Commit 0b27fd04 authored by Paul Slaughter's avatar Paul Slaughter

Merge branch '334485-vsa-fe-update-item-count-to-1000' into 'master'

[VSA][FE] Change item count to 1000+

See merge request gitlab-org/gitlab!64789
parents b57261d1 4af12b45
<script>
import { s__, n__, sprintf } from '~/locale';
export default {
props: {
stageCount: {
type: Number,
required: false,
default: null,
},
},
computed: {
formattedStageCount() {
if (!this.stageCount) {
return '-';
} else if (this.stageCount > 1000) {
return sprintf(s__('ValueStreamAnalytics|%{stageCount} items'), { stageCount: '1000+' });
}
return n__('%d item', '%d items', this.stageCount);
},
},
};
</script>
<template>
<span>{{ formattedStageCount }}</span>
</template>
...@@ -7,6 +7,7 @@ import { ...@@ -7,6 +7,7 @@ import {
} from '@gitlab/ui'; } from '@gitlab/ui';
import Tracking from '~/tracking'; import Tracking from '~/tracking';
import { OVERVIEW_STAGE_ID } from '../constants'; import { OVERVIEW_STAGE_ID } from '../constants';
import FormattedStageCount from './formatted_stage_count.vue';
export default { export default {
name: 'PathNavigation', name: 'PathNavigation',
...@@ -14,6 +15,7 @@ export default { ...@@ -14,6 +15,7 @@ export default {
GlPath, GlPath,
GlSkeletonLoading, GlSkeletonLoading,
GlPopover, GlPopover,
FormattedStageCount,
}, },
directives: { directives: {
SafeHtml, SafeHtml,
...@@ -88,10 +90,7 @@ export default { ...@@ -88,10 +90,7 @@ export default {
{{ s__('ValueStreamEvent|Items in stage') }} {{ s__('ValueStreamEvent|Items in stage') }}
</div> </div>
<div class="gl-pb-4 gl-font-weight-bold"> <div class="gl-pb-4 gl-font-weight-bold">
<template v-if="hasStageCount(pathItem)">{{ <formatted-stage-count :stage-count="pathItem.stageCount" />
n__('%d item', '%d items', pathItem.stageCount)
}}</template>
<template v-else>-</template>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -8,6 +8,7 @@ import { ...@@ -8,6 +8,7 @@ import {
GlTable, GlTable,
GlBadge, GlBadge,
} from '@gitlab/ui'; } from '@gitlab/ui';
import FormattedStageCount from '~/cycle_analytics/components/formatted_stage_count.vue';
import { __ } from '~/locale'; import { __ } from '~/locale';
import Tracking from '~/tracking'; import Tracking from '~/tracking';
import { import {
...@@ -42,6 +43,7 @@ export default { ...@@ -42,6 +43,7 @@ export default {
GlTable, GlTable,
GlBadge, GlBadge,
TotalTime, TotalTime,
FormattedStageCount,
}, },
mixins: [Tracking.mixin()], mixins: [Tracking.mixin()],
props: { props: {
...@@ -175,7 +177,9 @@ export default { ...@@ -175,7 +177,9 @@ export default {
> >
<template #head(end_event)="data"> <template #head(end_event)="data">
<span>{{ data.label }}</span <span>{{ data.label }}</span
><gl-badge v-if="stageCount" class="gl-ml-2" size="sm">{{ stageCount }}</gl-badge> ><gl-badge class="gl-ml-2" size="sm">
<formatted-stage-count :stage-count="stageCount" />
</gl-badge>
</template> </template>
<template #cell(end_event)="{ item }"> <template #cell(end_event)="{ item }">
<div data-testid="vsa-stage-event"> <div data-testid="vsa-stage-event">
......
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import FormattedStageCount from '~/cycle_analytics/components/formatted_stage_count.vue';
import Component from '~/cycle_analytics/components/path_navigation.vue'; import Component from '~/cycle_analytics/components/path_navigation.vue';
import { OVERVIEW_STAGE_ID } from '~/cycle_analytics/constants'; import { OVERVIEW_STAGE_ID } from '~/cycle_analytics/constants';
import { transformedStagePathData, issueStage } from '../mock_data'; import { transformedStagePathData, issueStage } from '../mock_data';
...@@ -26,6 +27,7 @@ describe('Group PathNavigation', () => { ...@@ -26,6 +27,7 @@ describe('Group PathNavigation', () => {
const pathItemContent = () => pathNavigationItems().wrappers.map(extendedWrapper); const pathItemContent = () => pathNavigationItems().wrappers.map(extendedWrapper);
const firstPopover = () => wrapper.findAllByTestId('stage-item-popover').at(0); const firstPopover = () => wrapper.findAllByTestId('stage-item-popover').at(0);
const findStageCountAtIndex = (index) => wrapper.findAllComponents(FormattedStageCount).at(index);
const stagesWithCounts = transformedStagePathData.filter( const stagesWithCounts = transformedStagePathData.filter(
(stage) => stage.id !== OVERVIEW_STAGE_ID, (stage) => stage.id !== OVERVIEW_STAGE_ID,
...@@ -76,7 +78,9 @@ describe('Group PathNavigation', () => { ...@@ -76,7 +78,9 @@ describe('Group PathNavigation', () => {
popoverStages.forEach((stage, index) => { popoverStages.forEach((stage, index) => {
const content = stage.findByTestId('stage-item-popover').html(); const content = stage.findByTestId('stage-item-popover').html();
expect(content).toContain('Items in stage'); expect(content).toContain('Items in stage');
expect(content).toContain(`${stagesWithCounts[index].stageCount} items`); expect(findStageCountAtIndex(index).props('stageCount')).toBe(
stagesWithCounts[index].stageCount,
);
}); });
}); });
}); });
......
...@@ -35661,6 +35661,9 @@ msgstr "" ...@@ -35661,6 +35661,9 @@ msgstr ""
msgid "ValueStreamAnalyticsStage|We don't have enough data to show this stage." msgid "ValueStreamAnalyticsStage|We don't have enough data to show this stage."
msgstr "" msgstr ""
msgid "ValueStreamAnalytics|%{stageCount} items"
msgstr ""
msgid "ValueStreamAnalytics|%{value}M" msgid "ValueStreamAnalytics|%{value}M"
msgstr "" msgstr ""
......
import { shallowMount } from '@vue/test-utils';
import Component from '~/cycle_analytics/components/formatted_stage_count.vue';
describe('Formatted Stage Count', () => {
let wrapper = null;
const createComponent = (stageCount = null) => {
wrapper = shallowMount(Component, {
propsData: {
stageCount,
},
});
};
beforeEach(() => {
createComponent();
});
afterEach(() => {
wrapper.destroy();
});
it.each`
stageCount | expectedOutput
${null} | ${'-'}
${1} | ${'1 item'}
${10} | ${'10 items'}
${1000} | ${'1000 items'}
${1001} | ${'1000+ items'}
`('returns "$expectedOutput" for stageCount=$stageCount', ({ stageCount, expectedOutput }) => {
createComponent(stageCount);
expect(wrapper.text()).toContain(expectedOutput);
});
});
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