Commit d610ff39 authored by Tom Quirk's avatar Tom Quirk Committed by Jan Provaznik

Show service templates nav based on FF

Put Service Templates nav item behind a featureflag,
currently disabled by default. When enabled,
the link won't be present in the UI.
parent 83573e22
...@@ -172,6 +172,14 @@ module ServicesHelper ...@@ -172,6 +172,14 @@ module ServicesHelper
name: integration.to_param name: integration.to_param
} }
end end
def service_templates_enabled?
Feature.disabled?(:disable_service_templates, type: :development, default_enabled: :yaml)
end
def show_service_templates_nav_link?
service_templates_enabled?
end
end end
ServicesHelper.prepend_if_ee('EE::ServicesHelper') ServicesHelper.prepend_if_ee('EE::ServicesHelper')
......
...@@ -202,17 +202,18 @@ ...@@ -202,17 +202,18 @@
= render_if_exists 'layouts/nav/sidebar/credentials_link' = render_if_exists 'layouts/nav/sidebar/credentials_link'
= nav_link(controller: :services) do - if show_service_templates_nav_link?
= link_to admin_application_settings_services_path do = nav_link(controller: :services) do
.nav-icon-container = link_to admin_application_settings_services_path do
= sprite_icon('template') .nav-icon-container
%span.nav-item-name = sprite_icon('template')
= _('Service Templates') %span.nav-item-name
%ul.sidebar-sub-level-items.is-fly-out-only = _('Service Templates')
= nav_link(controller: :services, html_options: { class: "fly-out-top-item" } ) do %ul.sidebar-sub-level-items.is-fly-out-only
= link_to admin_application_settings_services_path do = nav_link(controller: :services, html_options: { class: "fly-out-top-item" } ) do
%strong.fly-out-top-item-name = link_to admin_application_settings_services_path do
= _('Service Templates') %strong.fly-out-top-item-name
= _('Service Templates')
= nav_link(controller: :labels) do = nav_link(controller: :labels) do
= link_to admin_labels_path do = link_to admin_labels_path do
......
---
name: disable_service_templates
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/59098
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/327436
milestone: '13.12'
type: development
group: group::ecosystem
default_enabled: false
...@@ -251,41 +251,64 @@ RSpec.describe 'Admin updates settings' do ...@@ -251,41 +251,64 @@ RSpec.describe 'Admin updates settings' do
end end
end end
context 'when the Slack Notifications Service template is active' do context 'when Service Templates are enabled' do
before do before do
create(:service, :template, type: 'SlackService', active: true) stub_feature_flags(disable_service_templates: false)
end
visit general_admin_application_settings_path context 'when no service templates are active' do
it 'does not show Service Templates link' do
expect(page).not_to have_link('Service Templates')
end
end end
it 'change Slack Notifications Service template settings', :js do context 'when the Slack Notifications Service template is active' do
first(:link, 'Service Templates').click before do
click_link 'Slack notifications' stub_feature_flags(disable_service_templates: false)
fill_in 'Webhook', with: 'http://localhost' create(:service, :template, type: 'SlackService', active: true)
fill_in 'Username', with: 'test_user'
fill_in 'service[push_channel]', with: '#test_channel'
page.check('Notify only broken pipelines')
page.select 'All branches', from: 'Branches to be notified'
page.select 'Match any of the labels', from: 'Labels to be notified behavior'
check_all_events visit general_admin_application_settings_path
click_button 'Save changes' end
expect(page).to have_content 'Application settings saved successfully' it 'change Slack Notifications Service template settings', :js do
first(:link, 'Service Templates').click
click_link 'Slack notifications'
fill_in 'Webhook', with: 'http://localhost'
fill_in 'Username', with: 'test_user'
fill_in 'service[push_channel]', with: '#test_channel'
page.check('Notify only broken pipelines')
page.select 'All branches', from: 'Branches to be notified'
page.select 'Match any of the labels', from: 'Labels to be notified behavior'
check_all_events
click_button 'Save changes'
click_link 'Slack notifications' expect(page).to have_content 'Application settings saved successfully'
expect(page.all('input[type=checkbox]')).to all(be_checked) click_link 'Slack notifications'
expect(find_field('Webhook').value).to eq 'http://localhost'
expect(find_field('Username').value).to eq 'test_user' expect(page.all('input[type=checkbox]')).to all(be_checked)
expect(find('[name="service[push_channel]"]').value).to eq '#test_channel' expect(find_field('Webhook').value).to eq 'http://localhost'
expect(find_field('Username').value).to eq 'test_user'
expect(find('[name="service[push_channel]"]').value).to eq '#test_channel'
end
it 'defaults Deployment events to false for chat notification template settings', :js do
first(:link, 'Service Templates').click
click_link 'Slack notifications'
expect(find_field('Deployment')).not_to be_checked
end
end end
end
it 'defaults Deployment events to false for chat notification template settings', :js do context 'When Service templates are disabled' do
first(:link, 'Service Templates').click before do
click_link 'Slack notifications' stub_feature_flags(disable_service_templates: true)
end
expect(find_field('Deployment')).not_to be_checked it 'does not show Service Templates link' do
expect(page).not_to have_link('Service Templates')
end end
end end
......
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