Commit c1c11f50 authored by Simon Knox's avatar Simon Knox

Merge branch 'jivanvl-fix-reverse-chart-pipeline-minutes' into 'master'

Sort months of the CI minutes chart app

See merge request gitlab-org/gitlab!74917
parents 28b56e80 55da27be
<script> <script>
import { MONTHS } from '../constants';
import getCiMinutesUsage from '../graphql/queries/ci_minutes.graphql'; import getCiMinutesUsage from '../graphql/queries/ci_minutes.graphql';
import MinutesUsageMonthChart from './minutes_usage_month_chart.vue'; import MinutesUsageMonthChart from './minutes_usage_month_chart.vue';
import MinutesUsageProjectChart from './minutes_usage_project_chart.vue'; import MinutesUsageProjectChart from './minutes_usage_project_chart.vue';
...@@ -23,7 +24,21 @@ export default { ...@@ -23,7 +24,21 @@ export default {
}, },
computed: { computed: {
minutesUsageDataByMonth() { minutesUsageDataByMonth() {
return this.ciMinutesUsage.map((cur) => [cur.month, cur.minutes]); function monthIndex([name]) {
return Object.keys(MONTHS).indexOf(name.toLowerCase());
}
return this.ciMinutesUsage
.map((cur) => [cur.month, cur.minutes])
.sort((a, b) => {
if (monthIndex(a) > monthIndex(b)) {
return 1;
}
if (monthIndex(a) < monthIndex(b)) {
return -1;
}
return 0;
});
}, },
}, },
}; };
......
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
import { GlAlert, GlDropdown, GlDropdownItem } from '@gitlab/ui'; import { GlAlert, GlDropdown, GlDropdownItem } from '@gitlab/ui';
import { GlColumnChart } from '@gitlab/ui/dist/charts'; import { GlColumnChart } from '@gitlab/ui/dist/charts';
import { keyBy } from 'lodash'; import { keyBy } from 'lodash';
import { __ } from '~/locale';
import { import {
USAGE_BY_PROJECT, USAGE_BY_PROJECT,
X_AXIS_PROJECT_LABEL, X_AXIS_PROJECT_LABEL,
X_AXIS_CATEGORY, X_AXIS_CATEGORY,
Y_AXIS_LABEL, Y_AXIS_LABEL,
NO_CI_MINUTES_MSG, NO_CI_MINUTES_MSG,
MONTHS,
} from '../constants'; } from '../constants';
export default { export default {
...@@ -17,20 +17,6 @@ export default { ...@@ -17,20 +17,6 @@ export default {
X_AXIS_CATEGORY, X_AXIS_CATEGORY,
Y_AXIS_LABEL, Y_AXIS_LABEL,
NO_CI_MINUTES_MSG, NO_CI_MINUTES_MSG,
i18n: {
january: __('January'),
february: __('February'),
march: __('March'),
april: __('April'),
may: __('May'),
june: __('June'),
july: __('July'),
august: __('August'),
september: __('September'),
october: __('October'),
november: __('November'),
december: __('December'),
},
components: { components: {
GlAlert, GlAlert,
GlColumnChart, GlColumnChart,
...@@ -90,7 +76,7 @@ export default { ...@@ -90,7 +76,7 @@ export default {
[this.selectedMonth] = this.months; [this.selectedMonth] = this.months;
}, },
getTranslatedMonthName(month) { getTranslatedMonthName(month) {
return this.$options.i18n[month.toLowerCase()] ?? month; return MONTHS[month.toLowerCase()] ?? month;
}, },
}, },
}; };
......
...@@ -9,3 +9,18 @@ export const Y_AXIS_LABEL = __('Minutes'); ...@@ -9,3 +9,18 @@ export const Y_AXIS_LABEL = __('Minutes');
export const NO_CI_MINUTES_MSG = s__('UsageQuota|No CI minutes usage data available.'); export const NO_CI_MINUTES_MSG = s__('UsageQuota|No CI minutes usage data available.');
export const X_AXIS_CATEGORY = 'category'; export const X_AXIS_CATEGORY = 'category';
export const MONTHS = {
january: __('January'),
february: __('February'),
march: __('March'),
april: __('April'),
may: __('May'),
june: __('June'),
july: __('July'),
august: __('August'),
september: __('September'),
october: __('October'),
november: __('November'),
december: __('December'),
};
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