Commit ef3ab73f authored by Justin Ho's avatar Justin Ho

Add group integrations listing

- Move _integrations.html partial to shared folder
- Add sidebar link and make it active when integration
pages are open
- Add group/integrations_controller with index action
parent 4a0b0e55
......@@ -7,6 +7,10 @@ module Groups
before_action :authorize_admin_group!
def index
@integrations = Project.first.find_or_initialize_services
end
private
# TODO: Make this compatible with group-level integration
......
......@@ -11,7 +11,18 @@ module GroupsHelper
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
......
......@@ -62,10 +62,6 @@ module ServicesHelper
!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 @@ module ServicesHelper
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)
......
......@@ -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'
......
- 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
......@@ -160,6 +160,11 @@
%span
= _('CI / CD')
= nav_link(controller: :integrations) do
= link_to group_settings_integrations_path(@group), title: _('Integrations') do
%span
= _('Integrations')
= render_if_exists "groups/ee/settings_nav"
= render_if_exists "groups/ee/administration_nav"
......
......@@ -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
......
......@@ -10250,6 +10250,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 ""
......@@ -10286,6 +10289,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 ""
......
......@@ -11,6 +11,39 @@ describe Groups::Settings::IntegrationsController do
sign_in(user)
end
describe '#index' 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 :index, params: { group_id: group }
expect(response).to have_gitlab_http_status(:not_found)
end
end
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
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 group_level_integrations not enabled' do
it 'returns not_found' do
......
......@@ -120,6 +120,7 @@ RSpec.shared_context 'group navbar structure' do
_('General'),
_('Projects'),
_('CI / CD'),
_('Integrations'),
_('Webhooks'),
_('Audit Events')
]
......
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