Commit ccb431ba authored by Dylan Griffith's avatar Dylan Griffith

Merge branch '238983-add-group-integrations-to-sidebar-navigation' into 'master'

Update group integrations sidebar navigation and add docs link

Closes #238983

See merge request gitlab-org/gitlab!39948
parents 52bcad4b 4bdb1c71
...@@ -42,6 +42,7 @@ export default { ...@@ -42,6 +42,7 @@ export default {
v-if="adminState !== null" v-if="adminState !== null"
:inherit-from-id="adminState.id" :inherit-from-id="adminState.id"
:override="override" :override="override"
:learn-more-path="propsSource.learnMorePath"
@change="setOverride" @change="setOverride"
/> />
<active-checkbox v-if="propsSource.showActive" :key="`${currentKey}-active-checkbox`" /> <active-checkbox v-if="propsSource.showActive" :key="`${currentKey}-active-checkbox`" />
......
<script> <script>
import { GlNewDropdown, GlNewDropdownItem } from '@gitlab/ui'; import { GlNewDropdown, GlNewDropdownItem, GlLink } from '@gitlab/ui';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
const dropdownOptions = [ const dropdownOptions = [
...@@ -19,12 +19,18 @@ export default { ...@@ -19,12 +19,18 @@ export default {
components: { components: {
GlNewDropdown, GlNewDropdown,
GlNewDropdownItem, GlNewDropdownItem,
GlLink,
}, },
props: { props: {
inheritFromId: { inheritFromId: {
type: Number, type: Number,
required: true, required: true,
}, },
learnMorePath: {
type: String,
required: false,
default: null,
},
override: { override: {
type: Boolean, type: Boolean,
required: true, required: true,
...@@ -48,7 +54,12 @@ export default { ...@@ -48,7 +54,12 @@ export default {
<div <div
class="gl-display-flex gl-justify-content-space-between gl-align-items-baseline gl-py-4 gl-mt-5 gl-mb-6 gl-border-t-1 gl-border-t-solid gl-border-b-1 gl-border-b-solid gl-border-gray-100" class="gl-display-flex gl-justify-content-space-between gl-align-items-baseline gl-py-4 gl-mt-5 gl-mb-6 gl-border-t-1 gl-border-t-solid gl-border-b-1 gl-border-b-solid gl-border-gray-100"
> >
<span>{{ s__('Integrations|Default settings are inherited from the instance level.') }}</span> <span
>{{ s__('Integrations|Default settings are inherited from the instance level.') }}
<gl-link v-if="learnMorePath" :href="learnMorePath" target="_blank">{{
__('Learn more')
}}</gl-link>
</span>
<input name="service[inherit_from_id]" :value="override ? '' : inheritFromId" type="hidden" /> <input name="service[inherit_from_id]" :value="override ? '' : inheritFromId" type="hidden" />
<gl-new-dropdown :text="selected.text"> <gl-new-dropdown :text="selected.text">
<gl-new-dropdown-item <gl-new-dropdown-item
......
...@@ -19,6 +19,7 @@ function parseDatasetToProps(data) { ...@@ -19,6 +19,7 @@ function parseDatasetToProps(data) {
projectKey, projectKey,
upgradePlanPath, upgradePlanPath,
editProjectPath, editProjectPath,
learnMorePath,
triggerEvents, triggerEvents,
fields, fields,
inheritFromId, inheritFromId,
...@@ -51,6 +52,7 @@ function parseDatasetToProps(data) { ...@@ -51,6 +52,7 @@ function parseDatasetToProps(data) {
upgradePlanPath, upgradePlanPath,
editProjectPath, editProjectPath,
}, },
learnMorePath,
triggerEvents: JSON.parse(triggerEvents), triggerEvents: JSON.parse(triggerEvents),
fields: JSON.parse(fields), fields: JSON.parse(fields),
inheritFromId: parseInt(inheritFromId, 10), inheritFromId: parseInt(inheritFromId, 10),
......
...@@ -92,6 +92,7 @@ module ServicesHelper ...@@ -92,6 +92,7 @@ module ServicesHelper
commit_events: integration.commit_events.to_s, commit_events: integration.commit_events.to_s,
enable_comments: integration.comment_on_event_enabled.to_s, enable_comments: integration.comment_on_event_enabled.to_s,
comment_detail: integration.comment_detail, comment_detail: integration.comment_detail,
learn_more_path: integrations_help_page_path,
trigger_events: trigger_events_for_service(integration), trigger_events: trigger_events_for_service(integration),
fields: fields_for_service(integration), fields: fields_for_service(integration),
inherit_from_id: integration.inherit_from_id inherit_from_id: integration.inherit_from_id
...@@ -106,10 +107,18 @@ module ServicesHelper ...@@ -106,10 +107,18 @@ module ServicesHelper
ServiceFieldSerializer.new(service: integration).represent(integration.global_fields).to_json ServiceFieldSerializer.new(service: integration).represent(integration.global_fields).to_json
end end
def integrations_help_page_path
help_page_path('user/admin_area/settings/project_integration_management')
end
def project_jira_issues_integration? def project_jira_issues_integration?
false false
end end
def group_level_integrations?
@group.present? && Feature.enabled?(:group_level_integrations, @group)
end
extend self extend self
end end
......
...@@ -16,5 +16,5 @@ ...@@ -16,5 +16,5 @@
%h4= s_('AdminSettings|Apply integration settings to all Projects') %h4= s_('AdminSettings|Apply integration settings to all Projects')
%p %p
= s_('AdminSettings|Integrations configured here will automatically apply to all projects on this instance.') = s_('AdminSettings|Integrations configured here will automatically apply to all projects on this instance.')
= link_to _('Learn more'), '#' = link_to _('Learn more'), integrations_help_page_path, target: '_blank', rel: 'noopener noreferrer'
= render 'shared/integrations/index', integrations: @integrations = render 'shared/integrations/index', integrations: @integrations
...@@ -5,5 +5,5 @@ ...@@ -5,5 +5,5 @@
%h4= s_('GroupSettings|Apply integration settings to all Projects') %h4= s_('GroupSettings|Apply integration settings to all Projects')
%p %p
= s_('GroupSettings|Integrations configured here will automatically apply to all projects in this group.') = s_('GroupSettings|Integrations configured here will automatically apply to all projects in this group.')
= link_to _('Learn more'), '#' = link_to _('Learn more'), integrations_help_page_path, target: '_blank', rel: 'noopener noreferrer'
= render 'shared/integrations/index', integrations: @integrations = render 'shared/integrations/index', integrations: @integrations
...@@ -157,6 +157,12 @@ ...@@ -157,6 +157,12 @@
%span %span
= _('General') = _('General')
- if group_level_integrations?
= nav_link(controller: :integrations) do
= link_to group_settings_integrations_path(@group), title: _('Integrations') do
%span
= _('Integrations')
= nav_link(path: 'groups#projects') do = nav_link(path: 'groups#projects') do
= link_to projects_group_path(@group), title: _('Projects') do = link_to projects_group_path(@group), title: _('Projects') do
%span %span
...@@ -171,11 +177,6 @@ ...@@ -171,11 +177,6 @@
= link_to group_settings_ci_cd_path(@group), title: _('CI / CD') do = link_to group_settings_ci_cd_path(@group), title: _('CI / CD') do
%span %span
= _('CI / CD') = _('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" = render_if_exists "groups/ee/settings_nav"
......
...@@ -12,4 +12,4 @@ ...@@ -12,4 +12,4 @@
- if integration.editable? - if integration.editable?
.footer-block.row-content-block .footer-block.row-content-block
= service_save_button = service_save_button
= link_to _('Cancel'), scoped_integration_path(integration), class: 'btn btn-cancel' = link_to _('Cancel'), scoped_integrations_path, class: 'btn btn-cancel'
import { shallowMount } from '@vue/test-utils';
import { GlNewDropdown, GlLink } from '@gitlab/ui';
import OverrideDropdown from '~/integrations/edit/components/override_dropdown.vue';
describe('OverrideDropdown', () => {
let wrapper;
const defaultProps = {
inheritFromId: 1,
override: true,
};
const createComponent = (props = {}) => {
wrapper = shallowMount(OverrideDropdown, {
propsData: { ...defaultProps, ...props },
});
};
afterEach(() => {
if (wrapper) {
wrapper.destroy();
wrapper = null;
}
});
const findGlLink = () => wrapper.find(GlLink);
const findGlNewDropdown = () => wrapper.find(GlNewDropdown);
describe('template', () => {
describe('override prop is true', () => {
it('renders GlToggle as disabled', () => {
createComponent();
expect(findGlNewDropdown().props('text')).toBe('Use custom settings');
});
});
describe('override prop is false', () => {
it('renders GlToggle as disabled', () => {
createComponent({ override: false });
expect(findGlNewDropdown().props('text')).toBe('Use default settings');
});
});
describe('learnMorePath is present', () => {
it('renders GlLink with correct link', () => {
createComponent({
learnMorePath: '/docs',
});
expect(findGlLink().text()).toBe('Learn more');
expect(findGlLink().attributes('href')).toBe('/docs');
});
});
});
});
...@@ -26,4 +26,36 @@ RSpec.describe ServicesHelper do ...@@ -26,4 +26,36 @@ RSpec.describe ServicesHelper do
end end
end end
end end
describe '#group_level_integrations?' do
subject { helper.group_level_integrations? }
context 'when no group is present' do
it { is_expected.to eq(false) }
end
context 'when group is present' do
let(:group) { build_stubbed(:group) }
before do
assign(:group, group)
end
context 'when `group_level_integrations` is not enabled' do
it 'returns false' do
stub_feature_flags(group_level_integrations: false)
is_expected.to eq(false)
end
end
context 'when `group_level_integrations` is enabled for the group' do
it 'returns true' do
stub_feature_flags(group_level_integrations: group)
is_expected.to eq(true)
end
end
end
end
end end
...@@ -119,10 +119,10 @@ RSpec.shared_context 'group navbar structure' do ...@@ -119,10 +119,10 @@ RSpec.shared_context 'group navbar structure' do
nav_item: _('Settings'), nav_item: _('Settings'),
nav_sub_items: [ nav_sub_items: [
_('General'), _('General'),
_('Integrations'),
_('Projects'), _('Projects'),
_('Repository'), _('Repository'),
_('CI / CD'), _('CI / CD'),
_('Integrations'),
_('Webhooks'), _('Webhooks'),
_('Audit Events') _('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