diff --git a/app/controllers/groups/settings/integrations_controller.rb b/app/controllers/groups/settings/integrations_controller.rb index 0ba030f26bc1344796bfb88b38eafe1e622374ff..adfbe9bfa17f618bc2e4c3909936255abca34000 100644 --- a/app/controllers/groups/settings/integrations_controller.rb +++ b/app/controllers/groups/settings/integrations_controller.rb @@ -7,6 +7,10 @@ class IntegrationsController < Groups::ApplicationController before_action :authorize_admin_group! + def index + @integrations = [] + end + private # TODO: Make this compatible with group-level integration diff --git a/app/helpers/groups_helper.rb b/app/helpers/groups_helper.rb index 5abe6a635e0ad320a69ee75fea8b8906b11d93eb..0d7e2a7bd38b43fb8b2ea934b8ece5bba5748a57 100644 --- a/app/helpers/groups_helper.rb +++ b/app/helpers/groups_helper.rb @@ -11,7 +11,18 @@ def group_overview_nav_link_paths end def group_nav_link_paths - %w[groups#projects groups#edit badges#index ci_cd#show ldap_group_links#index hooks#index audit_events#index pipeline_quota#index] + %w[ + groups#projects + groups#edit + badges#index + ci_cd#show + integrations#index + integrations#edit + ldap_group_links#index + hooks#index + audit_events#index + pipeline_quota#index + ] end def group_packages_nav_link_paths diff --git a/app/helpers/services_helper.rb b/app/helpers/services_helper.rb index fe2df9188196004a88bf6dd99a7e3567fec49540..a4b6e6131001fbcbef2b86e3c29d2e6a7c1f80a0 100644 --- a/app/helpers/services_helper.rb +++ b/app/helpers/services_helper.rb @@ -62,10 +62,6 @@ def disable_fields_service?(service) !current_controller?("admin/services") && service.deprecated? end - def edit_integration_path(integration) - edit_admin_application_settings_integration_path(integration) - end - def scoped_integrations_path if @project.present? project_settings_integrations_path(@project) @@ -86,6 +82,16 @@ def scoped_integration_path(integration) end end + def scoped_edit_integration_path(integration) + if @project.present? + edit_project_settings_integration_path(@project, integration) + elsif @group.present? + edit_group_settings_integration_path(@group, integration) + else + edit_admin_application_settings_integration_path(integration) + end + end + def scoped_test_integration_path(integration) if @project.present? test_project_settings_integration_path(@project, integration) diff --git a/app/views/admin/application_settings/integrations.html.haml b/app/views/admin/application_settings/integrations.html.haml index 14df0599583427c72723f169e2c4559ee45212b2..2b01160a230c9af337132f508a41138abf98455f 100644 --- a/app/views/admin/application_settings/integrations.html.haml +++ b/app/views/admin/application_settings/integrations.html.haml @@ -18,7 +18,7 @@ %p = s_('AdminSettings|Integrations configured here will automatically apply to all projects on this instance.') = link_to _('Learn more'), '#' - = render 'projects/services/integrations' + = render 'shared/integrations/integrations', integrations: @integrations - else = render_if_exists 'admin/application_settings/elasticsearch_form' diff --git a/app/views/groups/settings/integrations/index.html.haml b/app/views/groups/settings/integrations/index.html.haml new file mode 100644 index 0000000000000000000000000000000000000000..78825cc72b0ee21f4c566223743dda0bb0625cee --- /dev/null +++ b/app/views/groups/settings/integrations/index.html.haml @@ -0,0 +1,9 @@ +- breadcrumb_title _('Integrations') +- page_title _('Integrations') +- @content_class = 'limit-container-width' unless fluid_layout + +%h4= s_('GroupSettings|Apply integration settings to all Projects') +%p + = s_('GroupSettings|Integrations configured here will automatically apply to all projects in this group.') + = link_to _('Learn more'), '#' += render 'shared/integrations/integrations', integrations: @integrations diff --git a/app/views/layouts/nav/sidebar/_group.html.haml b/app/views/layouts/nav/sidebar/_group.html.haml index b3acf3320d38a83e842a5c6c7e4398f02c8d68fa..89bcccb61853a3087c1812ccaaca1768c943c2e6 100644 --- a/app/views/layouts/nav/sidebar/_group.html.haml +++ b/app/views/layouts/nav/sidebar/_group.html.haml @@ -159,6 +159,11 @@ = link_to group_settings_ci_cd_path(@group), title: _('CI / CD') do %span = _('CI / CD') + - if Feature.enabled?(:group_level_integrations, @group) + = nav_link(controller: :integrations) do + = link_to group_settings_integrations_path(@group), title: _('Integrations') do + %span + = _('Integrations') = render_if_exists "groups/ee/settings_nav" diff --git a/app/views/projects/services/_integrations.html.haml b/app/views/shared/integrations/_integrations.html.haml similarity index 91% rename from app/views/projects/services/_integrations.html.haml rename to app/views/shared/integrations/_integrations.html.haml index 24aeb598d7b2415c1971f9bd3c50625486bead78..b2359aca016c531900a1eb10b11a4c40483fe139 100644 --- a/app/views/projects/services/_integrations.html.haml +++ b/app/views/shared/integrations/_integrations.html.haml @@ -12,12 +12,12 @@ %th{ role: 'columnheader', scope: 'col', 'aria-colindex': 4 }= _('Last updated') %tbody{ role: 'rowgroup' } - - @integrations.each do |integration| + - integrations.each do |integration| %tr{ role: 'row' } %td{ role: 'cell', 'aria-colindex': 1 } = boolean_to_icon integration.activated? %td{ role: 'cell', 'aria-colindex': 2 } - = link_to edit_integration_path(integration) do + = link_to scoped_edit_integration_path(integration) do %strong= integration.title %td.d-none.d-sm-block{ role: 'cell', 'aria-colindex': 3 } = integration.description diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 971a77e55be20a3b9f8468b2a81c1dce5839c429..49f9e66db64c1be47d059db3117bf580b16d7ec1 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -10310,6 +10310,9 @@ msgstr "" msgid "GroupSAML|should be a random persistent ID, emails are discouraged" msgstr "" +msgid "GroupSettings|Apply integration settings to all Projects" +msgstr "" + msgid "GroupSettings|Auto DevOps pipeline was updated for the group" msgstr "" @@ -10346,6 +10349,9 @@ msgstr "" msgid "GroupSettings|If the parent group's visibility is lower than the group current visibility, visibility levels for subgroups and projects will be changed to match the new parent group's visibility." msgstr "" +msgid "GroupSettings|Integrations configured here will automatically apply to all projects in this group." +msgstr "" + msgid "GroupSettings|Learn more about badges." msgstr "" diff --git a/spec/controllers/groups/settings/integrations_controller_spec.rb b/spec/controllers/groups/settings/integrations_controller_spec.rb index eee65476dab39abf81af75b20e2db77974f78d4b..6df1ad8a38305f5cf62c4cfaa6fec64d76e40013 100644 --- a/spec/controllers/groups/settings/integrations_controller_spec.rb +++ b/spec/controllers/groups/settings/integrations_controller_spec.rb @@ -11,17 +11,40 @@ sign_in(user) end - describe '#edit' do - context 'when group_level_integrations not enabled' do - it 'returns not_found' do - stub_feature_flags(group_level_integrations: { enabled: false, thing: group }) - - get :edit, params: { group_id: group, id: Service.available_services_names.sample } + describe '#index' do + context 'when user is not owner' do + it 'renders not_found' do + get :index, params: { group_id: group } expect(response).to have_gitlab_http_status(:not_found) end end + context 'when user is owner' do + before do + group.add_owner(user) + end + + context 'when group_level_integrations not enabled' do + it 'returns not_found' do + stub_feature_flags(group_level_integrations: { enabled: false, thing: group }) + + get :index, params: { group_id: group } + + expect(response).to have_gitlab_http_status(:not_found) + end + end + + it 'successfully displays the template' do + get :index, params: { group_id: group } + + expect(response).to have_gitlab_http_status(:ok) + expect(response).to render_template(:index) + end + end + end + + describe '#edit' do context 'when user is not owner' do it 'renders not_found' do get :edit, params: { group_id: group, id: Service.available_services_names.sample } @@ -35,6 +58,16 @@ group.add_owner(user) end + context 'when group_level_integrations not enabled' do + it 'returns not_found' do + stub_feature_flags(group_level_integrations: { enabled: false, thing: group }) + + get :edit, params: { group_id: group, id: Service.available_services_names.sample } + + expect(response).to have_gitlab_http_status(:not_found) + end + end + Service.available_services_names.each do |integration_name| context "#{integration_name}" do it 'successfully displays the template' do diff --git a/spec/support/shared_contexts/navbar_structure_context.rb b/spec/support/shared_contexts/navbar_structure_context.rb index 2a98855a83fe9c91d2b937cf85ba801b96dd099f..9ffe13545f701df8a13ebd5bb12bc238925f3d79 100644 --- a/spec/support/shared_contexts/navbar_structure_context.rb +++ b/spec/support/shared_contexts/navbar_structure_context.rb @@ -120,6 +120,7 @@ _('General'), _('Projects'), _('CI / CD'), + _('Integrations'), _('Webhooks'), _('Audit Events') ]