Move CI triggers page to project settings area

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent e1b7fced
......@@ -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
......
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
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
......@@ -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')
......
......@@ -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
......@@ -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"
......@@ -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')}
......@@ -53,8 +53,6 @@
end
end
resources :triggers, only: [:index, :create, :destroy]
resources :runner_projects, only: [:create, :destroy]
resources :events, only: [:index]
......@@ -591,6 +589,7 @@
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
......
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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment