Commit fc0524ab authored by Martin Wortschack's avatar Martin Wortschack

Merge branch '329445-devops-adoption-should-not-only-fetch-the-first-200-groups' into 'master'

DevOps Adoption - remove max requests fetching group data

See merge request gitlab-org/gitlab!63491
parents 5593ee00 5acc1409
...@@ -8,8 +8,6 @@ import { mergeUrlParams, updateHistory, getParameterValues } from '~/lib/utils/u ...@@ -8,8 +8,6 @@ import { mergeUrlParams, updateHistory, getParameterValues } from '~/lib/utils/u
import { import {
DEVOPS_ADOPTION_STRINGS, DEVOPS_ADOPTION_STRINGS,
DEVOPS_ADOPTION_ERROR_KEYS, DEVOPS_ADOPTION_ERROR_KEYS,
MAX_REQUEST_COUNT,
MAX_SEGMENTS,
DATE_TIME_FORMAT, DATE_TIME_FORMAT,
DEFAULT_POLLING_INTERVAL, DEFAULT_POLLING_INTERVAL,
DEVOPS_ADOPTION_GROUP_LEVEL_LABEL, DEVOPS_ADOPTION_GROUP_LEVEL_LABEL,
...@@ -58,13 +56,11 @@ export default { ...@@ -58,13 +56,11 @@ export default {
}, },
trackDevopsTabClickEvent: TRACK_ADOPTION_TAB_CLICK_EVENT, trackDevopsTabClickEvent: TRACK_ADOPTION_TAB_CLICK_EVENT,
trackDevopsScoreTabClickEvent: TRACK_DEVOPS_SCORE_TAB_CLICK_EVENT, trackDevopsScoreTabClickEvent: TRACK_DEVOPS_SCORE_TAB_CLICK_EVENT,
maxSegments: MAX_SEGMENTS,
devopsAdoptionTableConfiguration: DEVOPS_ADOPTION_TABLE_CONFIGURATION, devopsAdoptionTableConfiguration: DEVOPS_ADOPTION_TABLE_CONFIGURATION,
data() { data() {
return { return {
isLoadingGroups: false, isLoadingGroups: false,
isLoadingEnableGroup: false, isLoadingEnableGroup: false,
requestCount: 0,
openModal: false, openModal: false,
errors: { errors: {
[DEVOPS_ADOPTION_ERROR_KEYS.groups]: false, [DEVOPS_ADOPTION_ERROR_KEYS.groups]: false,
...@@ -140,9 +136,6 @@ export default { ...@@ -140,9 +136,6 @@ export default {
this.isLoadingEnableGroup || this.$apollo.queries.devopsAdoptionEnabledNamespaces.loading this.isLoadingEnableGroup || this.$apollo.queries.devopsAdoptionEnabledNamespaces.loading
); );
}, },
segmentLimitReached() {
return this.devopsAdoptionEnabledNamespaces?.nodes?.length > this.$options.maxSegments;
},
editGroupsButtonLabel() { editGroupsButtonLabel() {
return this.isGroup return this.isGroup
? this.$options.i18n.groupLevelLabel ? this.$options.i18n.groupLevelLabel
...@@ -241,8 +234,7 @@ export default { ...@@ -241,8 +234,7 @@ export default {
nodes: [...this.groups.nodes, ...nodes], nodes: [...this.groups.nodes, ...nodes],
}; };
this.requestCount += 1; if (pageInfo?.nextPage) {
if (this.requestCount < MAX_REQUEST_COUNT && pageInfo?.nextPage) {
this.fetchGroups(pageInfo.nextPage); this.fetchGroups(pageInfo.nextPage);
} else { } else {
this.isLoadingGroups = false; this.isLoadingGroups = false;
...@@ -322,7 +314,6 @@ export default { ...@@ -322,7 +314,6 @@ export default {
:has-segments-data="hasSegmentsData" :has-segments-data="hasSegmentsData"
:timestamp="timestamp" :timestamp="timestamp"
:has-group-data="hasGroupData" :has-group-data="hasGroupData"
:segment-limit-reached="segmentLimitReached"
:edit-groups-button-label="editGroupsButtonLabel" :edit-groups-button-label="editGroupsButtonLabel"
:cols="tab.cols" :cols="tab.cols"
:segments="devopsAdoptionEnabledNamespaces" :segments="devopsAdoptionEnabledNamespaces"
......
<script> <script>
import { GlLoadingIcon, GlTooltipDirective, GlButton, GlSprintf } from '@gitlab/ui'; import { GlLoadingIcon, GlButton, GlSprintf } from '@gitlab/ui';
import { TABLE_HEADER_TEXT, ADD_REMOVE_BUTTON_TOOLTIP } from '../constants'; import { TABLE_HEADER_TEXT } from '../constants';
import DevopsAdoptionEmptyState from './devops_adoption_empty_state.vue'; import DevopsAdoptionEmptyState from './devops_adoption_empty_state.vue';
import DevopsAdoptionTable from './devops_adoption_table.vue'; import DevopsAdoptionTable from './devops_adoption_table.vue';
...@@ -15,9 +15,6 @@ export default { ...@@ -15,9 +15,6 @@ export default {
i18n: { i18n: {
tableHeaderText: TABLE_HEADER_TEXT, tableHeaderText: TABLE_HEADER_TEXT,
}, },
directives: {
GlTooltip: GlTooltipDirective,
},
props: { props: {
isLoading: { isLoading: {
type: Boolean, type: Boolean,
...@@ -35,10 +32,6 @@ export default { ...@@ -35,10 +32,6 @@ export default {
type: Boolean, type: Boolean,
required: true, required: true,
}, },
segmentLimitReached: {
type: Boolean,
required: true,
},
editGroupsButtonLabel: { editGroupsButtonLabel: {
type: String, type: String,
required: true, required: true,
...@@ -53,11 +46,6 @@ export default { ...@@ -53,11 +46,6 @@ export default {
default: () => {}, default: () => {},
}, },
}, },
computed: {
addSegmentButtonTooltipText() {
return this.segmentLimitReached ? ADD_REMOVE_BUTTON_TOOLTIP : false;
},
},
}; };
</script> </script>
<template> <template>
...@@ -72,15 +60,10 @@ export default { ...@@ -72,15 +60,10 @@ export default {
<template #timestamp>{{ timestamp }}</template> <template #timestamp>{{ timestamp }}</template>
</gl-sprintf> </gl-sprintf>
</span> </span>
<span
v-if="hasGroupData" <gl-button v-if="hasGroupData" @click="$emit('openAddRemoveModal')">{{
v-gl-tooltip.hover="addSegmentButtonTooltipText" editGroupsButtonLabel
data-testid="segmentButtonWrapper" }}</gl-button>
>
<gl-button :disabled="segmentLimitReached" @click="$emit('openAddRemoveModal')">{{
editGroupsButtonLabel
}}</gl-button></span
>
</div> </div>
<devops-adoption-table <devops-adoption-table
:cols="cols" :cols="cols"
......
import { s__, __, sprintf } from '~/locale'; import { s__, __ } from '~/locale';
export const DEFAULT_POLLING_INTERVAL = 30000; export const DEFAULT_POLLING_INTERVAL = 30000;
export const MAX_SEGMENTS = 30;
export const MAX_REQUEST_COUNT = 10;
export const PER_PAGE = 100; export const PER_PAGE = 100;
export const DEVOPS_ADOPTION_SEGMENT_MODAL_ID = 'devopsSegmentModal'; export const DEVOPS_ADOPTION_SEGMENT_MODAL_ID = 'devopsSegmentModal';
...@@ -24,13 +20,6 @@ export const TABLE_HEADER_TEXT = s__( ...@@ -24,13 +20,6 @@ export const TABLE_HEADER_TEXT = s__(
'DevopsAdoption|Feature adoption is based on usage in the current calendar month. Last updated: %{timestamp}.', 'DevopsAdoption|Feature adoption is based on usage in the current calendar month. Last updated: %{timestamp}.',
); );
export const ADD_REMOVE_BUTTON_TOOLTIP = sprintf(
s__('DevopsAdoption|Maximum %{maxSegments} groups allowed'),
{
maxSegments: MAX_SEGMENTS,
},
);
export const DEVOPS_ADOPTION_GROUP_LEVEL_LABEL = s__('DevopsAdoption|Add/remove sub-groups'); export const DEVOPS_ADOPTION_GROUP_LEVEL_LABEL = s__('DevopsAdoption|Add/remove sub-groups');
export const DEVOPS_ADOPTION_TABLE_REMOVE_BUTTON_DISABLED = s__( export const DEVOPS_ADOPTION_TABLE_REMOVE_BUTTON_DISABLED = s__(
......
...@@ -193,20 +193,6 @@ describe('DevopsAdoptionApp', () => { ...@@ -193,20 +193,6 @@ describe('DevopsAdoptionApp', () => {
}); });
}); });
describe('when fetching too many pages of data', () => {
beforeEach(async () => {
// Always send the same page
groupsSpy = jest.fn().mockResolvedValue(initialResponse);
const mockApollo = createMockApolloProvider({ groupsSpy });
wrapper = createComponent({ mockApollo, data: { requestCount: 2 } });
await waitForPromises();
});
it('should fetch data twice', () => {
expect(groupsSpy).toHaveBeenCalledTimes(2);
});
});
describe('when error is thrown in the fetchMore request', () => { describe('when error is thrown in the fetchMore request', () => {
const error = 'Error: foo!'; const error = 'Error: foo!';
......
...@@ -5,7 +5,6 @@ import DevopsAdoptionEmptyState from 'ee/analytics/devops_report/devops_adoption ...@@ -5,7 +5,6 @@ import DevopsAdoptionEmptyState from 'ee/analytics/devops_report/devops_adoption
import DevopsAdoptionSection from 'ee/analytics/devops_report/devops_adoption/components/devops_adoption_section.vue'; import DevopsAdoptionSection from 'ee/analytics/devops_report/devops_adoption/components/devops_adoption_section.vue';
import DevopsAdoptionTable from 'ee/analytics/devops_report/devops_adoption/components/devops_adoption_table.vue'; import DevopsAdoptionTable from 'ee/analytics/devops_report/devops_adoption/components/devops_adoption_table.vue';
import { DEVOPS_ADOPTION_TABLE_CONFIGURATION } from 'ee/analytics/devops_report/devops_adoption/constants'; import { DEVOPS_ADOPTION_TABLE_CONFIGURATION } from 'ee/analytics/devops_report/devops_adoption/constants';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import { devopsAdoptionNamespaceData } from '../mock_data'; import { devopsAdoptionNamespaceData } from '../mock_data';
...@@ -20,16 +19,11 @@ describe('DevopsAdoptionSection', () => { ...@@ -20,16 +19,11 @@ describe('DevopsAdoptionSection', () => {
hasSegmentsData: true, hasSegmentsData: true,
timestamp: '2020-10-31 23:59', timestamp: '2020-10-31 23:59',
hasGroupData: true, hasGroupData: true,
segmentLimitReached: false,
editGroupsButtonLabel: 'Add/Remove groups', editGroupsButtonLabel: 'Add/Remove groups',
cols: DEVOPS_ADOPTION_TABLE_CONFIGURATION[0].cols, cols: DEVOPS_ADOPTION_TABLE_CONFIGURATION[0].cols,
segments: devopsAdoptionNamespaceData, segments: devopsAdoptionNamespaceData,
addSegmentButtonTooltipText: 'Maximum 30 groups allowed',
...props, ...props,
}, },
directives: {
GlTooltip: createMockDirective(),
},
stubs: { stubs: {
GlSprintf, GlSprintf,
}, },
...@@ -42,7 +36,6 @@ describe('DevopsAdoptionSection', () => { ...@@ -42,7 +36,6 @@ describe('DevopsAdoptionSection', () => {
const findTable = () => wrapper.findComponent(DevopsAdoptionTable); const findTable = () => wrapper.findComponent(DevopsAdoptionTable);
const findEmptyState = () => wrapper.findComponent(DevopsAdoptionEmptyState); const findEmptyState = () => wrapper.findComponent(DevopsAdoptionEmptyState);
const findAddEditButton = () => wrapper.findComponent(GlButton); const findAddEditButton = () => wrapper.findComponent(GlButton);
const findAddRemoveButtonWrapper = () => wrapper.findByTestId('segmentButtonWrapper');
describe('while loading', () => { describe('while loading', () => {
beforeEach(() => { beforeEach(() => {
...@@ -111,45 +104,20 @@ describe('DevopsAdoptionSection', () => { ...@@ -111,45 +104,20 @@ describe('DevopsAdoptionSection', () => {
}); });
describe('edit groups button', () => { describe('edit groups button', () => {
describe('segment limit reached', () => { beforeEach(() => {
beforeEach(() => { createComponent();
createComponent({ segmentLimitReached: true });
});
it('is disabled', () => {
expect(findAddEditButton().props('disabled')).toBe(true);
});
it('displays a tooltip', () => {
const tooltip = getBinding(findAddRemoveButtonWrapper().element, 'gl-tooltip');
expect(tooltip).toBeDefined();
expect(tooltip.value).toBe('Maximum 30 groups allowed');
});
}); });
describe('segment limit not reached', () => { it('is enabled', () => {
beforeEach(() => { expect(findAddEditButton().props('disabled')).toBe(false);
createComponent(); });
});
it('is enabled', () => {
expect(findAddEditButton().props('disabled')).toBe(false);
});
it('does not display a tooltip', () => {
const tooltip = getBinding(findAddRemoveButtonWrapper().element, 'gl-tooltip');
expect(tooltip.value).toBe(false);
});
it('emits openAddRemoveModal when clicked', () => { it('emits openAddRemoveModal when clicked', () => {
expect(wrapper.emitted('openAddRemoveModal')).toBeUndefined(); expect(wrapper.emitted('openAddRemoveModal')).toBeUndefined();
findAddEditButton().vm.$emit('click'); findAddEditButton().vm.$emit('click');
expect(wrapper.emitted('openAddRemoveModal')).toEqual([[]]); expect(wrapper.emitted('openAddRemoveModal')).toEqual([[]]);
});
}); });
}); });
}); });
......
...@@ -11339,9 +11339,6 @@ msgstr "" ...@@ -11339,9 +11339,6 @@ msgstr ""
msgid "DevopsAdoption|MRs" msgid "DevopsAdoption|MRs"
msgstr "" msgstr ""
msgid "DevopsAdoption|Maximum %{maxSegments} groups allowed"
msgstr ""
msgid "DevopsAdoption|My group" msgid "DevopsAdoption|My group"
msgstr "" msgstr ""
......
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