From 9f0d794513d2ce1c990e61f4d21efe1dcad845fd Mon Sep 17 00:00:00 2001 From: Jose Ivan Vargas Date: Fri, 30 Dec 2016 11:30:25 -0600 Subject: Moved the webhooks and services gear options to a single one called integrations --- app/controllers/projects/hooks_controller.rb | 7 ++--- app/controllers/projects/services_controller.rb | 2 +- .../projects/settings/integrations_controller.rb | 18 ++++++++++++ app/helpers/gitlab_routing_helper.rb | 3 ++ app/views/layouts/nav/_project_settings.html.haml | 10 ++----- app/views/projects/hooks/_index.html.haml | 1 + app/views/projects/hooks/index.html.haml | 1 - app/views/projects/services/_index.html.haml | 31 ++++++++++++++++++++ app/views/projects/services/index.html.haml | 33 ---------------------- .../projects/settings/integrations/show.html.haml | 3 ++ config/routes/project.rb | 2 +- 11 files changed, 64 insertions(+), 47 deletions(-) create mode 100644 app/controllers/projects/settings/integrations_controller.rb create mode 100644 app/views/projects/hooks/_index.html.haml delete mode 100644 app/views/projects/hooks/index.html.haml create mode 100644 app/views/projects/services/_index.html.haml delete mode 100644 app/views/projects/services/index.html.haml create mode 100644 app/views/projects/settings/integrations/show.html.haml diff --git a/app/controllers/projects/hooks_controller.rb b/app/controllers/projects/hooks_controller.rb index 0ae8ff98009..8c52aa748ae 100644 --- a/app/controllers/projects/hooks_controller.rb +++ b/app/controllers/projects/hooks_controller.rb @@ -7,8 +7,7 @@ class Projects::HooksController < Projects::ApplicationController layout "project_settings" def index - @hooks = @project.hooks - @hook = ProjectHook.new + redirect_to namespace_project_settings_integrations_path(@project.namespace, @project) end def create @@ -16,7 +15,7 @@ class Projects::HooksController < Projects::ApplicationController @hook.save if @hook.valid? - redirect_to namespace_project_hooks_path(@project.namespace, @project) + redirect_to namespace_project_settings_integrations_path(@project.namespace, @project) else @hooks = @project.hooks.select(&:persisted?) render :index @@ -44,7 +43,7 @@ class Projects::HooksController < Projects::ApplicationController def destroy hook.destroy - redirect_to namespace_project_hooks_path(@project.namespace, @project) + redirect_to namespace_project_settings_integrations_path(@project.namespace, @project) end private diff --git a/app/controllers/projects/services_controller.rb b/app/controllers/projects/services_controller.rb index 30c2a5d9982..b4c40c6bf14 100644 --- a/app/controllers/projects/services_controller.rb +++ b/app/controllers/projects/services_controller.rb @@ -10,7 +10,7 @@ class Projects::ServicesController < Projects::ApplicationController layout "project_settings" def index - @services = @project.find_or_initialize_services + redirect_to namespace_project_settings_integrations_path(@project.namespace, @project) end def edit diff --git a/app/controllers/projects/settings/integrations_controller.rb b/app/controllers/projects/settings/integrations_controller.rb new file mode 100644 index 00000000000..07563e45865 --- /dev/null +++ b/app/controllers/projects/settings/integrations_controller.rb @@ -0,0 +1,18 @@ +module Projects + module Settings + class IntegrationsController < Projects::ApplicationController + include ServiceParams + + before_action :authorize_admin_project! + + layout "project_settings" + def show + @hooks = @project.hooks + @hook = ProjectHook.new + + # Services + @services = @project.find_or_initialize_services + end + end + end +end diff --git a/app/helpers/gitlab_routing_helper.rb b/app/helpers/gitlab_routing_helper.rb index 5742fec4458..44e22d6abd5 100644 --- a/app/helpers/gitlab_routing_helper.rb +++ b/app/helpers/gitlab_routing_helper.rb @@ -208,6 +208,9 @@ module GitlabRoutingHelper end # Settings + def project_settings_integrations_path(project, *args) + namespace_project_settings_integrations_path(project.namespace, project, *args) + end def project_settings_members_path(project, *args) namespace_project_settings_members_path(project.namespace, project, *args) end diff --git a/app/views/layouts/nav/_project_settings.html.haml b/app/views/layouts/nav/_project_settings.html.haml index 0fb2bb460cb..08e016a1773 100644 --- a/app/views/layouts/nav/_project_settings.html.haml +++ b/app/views/layouts/nav/_project_settings.html.haml @@ -8,14 +8,10 @@ = link_to namespace_project_deploy_keys_path(@project.namespace, @project), title: 'Deploy Keys' do %span Deploy Keys - = nav_link(controller: :hooks) do - = link_to namespace_project_hooks_path(@project.namespace, @project), title: 'Webhooks' do + = nav_link(controller: :integrations) do + = link_to namespace_project_settings_integrations_path(@project.namespace, @project), title: 'Webhooks' do %span - Webhooks - = nav_link(controller: :services) do - = link_to namespace_project_services_path(@project.namespace, @project), title: 'Services' do - %span - Services + Integrations = nav_link(controller: :protected_branches) do = link_to namespace_project_protected_branches_path(@project.namespace, @project), title: 'Protected Branches' do %span diff --git a/app/views/projects/hooks/_index.html.haml b/app/views/projects/hooks/_index.html.haml new file mode 100644 index 00000000000..8faad351463 --- /dev/null +++ b/app/views/projects/hooks/_index.html.haml @@ -0,0 +1 @@ += render 'shared/web_hooks/form', hook: @hook, hooks: @hooks, url_components: [@project.namespace.becomes(Namespace), @project] diff --git a/app/views/projects/hooks/index.html.haml b/app/views/projects/hooks/index.html.haml deleted file mode 100644 index 8faad351463..00000000000 --- a/app/views/projects/hooks/index.html.haml +++ /dev/null @@ -1 +0,0 @@ -= render 'shared/web_hooks/form', hook: @hook, hooks: @hooks, url_components: [@project.namespace.becomes(Namespace), @project] diff --git a/app/views/projects/services/_index.html.haml b/app/views/projects/services/_index.html.haml new file mode 100644 index 00000000000..964133504e6 --- /dev/null +++ b/app/views/projects/services/_index.html.haml @@ -0,0 +1,31 @@ +.row.prepend-top-default.append-bottom-default + .col-lg-3 + %h4.prepend-top-0 + Project services + %p Project services allow you to integrate GitLab with other applications + .col-lg-9 + %table.table + %colgroup + %col + %col + %col.hidden-xs + %col{ width: "120" } + %thead + %tr + %th + %th Service + %th.hidden-xs Description + %th Last edit + - @services.sort_by(&:title).each do |service| + %tr + %td + = boolean_to_icon service.activated? + %td + = link_to edit_namespace_project_service_path(@project.namespace, @project, service.to_param) do + %strong= service.title + %td.hidden-xs + = service.description + %td.light + - if service.updated_at.present? + = time_ago_in_words service.updated_at + ago diff --git a/app/views/projects/services/index.html.haml b/app/views/projects/services/index.html.haml deleted file mode 100644 index 66fd3029dc9..00000000000 --- a/app/views/projects/services/index.html.haml +++ /dev/null @@ -1,33 +0,0 @@ -- page_title "Services" - -.row.prepend-top-default.append-bottom-default - .col-lg-3 - %h4.prepend-top-0 - Project services - %p Project services allow you to integrate GitLab with other applications - .col-lg-9 - %table.table - %colgroup - %col - %col - %col.hidden-xs - %col{ width: "120" } - %thead - %tr - %th - %th Service - %th.hidden-xs Description - %th Last edit - - @services.sort_by(&:title).each do |service| - %tr - %td - = boolean_to_icon service.activated? - %td - = link_to edit_namespace_project_service_path(@project.namespace, @project, service.to_param) do - %strong= service.title - %td.hidden-xs - = service.description - %td.light - - if service.updated_at.present? - = time_ago_in_words service.updated_at - ago diff --git a/app/views/projects/settings/integrations/show.html.haml b/app/views/projects/settings/integrations/show.html.haml new file mode 100644 index 00000000000..aa38a889cdd --- /dev/null +++ b/app/views/projects/settings/integrations/show.html.haml @@ -0,0 +1,3 @@ +- page_title 'Integrations' += render 'projects/hooks/index' += render 'projects/services/index' diff --git a/config/routes/project.rb b/config/routes/project.rb index 1fc6ed28c74..6620b765e02 100644 --- a/config/routes/project.rb +++ b/config/routes/project.rb @@ -307,9 +307,9 @@ constraints(ProjectUrlConstrainer.new) do end end end - namespace :settings do resource :members, only: [:show] + resource :integrations, only: [:show] end # Since both wiki and repository routing contains wildcard characters -- cgit v1.2.1