summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG1
-rw-r--r--app/controllers/ci/triggers_controller.rb43
-rw-r--r--app/controllers/projects/triggers_controller.rb35
-rw-r--r--app/views/layouts/ci/_nav_project.html.haml5
-rw-r--r--app/views/layouts/nav/_project_settings.html.haml5
-rw-r--r--app/views/projects/triggers/_trigger.html.haml (renamed from app/views/ci/triggers/_trigger.html.haml)2
-rw-r--r--app/views/projects/triggers/index.html.haml (renamed from app/views/ci/triggers/index.html.haml)10
-rw-r--r--config/routes.rb3
-rw-r--r--spec/features/triggers_spec.rb (renamed from spec/features/ci/triggers_spec.rb)9
9 files changed, 53 insertions, 60 deletions
diff --git a/CHANGELOG b/CHANGELOG
index f34f79d18dd..181baf24889 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -15,6 +15,7 @@ v 8.1.0 (unreleased)
- Fix grammar in admin area "labels" .nothing-here-block when no labels exist.
- Move CI runners page to project settings area
- Move CI variables page to project settings area
+ - Move CI triggers page to project settings area
v 8.0.3
- Fix URL shown in Slack notifications
diff --git a/app/controllers/ci/triggers_controller.rb b/app/controllers/ci/triggers_controller.rb
deleted file mode 100644
index a39cc5d3a56..00000000000
--- a/app/controllers/ci/triggers_controller.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-module Ci
- class TriggersController < Ci::ApplicationController
- before_action :authenticate_user!
- before_action :project
- before_action :authorize_access_project!
- before_action :authorize_manage_project!
-
- layout 'ci/project'
-
- def index
- @triggers = @project.triggers
- @trigger = Ci::Trigger.new
- end
-
- def create
- @trigger = @project.triggers.new
- @trigger.save
-
- if @trigger.valid?
- redirect_to ci_project_triggers_path(@project)
- else
- @triggers = @project.triggers.select(&:persisted?)
- render :index
- end
- end
-
- def destroy
- trigger.destroy
-
- redirect_to ci_project_triggers_path(@project)
- end
-
- private
-
- def trigger
- @trigger ||= @project.triggers.find(params[:id])
- end
-
- def project
- @project = Ci::Project.find(params[:project_id])
- end
- end
-end
diff --git a/app/controllers/projects/triggers_controller.rb b/app/controllers/projects/triggers_controller.rb
new file mode 100644
index 00000000000..782ebd01b05
--- /dev/null
+++ b/app/controllers/projects/triggers_controller.rb
@@ -0,0 +1,35 @@
+class Projects::TriggersController < Projects::ApplicationController
+ before_action :ci_project
+ before_action :authorize_admin_project!
+
+ layout 'project_settings'
+
+ def index
+ @triggers = @ci_project.triggers
+ @trigger = Ci::Trigger.new
+ end
+
+ def create
+ @trigger = @ci_project.triggers.new
+ @trigger.save
+
+ if @trigger.valid?
+ redirect_to namespace_project_triggers_path(@project.namespace, @project)
+ else
+ @triggers = @ci_project.triggers.select(&:persisted?)
+ render :index
+ end
+ end
+
+ def destroy
+ trigger.destroy
+
+ redirect_to namespace_project_triggers_path(@project.namespace, @project)
+ end
+
+ private
+
+ def trigger
+ @trigger ||= @ci_project.triggers.find(params[:id])
+ end
+end
diff --git a/app/views/layouts/ci/_nav_project.html.haml b/app/views/layouts/ci/_nav_project.html.haml
index 4b0dc4fc2f5..2d3cc3cf983 100644
--- a/app/views/layouts/ci/_nav_project.html.haml
+++ b/app/views/layouts/ci/_nav_project.html.haml
@@ -16,11 +16,6 @@
= icon('link fw')
%span
Web Hooks
- = nav_link path: 'triggers#index' do
- = link_to ci_project_triggers_path(@project) do
- = icon('retweet fw')
- %span
- Triggers
= nav_link path: ['services#index', 'services#edit'] do
= link_to ci_project_services_path(@project) do
= icon('share fw')
diff --git a/app/views/layouts/nav/_project_settings.html.haml b/app/views/layouts/nav/_project_settings.html.haml
index c8975fb8492..28efb035d09 100644
--- a/app/views/layouts/nav/_project_settings.html.haml
+++ b/app/views/layouts/nav/_project_settings.html.haml
@@ -45,3 +45,8 @@
= icon('code fw')
%span
Variables
+ = nav_link path: 'triggers#index' do
+ = link_to namespace_project_triggers_path(@project.namespace, @project) do
+ = icon('retweet fw')
+ %span
+ Triggers
diff --git a/app/views/ci/triggers/_trigger.html.haml b/app/views/projects/triggers/_trigger.html.haml
index addfbfcb0d4..48b3b5c9920 100644
--- a/app/views/ci/triggers/_trigger.html.haml
+++ b/app/views/projects/triggers/_trigger.html.haml
@@ -11,4 +11,4 @@
%td
.pull-right
- = link_to 'Revoke', ci_project_trigger_path(@project, trigger), data: { confirm: 'Are you sure?'}, method: :delete, class: "btn btn-danger btn-sm btn-grouped"
+ = link_to 'Revoke', namespace_project_trigger_path(@project.namespace, @project, trigger), data: { confirm: 'Are you sure?'}, method: :delete, class: "btn btn-danger btn-sm btn-grouped"
diff --git a/app/views/ci/triggers/index.html.haml b/app/views/projects/triggers/index.html.haml
index 44374a1a4d5..17dcb78e256 100644
--- a/app/views/ci/triggers/index.html.haml
+++ b/app/views/projects/triggers/index.html.haml
@@ -12,11 +12,11 @@
%th Token
%th Last used
%th
- = render @triggers
+ = render partial: 'trigger', collection: @triggers, as: :trigger
- else
%h4 No triggers
-= form_for [:ci, @project, @trigger], html: { class: 'form-horizontal' } do |f|
+= form_for @trigger, url: url_for(controller: 'projects/triggers', action: 'create'), html: { class: 'form-horizontal' } do |f|
.clearfix
= f.submit "Add Trigger", class: 'btn btn-success pull-right'
@@ -34,7 +34,7 @@
:plain
curl -X POST \
-F token=TOKEN \
- #{ci_build_trigger_url(@project.id, 'REF_NAME')}
+ #{ci_build_trigger_url(@ci_project.id, 'REF_NAME')}
%h3
Use .gitlab-ci.yml
@@ -49,7 +49,7 @@
trigger:
type: deploy
script:
- - "curl -X POST -F token=TOKEN #{ci_build_trigger_url(@project.id, 'REF_NAME')}"
+ - "curl -X POST -F token=TOKEN #{ci_build_trigger_url(@ci_project.id, 'REF_NAME')}"
%h3
Pass build variables
@@ -64,4 +64,4 @@
curl -X POST \
-F token=TOKEN \
-F "variables[RUN_NIGHTLY_BUILD]=true" \
- #{ci_build_trigger_url(@project.id, 'REF_NAME')}
+ #{ci_build_trigger_url(@ci_project.id, 'REF_NAME')}
diff --git a/config/routes.rb b/config/routes.rb
index 776b606bf7d..f7317fb5d9f 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -53,8 +53,6 @@ Gitlab::Application.routes.draw do
end
end
- resources :triggers, only: [:index, :create, :destroy]
-
resources :runner_projects, only: [:create, :destroy]
resources :events, only: [:index]
@@ -591,6 +589,7 @@ Gitlab::Application.routes.draw do
resources :tags, only: [:index, :new, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
resources :protected_branches, only: [:index, :create, :update, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
resource :variables, only: [:show, :update]
+ resources :triggers, only: [:index, :create, :destroy]
resources :hooks, only: [:index, :create, :destroy], constraints: { id: /\d+/ } do
member do
diff --git a/spec/features/ci/triggers_spec.rb b/spec/features/triggers_spec.rb
index c6afeb74628..69492d58878 100644
--- a/spec/features/ci/triggers_spec.rb
+++ b/spec/features/triggers_spec.rb
@@ -1,13 +1,14 @@
require 'spec_helper'
describe 'Triggers' do
- let(:user) { create(:user) }
+ let(:user) { create(:user) }
+ before { login_as(user) }
before do
- login_as(user)
@project = FactoryGirl.create :ci_project
- @project.gl_project.team << [user, :master]
- visit ci_project_triggers_path(@project)
+ @gl_project = @project.gl_project
+ @gl_project.team << [user, :master]
+ visit namespace_project_triggers_path(@gl_project.namespace, @gl_project)
end
context 'create a trigger' do