Commit ba6a0972 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Address minor review comments

Minor refactor metrics constants and update
some externalized strings
parent 6bfdb481
......@@ -6,7 +6,7 @@ import PathNavigation from '~/cycle_analytics/components/path_navigation.vue';
import StageTable from '~/cycle_analytics/components/stage_table.vue';
import ValueStreamMetrics from '~/cycle_analytics/components/value_stream_metrics.vue';
import { __ } from '~/locale';
import { projectMetricsRequests } from '../constants';
import { SUMMARY_METRICS_REQUEST, METRICS_REQUESTS } from '../constants';
const OVERVIEW_DIALOG_COOKIE = 'cycle_analytics_help_dismissed';
......@@ -94,7 +94,7 @@ export default {
return 0;
},
metricsRequests() {
return projectMetricsRequests(this.features.cycleAnalyticsForGroups);
return this.features?.cycleAnalyticsForGroups ? METRICS_REQUESTS : SUMMARY_METRICS_REQUEST;
},
},
methods: {
......
......@@ -11,12 +11,13 @@ const requestData = ({ request, path, params, name }) => {
return request(path, params)
.then(({ data }) => data)
.catch(() => {
createFlash({
message: sprintf(
s__('There was an error while fetching value stream analytics %{requestTypeName} data.'),
{ requestTypeName: name },
const message = sprintf(
s__(
'ValueStreamAnalytics|There was an error while fetching value stream analytics %{requestTypeName} data.',
),
});
{ requestTypeName: name },
);
createFlash({ message });
});
};
......
......@@ -60,12 +60,11 @@ export const METRICS_POPOVER_CONTENT = {
},
};
export const projectMetricsRequests = (cycleAnalyticsForGroups = false) => {
const summaryMetrics = [{ request: getValueStreamSummaryMetrics, name: __('recent activity') }];
if (cycleAnalyticsForGroups) {
return [{ request: getValueStreamTimeSummaryMetrics, name: __('time summary') }].concat(
summaryMetrics,
);
}
return summaryMetrics;
};
export const SUMMARY_METRICS_REQUEST = [
{ request: getValueStreamSummaryMetrics, name: __('recent activity') },
];
export const METRICS_REQUESTS = [
{ request: getValueStreamTimeSummaryMetrics, name: __('time summary') },
...SUMMARY_METRICS_REQUEST,
];
......@@ -33714,9 +33714,6 @@ msgstr ""
msgid "There was an error while fetching the table data. Please refresh the page to try again."
msgstr ""
msgid "There was an error while fetching value stream analytics %{requestTypeName} data."
msgstr ""
msgid "There was an error while fetching value stream analytics data."
msgstr ""
......@@ -36555,6 +36552,9 @@ msgstr ""
msgid "ValueStreamAnalytics|Number of new issues created."
msgstr ""
msgid "ValueStreamAnalytics|There was an error while fetching value stream analytics %{requestTypeName} data."
msgstr ""
msgid "ValueStreamAnalytics|Total number of deploys to production."
msgstr ""
......
......@@ -32,7 +32,7 @@ describe('ValueStreamMetrics', () => {
wrapper = null;
});
it('will display a loading icon if `true`', async () => {
it('will display a loader with pending requests', async () => {
mockGetValueStreamSummaryMetrics = jest.fn().mockResolvedValue({ data: metricsData });
wrapper = createComponent();
await wrapper.vm.$nextTick();
......@@ -105,7 +105,7 @@ describe('ValueStreamMetrics', () => {
await waitForPromises();
});
it('it should render a error message', () => {
it('it should render an error message', () => {
expect(createFlash).toHaveBeenCalledWith({
message: `There was an error while fetching value stream analytics ${fakeReqName} data.`,
});
......
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