diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-10-07 16:20:31 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-10-07 16:20:31 +0200 |
commit | a30b68fe1ded96c5aafe4348d1afec269354c469 (patch) | |
tree | 20051e46b2d00d40cf73e2ef36e0005841d49063 | |
parent | 1e06cabf4a8fa4d4c7acb9898682a5b4b41a9f58 (diff) | |
download | gitlab-ce-a30b68fe1ded96c5aafe4348d1afec269354c469.tar.gz |
Move CI services to project settings area
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/controllers/ci/services_controller.rb | 59 | ||||
-rw-r--r-- | app/controllers/projects/ci_services_controller.rb | 49 | ||||
-rw-r--r-- | app/views/layouts/ci/_nav_project.html.haml | 5 | ||||
-rw-r--r-- | app/views/layouts/nav/_project_settings.html.haml | 4 | ||||
-rw-r--r-- | app/views/projects/ci_services/_form.html.haml (renamed from app/views/ci/services/_form.html.haml) | 7 | ||||
-rw-r--r-- | app/views/projects/ci_services/edit.html.haml (renamed from app/views/ci/services/edit.html.haml) | 0 | ||||
-rw-r--r-- | app/views/projects/ci_services/index.html.haml (renamed from app/views/ci/services/index.html.haml) | 2 | ||||
-rw-r--r-- | config/routes.rb | 12 | ||||
-rw-r--r-- | spec/controllers/ci/commits_controller_spec.rb | 23 |
10 files changed, 61 insertions, 101 deletions
diff --git a/CHANGELOG b/CHANGELOG index 388fa2f8966..5ea1deea68b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -33,6 +33,7 @@ v 8.1.0 (unreleased) - Add user preference to change layout width (Peter Göbel) - Use commit status in merge request widget as preffered source of CI status - Integrate CI commit and build pages into project pages + - Move CI services page to project settings area v 8.0.4 - Fix Message-ID header to be RFC 2111-compliant to prevent e-mails being dropped (Stan Hu) diff --git a/app/controllers/ci/services_controller.rb b/app/controllers/ci/services_controller.rb deleted file mode 100644 index 52c96a34ce8..00000000000 --- a/app/controllers/ci/services_controller.rb +++ /dev/null @@ -1,59 +0,0 @@ -module Ci - class ServicesController < Ci::ApplicationController - before_action :authenticate_user! - before_action :project - before_action :authorize_access_project! - before_action :authorize_manage_project! - before_action :service, only: [:edit, :update, :test] - - respond_to :html - - layout 'ci/project' - - def index - @project.build_missing_services - @services = @project.services.reload - end - - def edit - end - - def update - if @service.update_attributes(service_params) - redirect_to edit_ci_project_service_path(@project, @service.to_param) - else - render 'edit' - end - end - - def test - last_build = @project.builds.last - - if @service.execute(last_build) - message = { notice: 'We successfully tested the service' } - else - message = { alert: 'We tried to test the service but error occurred' } - end - - redirect_to :back, message - end - - private - - def project - @project = Ci::Project.find(params[:project_id]) - end - - def service - @service ||= @project.services.find { |service| service.to_param == params[:id] } - end - - def service_params - params.require(:service).permit( - :type, :active, :webhook, :notify_only_broken_builds, - :email_recipients, :email_only_broken_builds, :email_add_pusher, - :hipchat_token, :hipchat_room, :hipchat_server - ) - end - end -end diff --git a/app/controllers/projects/ci_services_controller.rb b/app/controllers/projects/ci_services_controller.rb new file mode 100644 index 00000000000..6d2756eba3d --- /dev/null +++ b/app/controllers/projects/ci_services_controller.rb @@ -0,0 +1,49 @@ +class Projects::CiServicesController < Projects::ApplicationController + before_action :ci_project + before_action :authorize_admin_project! + + layout "project_settings" + + def index + @ci_project.build_missing_services + @services = @ci_project.services.reload + end + + def edit + service + end + + def update + if @service.update_attributes(service_params) + redirect_to edit_namespace_project_ci_service_path(@project, @project.namespace, @service.to_param) + else + render 'edit' + end + end + + def test + last_build = @project.builds.last + + if @service.execute(last_build) + message = { notice: 'We successfully tested the service' } + else + message = { alert: 'We tried to test the service but error occurred' } + end + + redirect_to :back, message + end + + private + + def service + @service ||= @ci_project.services.find { |service| service.to_param == params[:id] } + end + + def service_params + params.require(:service).permit( + :type, :active, :webhook, :notify_only_broken_builds, + :email_recipients, :email_only_broken_builds, :email_add_pusher, + :hipchat_token, :hipchat_room, :hipchat_server + ) + end +end diff --git a/app/views/layouts/ci/_nav_project.html.haml b/app/views/layouts/ci/_nav_project.html.haml index db631f24656..f094edbfa87 100644 --- a/app/views/layouts/ci/_nav_project.html.haml +++ b/app/views/layouts/ci/_nav_project.html.haml @@ -5,11 +5,6 @@ %span Back to project %li.separate-item - = nav_link path: ['services#index', 'services#edit'] do - = link_to ci_project_services_path(@project) do - = icon('share fw') - %span - Services = nav_link path: 'events#index' do = link_to ci_project_events_path(@project) do = icon('book fw') diff --git a/app/views/layouts/nav/_project_settings.html.haml b/app/views/layouts/nav/_project_settings.html.haml index f618a18870b..954dbe5d2b9 100644 --- a/app/views/layouts/nav/_project_settings.html.haml +++ b/app/views/layouts/nav/_project_settings.html.haml @@ -60,8 +60,8 @@ = icon('building fw') %span CI Settings - = nav_link path: ['ci/services#index', 'ci/services#edit'] do - = link_to ci_project_services_path(@project.gitlab_ci_project) do + = nav_link controller: 'ci_services' do + = link_to namespace_project_ci_services_path(@project.namespace, @project) do = icon('share fw') %span CI Services diff --git a/app/views/ci/services/_form.html.haml b/app/views/projects/ci_services/_form.html.haml index 9110aaa0528..397832e56db 100644 --- a/app/views/ci/services/_form.html.haml +++ b/app/views/projects/ci_services/_form.html.haml @@ -4,13 +4,10 @@ %p= @service.description -.back-link - = link_to ci_project_services_path(@project) do - ← to services %hr -= form_for(@service, as: :service, url: ci_project_service_path(@project, @service.to_param), method: :put, html: { class: 'form-horizontal' }) do |f| += form_for(@service, as: :service, url: namespace_project_ci_service_path(@project.namespace, @project, @service.to_param), method: :put, html: { class: 'form-horizontal' }) do |f| - if @service.errors.any? .alert.alert-danger %ul @@ -54,4 +51,4 @@ = f.submit 'Save', class: 'btn btn-save' - if @service.valid? && @service.activated? && @service.can_test? - = link_to 'Test settings', test_ci_project_service_path(@project, @service.to_param), class: 'btn' + = link_to 'Test settings', test_namespace_project_ci_service_path(@project.namespace, @project, @service.to_param), class: 'btn' diff --git a/app/views/ci/services/edit.html.haml b/app/views/projects/ci_services/edit.html.haml index bcc5832792f..bcc5832792f 100644 --- a/app/views/ci/services/edit.html.haml +++ b/app/views/projects/ci_services/edit.html.haml diff --git a/app/views/ci/services/index.html.haml b/app/views/projects/ci_services/index.html.haml index 37e5723b541..c78b21884a3 100644 --- a/app/views/ci/services/index.html.haml +++ b/app/views/projects/ci_services/index.html.haml @@ -13,7 +13,7 @@ %td = boolean_to_icon service.activated? %td - = link_to edit_ci_project_service_path(@project, service.to_param) do + = link_to edit_namespace_project_ci_service_path(@project.namespace, @project, service.to_param) do %strong= service.title %td = service.description diff --git a/config/routes.rb b/config/routes.rb index 4fb779e297c..e91b09de9b0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -22,12 +22,6 @@ Gitlab::Application.routes.draw do get :dumped_yaml end - resources :services, only: [:index, :edit, :update] do - member do - get :test - end - end - resources :runner_projects, only: [:create, :destroy] resources :events, only: [:index] @@ -576,6 +570,12 @@ Gitlab::Application.routes.draw do end end + resources :ci_services, constraints: { id: /[^\/]+/ }, only: [:index, :edit, :update] do + member do + get :test + end + end + resources :builds, only: [:show] do member do get :cancel diff --git a/spec/controllers/ci/commits_controller_spec.rb b/spec/controllers/ci/commits_controller_spec.rb deleted file mode 100644 index cc39ce7687c..00000000000 --- a/spec/controllers/ci/commits_controller_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require "spec_helper" - -describe Ci::CommitsController do - describe "GET /status" do - it "returns status of commit" do - commit = FactoryGirl.create :ci_commit - get :status, id: commit.sha, ref_id: commit.ref, project_id: commit.project.id - - expect(response).to be_success - expect(response.code).to eq('200') - JSON.parse(response.body)["status"] == "pending" - end - - it "returns not_found status" do - commit = FactoryGirl.create :ci_commit - get :status, id: commit.sha, ref_id: "deploy", project_id: commit.project.id - - expect(response).to be_success - expect(response.code).to eq('200') - JSON.parse(response.body)["status"] == "not_found" - end - end -end |