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