Commit 57bc195e authored by Martin Wortschack's avatar Martin Wortschack

Merge branch...

Merge branch '333586-devops-adoption-allow-multi-select-for-enabling-disabling-groups' into 'master'

DevOps Adoption - Allow multi-select for enabling / disabling groups

See merge request gitlab-org/gitlab!66818
parents fac4ed62 b02a9c52
...@@ -48,6 +48,7 @@ feature is available. ...@@ -48,6 +48,7 @@ feature is available.
> - DAST and SAST metrics [added](https://gitlab.com/gitlab-org/gitlab/-/issues/328033) in GitLab 14.1. > - DAST and SAST metrics [added](https://gitlab.com/gitlab-org/gitlab/-/issues/328033) in GitLab 14.1.
> - Fuzz Testing metrics [added](https://gitlab.com/gitlab-org/gitlab/-/issues/330398) in GitLab 14.2. > - Fuzz Testing metrics [added](https://gitlab.com/gitlab-org/gitlab/-/issues/330398) in GitLab 14.2.
> - Dependency Scanning metrics [added](https://gitlab.com/gitlab-org/gitlab/-/issues/328034) in GitLab 14.2. > - Dependency Scanning metrics [added](https://gitlab.com/gitlab-org/gitlab/-/issues/328034) in GitLab 14.2.
> - Multiselect [added](https://gitlab.com/gitlab-org/gitlab/-/issues/333586) in GitLab 14.2.
DevOps Adoption shows you which groups in your organization are using the most essential features of GitLab: DevOps Adoption shows you which groups in your organization are using the most essential features of GitLab:
...@@ -66,15 +67,15 @@ DevOps Adoption shows you which groups in your organization are using the most e ...@@ -66,15 +67,15 @@ DevOps Adoption shows you which groups in your organization are using the most e
- Pipelines - Pipelines
- Runners - Runners
To add your groups, in the top right-hand section the page, select **Add group to table**. To add or remove your groups, in the top right-hand section the page, select **Add or remove groups**.
DevOps Adoption allows you to: DevOps Adoption allows you to:
- Verify whether you are getting the return on investment that you expected from GitLab. - Verify whether you are getting the return on investment that you expected from GitLab.
- Identify specific groups that are lagging in their adoption of GitLab so you can help them along in their DevOps journey. - Identify specific groups that are lagging in their adoption of GitLab, so you can help them along in their DevOps journey.
- Find the groups that have adopted certain features and can provide guidance to other groups on how to use those features. - Find the groups that have adopted certain features, and can provide guidance to other groups on how to use those features.
![DevOps Report](img/admin_devops_adoption_v14_1.png) ![DevOps Report](img/admin_devops_adoption_v14_2.png)
### Disable or enable DevOps Adoption ### Disable or enable DevOps Adoption
......
...@@ -12,6 +12,7 @@ info: To determine the technical writer assigned to the Stage/Group associated w ...@@ -12,6 +12,7 @@ info: To determine the technical writer assigned to the Stage/Group associated w
> - DAST and SAST metrics [added](https://gitlab.com/gitlab-org/gitlab/-/issues/328033) in GitLab 14.1. > - DAST and SAST metrics [added](https://gitlab.com/gitlab-org/gitlab/-/issues/328033) in GitLab 14.1.
> - Fuzz Testing metrics [added](https://gitlab.com/gitlab-org/gitlab/-/issues/330398) in GitLab 14.2. > - Fuzz Testing metrics [added](https://gitlab.com/gitlab-org/gitlab/-/issues/330398) in GitLab 14.2.
> - Dependency Scanning metrics [added](https://gitlab.com/gitlab-org/gitlab/-/issues/328034) in GitLab 14.2. > - Dependency Scanning metrics [added](https://gitlab.com/gitlab-org/gitlab/-/issues/328034) in GitLab 14.2.
> - Multiselect [added](https://gitlab.com/gitlab-org/gitlab/-/issues/333586) in GitLab 14.2.
Prerequisites: Prerequisites:
...@@ -19,7 +20,7 @@ Prerequisites: ...@@ -19,7 +20,7 @@ Prerequisites:
To access Group DevOps Adoption, go to your group and select **Analytics > DevOps Adoption**. To access Group DevOps Adoption, go to your group and select **Analytics > DevOps Adoption**.
Group DevOps Adoption shows you how individual groups and sub-groups within your organization use the following features: Group DevOps Adoption shows you how individual groups and subgroups within your organization use the following features:
- Dev - Dev
- Approvals - Approvals
...@@ -36,16 +37,16 @@ Group DevOps Adoption shows you how individual groups and sub-groups within your ...@@ -36,16 +37,16 @@ Group DevOps Adoption shows you how individual groups and sub-groups within your
- Pipelines - Pipelines
- Runners - Runners
When managing groups in the UI, you can add your sub-groups with the **Add sub-group to table** When managing groups in the UI, you can add or remove your subgroups with the **Add or remove subgroups**
button, in the top right hand section of your Groups pages. button, in the top right hand section of your Groups pages.
With DevOps Adoption you can: With DevOps Adoption you can:
- Verify whether you are getting the return on investment that you expected from GitLab. - Verify whether you are getting the return on investment that you expected from GitLab.
- Identify specific sub-groups that are lagging in their adoption of GitLab so you can help them along in their DevOps journey. - Identify specific subgroups that are lagging in their adoption of GitLab, so you can help them along in their DevOps journey.
- Find the sub-groups that have adopted certain features and can provide guidance to other sub-groups on how to use those features. - Find the subgroups that have adopted certain features, and can provide guidance to other subgroups on how to use those features.
![DevOps Report](img/group_devops_adoption_v14_1.png) ![DevOps Report](img/group_devops_adoption_v14_2.png)
## Enable data processing ## Enable data processing
...@@ -59,10 +60,10 @@ GitLab requires around a minute to process it. ...@@ -59,10 +60,10 @@ GitLab requires around a minute to process it.
## What is displayed ## What is displayed
DevOps Adoption displays feature adoption data for the given group DevOps Adoption displays feature adoption data for the given group
and any added sub-groups for the current calendar month. and any added subgroups for the current calendar month.
Each group appears as a separate row in the table. Each group appears as a separate row in the table.
For each row, a feature is considered "adopted" if it has been used in a project in the given group For each row, a feature is considered "adopted" if it has been used in a project in the given group
during the time period (including projects in any sub-groups of the given group). during the time period (including projects in any subgroups of the given group).
## When is a feature considered adopted ## When is a feature considered adopted
...@@ -83,14 +84,14 @@ Following this guideline, GitLab doesn't penalize for: ...@@ -83,14 +84,14 @@ Following this guideline, GitLab doesn't penalize for:
over time, so we should not consider adoption to have decreased if GitLab adds features. over time, so we should not consider adoption to have decreased if GitLab adds features.
This means we should not measure adoption by percentages, only total counts. This means we should not measure adoption by percentages, only total counts.
## Add a sub-group ## Add a subgroup
DevOps Adoption can also display data for sub-groups within the given group, DevOps Adoption can also display data for subgroups within the given group,
to show you differences in adoption across the group. to show you differences in adoption across the group.
To add a sub-group to your Group DevOps Adoption report: To add subgroups to your Group DevOps Adoption report:
1. Select **Add/remove sub-groups**. 1. Select **Add or remove subgroups**.
1. Select the sub-group you want to add and select **Save changes**. 1. Select the subgroups you want to add and select **Save changes**.
The sub-group data might not appear immediately, because GitLab requires around a minute to collect The subgroup data might not appear immediately, because GitLab requires around a minute to collect
the data. the data.
...@@ -8,7 +8,7 @@ import { ...@@ -8,7 +8,7 @@ import {
} from '@gitlab/ui'; } from '@gitlab/ui';
import * as Sentry from '@sentry/browser'; import * as Sentry from '@sentry/browser';
import { TYPE_GROUP } from '~/graphql_shared/constants'; import { TYPE_GROUP } from '~/graphql_shared/constants';
import { convertToGraphQLId } from '~/graphql_shared/utils'; import { convertToGraphQLId, getIdFromGraphQLId } from '~/graphql_shared/utils';
import { import {
DEBOUNCE_DELAY, DEBOUNCE_DELAY,
I18N_GROUP_DROPDOWN_TEXT, I18N_GROUP_DROPDOWN_TEXT,
...@@ -19,6 +19,7 @@ import { ...@@ -19,6 +19,7 @@ import {
I18N_NO_SUB_GROUPS, I18N_NO_SUB_GROUPS,
} from '../constants'; } from '../constants';
import bulkEnableDevopsAdoptionNamespacesMutation from '../graphql/mutations/bulk_enable_devops_adoption_namespaces.mutation.graphql'; import bulkEnableDevopsAdoptionNamespacesMutation from '../graphql/mutations/bulk_enable_devops_adoption_namespaces.mutation.graphql';
import disableDevopsAdoptionNamespaceMutation from '../graphql/mutations/disable_devops_adoption_namespace.mutation.graphql';
export default { export default {
name: 'DevopsAdoptionAddDropdown', name: 'DevopsAdoptionAddDropdown',
...@@ -63,6 +64,11 @@ export default { ...@@ -63,6 +64,11 @@ export default {
required: false, required: false,
default: false, default: false,
}, },
enabledNamespaces: {
type: Object,
required: false,
default: () => ({ nodes: [] }),
},
}, },
computed: { computed: {
filteredGroupsLength() { filteredGroupsLength() {
...@@ -77,12 +83,31 @@ export default { ...@@ -77,12 +83,31 @@ export default {
tooltipText() { tooltipText() {
return this.isLoadingGroups || this.hasSubgroups ? false : I18N_NO_SUB_GROUPS; return this.isLoadingGroups || this.hasSubgroups ? false : I18N_NO_SUB_GROUPS;
}, },
enabledNamespaceIds() {
return this.enabledNamespaces.nodes.map((enabledNamespace) =>
getIdFromGraphQLId(enabledNamespace.namespace.id),
);
},
}, },
beforeDestroy() { beforeDestroy() {
clearTimeout(this.timeout); clearTimeout(this.timeout);
this.timeout = null; this.timeout = null;
}, },
methods: { methods: {
namespaceIdByGroupId(groupId) {
return this.enabledNamespaces.nodes?.find(
(enabledNamespace) => getIdFromGraphQLId(enabledNamespace.namespace.id) === groupId,
).id;
},
handleGroupSelect(id) {
const groupEnabled = this.isGroupEnabled(id);
if (groupEnabled) {
this.disableGroup(id);
} else {
this.enableGroup(id);
}
},
enableGroup(id) { enableGroup(id) {
this.$apollo this.$apollo
.mutate({ .mutate({
...@@ -103,6 +128,28 @@ export default { ...@@ -103,6 +128,28 @@ export default {
Sentry.captureException(error); Sentry.captureException(error);
}); });
}, },
disableGroup(id) {
const gid = this.namespaceIdByGroupId(id);
this.$apollo
.mutate({
mutation: disableDevopsAdoptionNamespaceMutation,
variables: {
id: gid,
},
update: () => {
this.$emit('enabledNamespacesRemoved', gid);
},
})
.catch((error) => {
Sentry.captureException(error);
});
},
isGroupEnabled(groupId) {
return this.enabledNamespaceIds.some((namespaceId) => {
return namespaceId === groupId;
});
},
}, },
}; };
</script> </script>
...@@ -126,8 +173,10 @@ export default { ...@@ -126,8 +173,10 @@ export default {
<gl-dropdown-item <gl-dropdown-item
v-for="group in groups" v-for="group in groups"
:key="group.id" :key="group.id"
:is-check-item="true"
:is-checked="isGroupEnabled(group.id)"
data-testid="group-row" data-testid="group-row"
@click="enableGroup(group.id)" @click.native.capture.stop="handleGroupSelect(group.id)"
> >
{{ group.full_name }} {{ group.full_name }}
</gl-dropdown-item> </gl-dropdown-item>
......
...@@ -4,7 +4,6 @@ import * as Sentry from '@sentry/browser'; ...@@ -4,7 +4,6 @@ import * as Sentry from '@sentry/browser';
import dateformat from 'dateformat'; import dateformat from 'dateformat';
import DevopsScore from '~/analytics/devops_report/components/devops_score.vue'; import DevopsScore from '~/analytics/devops_report/components/devops_score.vue';
import API from '~/api'; import API from '~/api';
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import { mergeUrlParams, updateHistory, getParameterValues } from '~/lib/utils/url_utility'; import { mergeUrlParams, updateHistory, getParameterValues } from '~/lib/utils/url_utility';
import { import {
I18N_GROUPS_QUERY_ERROR, I18N_GROUPS_QUERY_ERROR,
...@@ -150,13 +149,6 @@ export default { ...@@ -150,13 +149,6 @@ export default {
enabledNamespaces() { enabledNamespaces() {
return this.devopsAdoptionEnabledNamespaces?.nodes || []; return this.devopsAdoptionEnabledNamespaces?.nodes || [];
}, },
disabledGroupNodes() {
const enabledNamespaceIds = this.enabledNamespaces.map((group) =>
getIdFromGraphQLId(group.namespace.id),
);
return this.availableGroups.filter((group) => !enabledNamespaceIds.includes(group.id));
},
}, },
created() { created() {
this.fetchGroups(); this.fetchGroups();
...@@ -328,7 +320,7 @@ export default { ...@@ -328,7 +320,7 @@ export default {
:cols="tab.cols" :cols="tab.cols"
:enabled-namespaces="devopsAdoptionEnabledNamespaces" :enabled-namespaces="devopsAdoptionEnabledNamespaces"
:search-term="searchTerm" :search-term="searchTerm"
:disabled-group-nodes="disabledGroupNodes" :groups="availableGroups"
:is-loading-groups="isLoadingGroups" :is-loading-groups="isLoadingGroups"
:has-subgroups="hasSubgroups" :has-subgroups="hasSubgroups"
@enabledNamespacesRemoved="deleteEnabledNamespacesFromCache" @enabledNamespacesRemoved="deleteEnabledNamespacesFromCache"
...@@ -350,11 +342,13 @@ export default { ...@@ -350,11 +342,13 @@ export default {
> >
<devops-adoption-add-dropdown <devops-adoption-add-dropdown
:search-term="searchTerm" :search-term="searchTerm"
:groups="disabledGroupNodes" :groups="availableGroups"
:enabled-namespaces="devopsAdoptionEnabledNamespaces"
:is-loading-groups="isLoadingGroups" :is-loading-groups="isLoadingGroups"
:has-subgroups="hasSubgroups" :has-subgroups="hasSubgroups"
@fetchGroups="fetchGroups" @fetchGroups="fetchGroups"
@enabledNamespacesAdded="addEnabledNamespacesToCache" @enabledNamespacesAdded="addEnabledNamespacesToCache"
@enabledNamespacesRemoved="deleteEnabledNamespacesFromCache"
/> />
</span> </span>
</template> </template>
......
...@@ -42,7 +42,7 @@ export default { ...@@ -42,7 +42,7 @@ export default {
required: false, required: false,
default: () => {}, default: () => {},
}, },
disabledGroupNodes: { groups: {
type: Array, type: Array,
required: true, required: true,
}, },
...@@ -75,11 +75,13 @@ export default { ...@@ -75,11 +75,13 @@ export default {
<devops-adoption-add-dropdown <devops-adoption-add-dropdown
class="gl-mb-3 gl-md-display-none" class="gl-mb-3 gl-md-display-none"
:search-term="searchTerm" :search-term="searchTerm"
:groups="disabledGroupNodes" :groups="groups"
:enabled-namespaces="enabledNamespaces"
:is-loading-groups="isLoadingGroups" :is-loading-groups="isLoadingGroups"
:has-subgroups="hasSubgroups" :has-subgroups="hasSubgroups"
@fetchGroups="$emit('fetchGroups', $event)" @fetchGroups="$emit('fetchGroups', $event)"
@enabledNamespacesAdded="$emit('enabledNamespacesAdded', $event)" @enabledNamespacesAdded="$emit('enabledNamespacesAdded', $event)"
@enabledNamespacesRemoved="$emit('enabledNamespacesRemoved', $event)"
@trackModalOpenState="$emit('trackModalOpenState', $event)" @trackModalOpenState="$emit('trackModalOpenState', $event)"
/> />
</div> </div>
......
...@@ -34,13 +34,13 @@ export const I18N_TABLE_REMOVE_BUTTON_DISABLED = s__( ...@@ -34,13 +34,13 @@ export const I18N_TABLE_REMOVE_BUTTON_DISABLED = s__(
'DevopsAdoption|You cannot remove the group you are currently in.', 'DevopsAdoption|You cannot remove the group you are currently in.',
); );
export const I18N_GROUP_DROPDOWN_TEXT = s__('DevopsAdoption|Add sub-group to table'); export const I18N_GROUP_DROPDOWN_TEXT = s__('DevopsAdoption|Add or remove subgroups');
export const I18N_GROUP_DROPDOWN_HEADER = s__('DevopsAdoption|Add sub-group'); export const I18N_GROUP_DROPDOWN_HEADER = s__('DevopsAdoption|Edit subgroups');
export const I18N_ADMIN_DROPDOWN_TEXT = s__('DevopsAdoption|Add group to table'); export const I18N_ADMIN_DROPDOWN_TEXT = s__('DevopsAdoption|Add or remove groups');
export const I18N_ADMIN_DROPDOWN_HEADER = s__('DevopsAdoption|Add group'); export const I18N_ADMIN_DROPDOWN_HEADER = s__('DevopsAdoption|Edit groups');
export const I18N_NO_RESULTS = s__('DevopsAdoption|No results…'); export const I18N_NO_RESULTS = s__('DevopsAdoption|No results…');
export const I18N_NO_SUB_GROUPS = s__('DevopsAdoption|This group has no sub-groups'); export const I18N_NO_SUB_GROUPS = s__('DevopsAdoption|This group has no subgroups');
export const I18N_FEATURES_ADOPTED_TEXT = s__( export const I18N_FEATURES_ADOPTED_TEXT = s__(
'DevopsAdoption|%{adoptedCount}/%{featuresCount} %{title} features adopted', 'DevopsAdoption|%{adoptedCount}/%{featuresCount} %{title} features adopted',
......
...@@ -4,7 +4,15 @@ import { createLocalVue } from '@vue/test-utils'; ...@@ -4,7 +4,15 @@ import { createLocalVue } from '@vue/test-utils';
import Vue from 'vue'; import Vue from 'vue';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import DevopsAdoptionAddDropdown from 'ee/analytics/devops_report/devops_adoption/components/devops_adoption_add_dropdown.vue'; import DevopsAdoptionAddDropdown from 'ee/analytics/devops_report/devops_adoption/components/devops_adoption_add_dropdown.vue';
import {
I18N_GROUP_DROPDOWN_TEXT,
I18N_GROUP_DROPDOWN_HEADER,
I18N_ADMIN_DROPDOWN_TEXT,
I18N_ADMIN_DROPDOWN_HEADER,
I18N_NO_SUB_GROUPS,
} from 'ee/analytics/devops_report/devops_adoption/constants';
import bulkEnableDevopsAdoptionNamespacesMutation from 'ee/analytics/devops_report/devops_adoption/graphql/mutations/bulk_enable_devops_adoption_namespaces.mutation.graphql'; import bulkEnableDevopsAdoptionNamespacesMutation from 'ee/analytics/devops_report/devops_adoption/graphql/mutations/bulk_enable_devops_adoption_namespaces.mutation.graphql';
import disableDevopsAdoptionNamespaceMutation from 'ee/analytics/devops_report/devops_adoption/graphql/mutations/disable_devops_adoption_namespace.mutation.graphql';
import createMockApollo from 'helpers/mock_apollo_helper'; import createMockApollo from 'helpers/mock_apollo_helper';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive'; import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
...@@ -18,7 +26,7 @@ import { ...@@ -18,7 +26,7 @@ import {
const localVue = createLocalVue(); const localVue = createLocalVue();
Vue.use(VueApollo); Vue.use(VueApollo);
const mutate = jest.fn().mockResolvedValue({ const mutateAdd = jest.fn().mockResolvedValue({
data: { data: {
bulkEnableDevopsAdoptionNamespaces: { bulkEnableDevopsAdoptionNamespaces: {
enabledNamespaces: [devopsAdoptionNamespaceData.nodes[0]], enabledNamespaces: [devopsAdoptionNamespaceData.nodes[0]],
...@@ -26,14 +34,28 @@ const mutate = jest.fn().mockResolvedValue({ ...@@ -26,14 +34,28 @@ const mutate = jest.fn().mockResolvedValue({
}, },
}, },
}); });
const mutateDisable = jest.fn().mockResolvedValue({
data: {
disableDevopsAdoptionNamespace: {
errors: [],
},
},
});
const mutateWithErrors = jest.fn().mockRejectedValue(genericDeleteErrorMessage); const mutateWithErrors = jest.fn().mockRejectedValue(genericDeleteErrorMessage);
describe('DevopsAdoptionAddDropdown', () => { describe('DevopsAdoptionAddDropdown', () => {
let wrapper; let wrapper;
const createComponent = ({ enableNamespaceSpy = mutate, provide = {}, props = {} } = {}) => { const createComponent = ({
enableNamespaceSpy = mutateAdd,
disableNamespaceSpy = mutateDisable,
provide = {},
props = {},
} = {}) => {
const mockApollo = createMockApollo([ const mockApollo = createMockApollo([
[bulkEnableDevopsAdoptionNamespacesMutation, enableNamespaceSpy], [bulkEnableDevopsAdoptionNamespacesMutation, enableNamespaceSpy],
[disableDevopsAdoptionNamespaceMutation, disableNamespaceSpy],
]); ]);
wrapper = shallowMountExtended(DevopsAdoptionAddDropdown, { wrapper = shallowMountExtended(DevopsAdoptionAddDropdown, {
...@@ -55,7 +77,7 @@ describe('DevopsAdoptionAddDropdown', () => { ...@@ -55,7 +77,7 @@ describe('DevopsAdoptionAddDropdown', () => {
const findDropdown = () => wrapper.findComponent(GlDropdown); const findDropdown = () => wrapper.findComponent(GlDropdown);
const clickFirstRow = () => wrapper.findByTestId('group-row').vm.$emit('click'); const clickFirstRow = () => wrapper.findByTestId('group-row').trigger('click');
describe('default behaviour', () => { describe('default behaviour', () => {
beforeEach(() => { beforeEach(() => {
...@@ -69,8 +91,8 @@ describe('DevopsAdoptionAddDropdown', () => { ...@@ -69,8 +91,8 @@ describe('DevopsAdoptionAddDropdown', () => {
it('displays the correct text', () => { it('displays the correct text', () => {
const dropdown = findDropdown(); const dropdown = findDropdown();
expect(dropdown.props('text')).toBe('Add group to table'); expect(dropdown.props('text')).toBe(I18N_ADMIN_DROPDOWN_TEXT);
expect(dropdown.props('headerText')).toBe('Add group'); expect(dropdown.props('headerText')).toBe(I18N_ADMIN_DROPDOWN_HEADER);
}); });
it('is disabled', () => { it('is disabled', () => {
...@@ -81,7 +103,7 @@ describe('DevopsAdoptionAddDropdown', () => { ...@@ -81,7 +103,7 @@ describe('DevopsAdoptionAddDropdown', () => {
const tooltip = getBinding(findDropdown().element, 'gl-tooltip'); const tooltip = getBinding(findDropdown().element, 'gl-tooltip');
expect(tooltip).toBeDefined(); expect(tooltip).toBeDefined();
expect(tooltip.value).toBe('This group has no sub-groups'); expect(tooltip.value).toBe(I18N_NO_SUB_GROUPS);
}); });
}); });
...@@ -91,8 +113,8 @@ describe('DevopsAdoptionAddDropdown', () => { ...@@ -91,8 +113,8 @@ describe('DevopsAdoptionAddDropdown', () => {
const dropdown = findDropdown(); const dropdown = findDropdown();
expect(dropdown.props('text')).toBe('Add sub-group to table'); expect(dropdown.props('text')).toBe(I18N_GROUP_DROPDOWN_TEXT);
expect(dropdown.props('headerText')).toBe('Add sub-group'); expect(dropdown.props('headerText')).toBe(I18N_GROUP_DROPDOWN_HEADER);
}); });
}); });
...@@ -129,21 +151,24 @@ describe('DevopsAdoptionAddDropdown', () => { ...@@ -129,21 +151,24 @@ describe('DevopsAdoptionAddDropdown', () => {
describe('on row click', () => { describe('on row click', () => {
describe.each` describe.each`
level | groupGid level | groupGid | enabledNamespaces
${'group'} | ${groupGids[0]} ${'group'} | ${groupGids[0]} | ${undefined}
${'admin'} | ${null} ${'group'} | ${groupGids[0]} | ${devopsAdoptionNamespaceData}
`('$level level sucessful request', ({ groupGid }) => { ${'admin'} | ${null} | ${undefined}
${'admin'} | ${null} | ${devopsAdoptionNamespaceData}
`('$level level sucessful request', ({ groupGid, enabledNamespaces }) => {
beforeEach(() => { beforeEach(() => {
createComponent({ createComponent({
props: { hasSubgroups: true, groups: groupNodes }, props: { hasSubgroups: true, groups: groupNodes, enabledNamespaces },
provide: { groupGid }, provide: { groupGid },
}); });
clickFirstRow(); clickFirstRow();
}); });
if (!enabledNamespaces) {
it('makes a request to enable the selected group', () => { it('makes a request to enable the selected group', () => {
expect(mutate).toHaveBeenCalledWith({ expect(mutateAdd).toHaveBeenCalledWith({
displayNamespaceId: groupGid, displayNamespaceId: groupGid,
namespaceIds: ['gid://gitlab/Group/1'], namespaceIds: ['gid://gitlab/Group/1'],
}); });
...@@ -154,6 +179,19 @@ describe('DevopsAdoptionAddDropdown', () => { ...@@ -154,6 +179,19 @@ describe('DevopsAdoptionAddDropdown', () => {
expect(params).toStrictEqual([devopsAdoptionNamespaceData.nodes[0]]); expect(params).toStrictEqual([devopsAdoptionNamespaceData.nodes[0]]);
}); });
} else {
it('makes a request to disable the selected group', () => {
expect(mutateDisable).toHaveBeenCalledWith({
id: devopsAdoptionNamespaceData.nodes[0].id,
});
});
it('emits the enabledNamespacesRemoved event', () => {
const [params] = wrapper.emitted().enabledNamespacesRemoved[0];
expect(params).toBe(devopsAdoptionNamespaceData.nodes[0].id);
});
}
}); });
describe('on error', () => { describe('on error', () => {
......
...@@ -22,7 +22,7 @@ describe('DevopsAdoptionSection', () => { ...@@ -22,7 +22,7 @@ describe('DevopsAdoptionSection', () => {
hasGroupData: true, hasGroupData: true,
cols: DEVOPS_ADOPTION_TABLE_CONFIGURATION[0].cols, cols: DEVOPS_ADOPTION_TABLE_CONFIGURATION[0].cols,
enabledNamespaces: devopsAdoptionNamespaceData, enabledNamespaces: devopsAdoptionNamespaceData,
disabledGroupNodes: groupNodes, groups: groupNodes,
searchTerm: '', searchTerm: '',
isLoadingGroups: false, isLoadingGroups: false,
hasSubgroups: true, hasSubgroups: true,
......
export const groupData = [ export const groupData = [
{ id: '1', full_name: 'Foo' }, { id: 1, full_name: 'Foo' },
{ id: '2', full_name: 'Bar' }, { id: 2, full_name: 'Bar' },
]; ];
export const groupNodes = [ export const groupNodes = [
{ {
__typename: 'Group', __typename: 'Group',
full_name: 'Foo', full_name: 'Foo',
id: '1', id: 1,
}, },
{ {
__typename: 'Group', __typename: 'Group',
full_name: 'Bar', full_name: 'Bar',
id: '2', id: 2,
}, },
]; ];
export const groupNodeLabelValues = [ export const groupNodeLabelValues = [
{ label: 'Foo', value: '1' }, { label: 'Foo', value: 1 },
{ label: 'Bar', value: '2' }, { label: 'Bar', value: 2 },
]; ];
export const groupIds = [1, 2]; export const groupIds = [1, 2];
...@@ -28,7 +28,7 @@ export const groupGids = ['gid://gitlab/Group/1', 'gid://gitlab/Group/2']; ...@@ -28,7 +28,7 @@ export const groupGids = ['gid://gitlab/Group/1', 'gid://gitlab/Group/2'];
export const devopsAdoptionNamespaceData = { export const devopsAdoptionNamespaceData = {
nodes: [ nodes: [
{ {
id: 1, id: 'gid://gitlab/EnabledNamespace/1',
namespace: { namespace: {
fullName: 'Group 1', fullName: 'Group 1',
id: 'gid://gitlab/Group/1', id: 'gid://gitlab/Group/1',
...@@ -51,7 +51,7 @@ export const devopsAdoptionNamespaceData = { ...@@ -51,7 +51,7 @@ export const devopsAdoptionNamespaceData = {
__typename: 'devopsAdoptionEnabledNamespace', __typename: 'devopsAdoptionEnabledNamespace',
}, },
{ {
id: 2, id: 'gid://gitlab/EnabledNamespace/2',
namespace: { namespace: {
fullName: 'Group 2', fullName: 'Group 2',
id: 'gid://gitlab/Group/2', id: 'gid://gitlab/Group/2',
......
...@@ -11334,16 +11334,10 @@ msgstr "" ...@@ -11334,16 +11334,10 @@ msgstr ""
msgid "DevopsAdoption|Add a group to get started" msgid "DevopsAdoption|Add a group to get started"
msgstr "" msgstr ""
msgid "DevopsAdoption|Add group" msgid "DevopsAdoption|Add or remove groups"
msgstr "" msgstr ""
msgid "DevopsAdoption|Add group to table" msgid "DevopsAdoption|Add or remove subgroups"
msgstr ""
msgid "DevopsAdoption|Add sub-group"
msgstr ""
msgid "DevopsAdoption|Add sub-group to table"
msgstr "" msgstr ""
msgid "DevopsAdoption|Adopted" msgid "DevopsAdoption|Adopted"
...@@ -11403,6 +11397,12 @@ msgstr "" ...@@ -11403,6 +11397,12 @@ msgstr ""
msgid "DevopsAdoption|DevOps adoption tracks the use of key features across your favorite groups. Add a group to the table to begin." msgid "DevopsAdoption|DevOps adoption tracks the use of key features across your favorite groups. Add a group to the table to begin."
msgstr "" msgstr ""
msgid "DevopsAdoption|Edit groups"
msgstr ""
msgid "DevopsAdoption|Edit subgroups"
msgstr ""
msgid "DevopsAdoption|Feature adoption is based on usage in the previous calendar month. Last updated: %{timestamp}." msgid "DevopsAdoption|Feature adoption is based on usage in the previous calendar month. Last updated: %{timestamp}."
msgstr "" msgstr ""
...@@ -11463,7 +11463,7 @@ msgstr "" ...@@ -11463,7 +11463,7 @@ msgstr ""
msgid "DevopsAdoption|There was an error fetching Groups. Please refresh the page." msgid "DevopsAdoption|There was an error fetching Groups. Please refresh the page."
msgstr "" msgstr ""
msgid "DevopsAdoption|This group has no sub-groups" msgid "DevopsAdoption|This group has no subgroups"
msgstr "" msgstr ""
msgid "DevopsAdoption|You cannot remove the group you are currently in." msgid "DevopsAdoption|You cannot remove the group you are currently in."
......
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