Commit 8ad897d1 authored by lauraMon's avatar lauraMon

Updated with Andrews feedback

parent 87cdbd22
...@@ -21,12 +21,12 @@ import getAlerts from '../graphql/queries/get_alerts.query.graphql'; ...@@ -21,12 +21,12 @@ import getAlerts from '../graphql/queries/get_alerts.query.graphql';
import getAlertsCountByStatus from '../graphql/queries/get_count_by_status.query.graphql'; import getAlertsCountByStatus from '../graphql/queries/get_count_by_status.query.graphql';
import { ALERTS_STATUS, ALERTS_STATUS_TABS, ALERTS_SEVERITY_LABELS } from '../constants'; import { ALERTS_STATUS, ALERTS_STATUS_TABS, ALERTS_SEVERITY_LABELS } from '../constants';
import updateAlertStatus from '../graphql/mutations/update_alert_status.graphql'; import updateAlertStatus from '../graphql/mutations/update_alert_status.graphql';
import { capitalizeFirstCharacter } from '~/lib/utils/text_utility'; import { capitalizeFirstCharacter, convertToSnakeCase } from '~/lib/utils/text_utility';
const tdClass = 'table-col d-flex d-md-table-cell align-items-center'; const tdClass = 'table-col d-flex d-md-table-cell align-items-center';
const bodyTrClass = const bodyTrClass =
'gl-border-1 gl-border-t-solid gl-border-gray-100 hover-bg-blue-50 hover-gl-cursor-pointer hover-gl-border-b-solid hover-gl-border-blue-200'; 'gl-border-1 gl-border-t-solid gl-border-gray-100 hover-bg-blue-50 hover-gl-cursor-pointer hover-gl-border-b-solid hover-gl-border-blue-200';
const findSortColumn = () => document.querySelector('.started-at'); const findDefaultSortColumn = () => document.querySelector('.js-started-at');
export default { export default {
i18n: { i18n: {
...@@ -47,7 +47,7 @@ export default { ...@@ -47,7 +47,7 @@ export default {
{ {
key: 'startTime', key: 'startTime',
label: s__('AlertManagement|Start time'), label: s__('AlertManagement|Start time'),
thClass: 'started-at', thClass: 'js-started-at',
tdClass, tdClass,
sortable: true, sortable: true,
}, },
...@@ -181,7 +181,7 @@ export default { ...@@ -181,7 +181,7 @@ export default {
}, },
}, },
mounted() { mounted() {
findSortColumn().ariaSort = 'ascending'; findDefaultSortColumn().ariaSort = 'ascending';
}, },
methods: { methods: {
filterAlertsByStatus(tabIndex) { filterAlertsByStatus(tabIndex) {
...@@ -189,9 +189,10 @@ export default { ...@@ -189,9 +189,10 @@ export default {
}, },
fetchSortedData({ sortBy, sortDesc }) { fetchSortedData({ sortBy, sortDesc }) {
const sortDirection = sortDesc ? 'DESC' : 'ASC'; const sortDirection = sortDesc ? 'DESC' : 'ASC';
const sortColumn = sortBy.replace(/([A-Z])/g, '_$1').toUpperCase(); const sortColumn = convertToSnakeCase(sortBy).toUpperCase();
if (sortBy !== 'startTime') { if (sortBy !== 'startTime') {
findSortColumn().ariaSort = 'none'; findDefaultSortColumn().ariaSort = 'none';
} }
this.sort = `${sortColumn}_${sortDirection}`; this.sort = `${sortColumn}_${sortDirection}`;
}, },
......
...@@ -292,7 +292,7 @@ describe('AlertManagementList', () => { ...@@ -292,7 +292,7 @@ describe('AlertManagementList', () => {
beforeEach(() => { beforeEach(() => {
mountComponent({ mountComponent({
props: { alertManagementEnabled: true, userCanEnableAlertManagement: true }, props: { alertManagementEnabled: true, userCanEnableAlertManagement: true },
data: { alerts: mockAlerts, errored: false, sort: 'START_TIME_ASC' }, data: { alerts: mockAlerts, errored: false, sort: 'START_TIME_ASC', alertsCount },
loading: false, loading: false,
}); });
}); });
......
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