Move CI triggers page to project settings area
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
e1b7fcedfb
commit
2a0d4e7200
9 changed files with 53 additions and 60 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
35
app/controllers/projects/triggers_controller.rb
Normal file
35
app/controllers/projects/triggers_controller.rb
Normal file
|
@ -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
|
|
@ -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 @@ 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
|
||||
|
|
|
@ -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
|
Loading…
Reference in a new issue