Commit a083879e authored by lauraMon's avatar lauraMon

Improves with some refacotoring

parent d6a471ef
...@@ -34,7 +34,6 @@ import Tracking from '~/tracking'; ...@@ -34,7 +34,6 @@ import Tracking from '~/tracking';
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 gl-hover-bg-blue-50 gl-hover-cursor-pointer gl-hover-border-b-solid gl-hover-border-blue-200'; 'gl-border-1 gl-border-t-solid gl-border-gray-100 gl-hover-bg-blue-50 gl-hover-cursor-pointer gl-hover-border-b-solid gl-hover-border-blue-200';
const findDefaultSortColumn = () => document.querySelector('.js-started-at');
const initialPaginationState = { const initialPaginationState = {
currentPage: 1, currentPage: 1,
...@@ -193,6 +192,8 @@ export default { ...@@ -193,6 +192,8 @@ export default {
statusFilter: [], statusFilter: [],
filteredByStatus: '', filteredByStatus: '',
pagination: initialPaginationState, pagination: initialPaginationState,
sortBy: 'startedAt',
sortDesc: true,
}; };
}, },
computed: { computed: {
...@@ -229,9 +230,6 @@ export default { ...@@ -229,9 +230,6 @@ export default {
}, },
mounted() { mounted() {
this.trackPageViews(); this.trackPageViews();
if (this.alertManagementEnabled) {
findDefaultSortColumn().ariaSort = 'descending';
}
}, },
methods: { methods: {
filterAlertsByStatus(tabIndex) { filterAlertsByStatus(tabIndex) {
...@@ -244,9 +242,6 @@ export default { ...@@ -244,9 +242,6 @@ export default {
const sortDirection = sortDesc ? 'DESC' : 'ASC'; const sortDirection = sortDesc ? 'DESC' : 'ASC';
const sortColumn = convertToSnakeCase(sortBy).toUpperCase(); const sortColumn = convertToSnakeCase(sortBy).toUpperCase();
if (sortBy !== 'startedAt') {
findDefaultSortColumn().ariaSort = 'none';
}
this.resetPagination(); this.resetPagination();
this.sort = `${sortColumn}_${sortDirection}`; this.sort = `${sortColumn}_${sortDirection}`;
}, },
...@@ -347,6 +342,8 @@ export default { ...@@ -347,6 +342,8 @@ export default {
stacked="md" stacked="md"
:tbody-tr-class="tbodyTrClass" :tbody-tr-class="tbodyTrClass"
:no-local-sorting="true" :no-local-sorting="true"
:sort-desc.sync="sortDesc"
:sort-by.sync="sortBy"
sort-icon-left sort-icon-left
@row-clicked="navigateToAlertDetails" @row-clicked="navigateToAlertDetails"
@sort-changed="fetchSortedData" @sort-changed="fetchSortedData"
......
...@@ -91,10 +91,7 @@ describe('AlertManagementList', () => { ...@@ -91,10 +91,7 @@ describe('AlertManagementList', () => {
}); });
} }
const mockStartedAtCol = {};
beforeEach(() => { beforeEach(() => {
jest.spyOn(document, 'querySelector').mockReturnValue(mockStartedAtCol);
mountComponent(); mountComponent();
}); });
...@@ -352,14 +349,6 @@ describe('AlertManagementList', () => { ...@@ -352,14 +349,6 @@ describe('AlertManagementList', () => {
expect(wrapper.vm.$data.sort).toBe('SEVERITY_DESC'); expect(wrapper.vm.$data.sort).toBe('SEVERITY_DESC');
}); });
it('updates the `ariaSort` attribute so the sort icon appears in the proper column', () => {
expect(mockStartedAtCol.ariaSort).toEqual('descending');
findSeverityColumnHeader().trigger('click');
expect(mockStartedAtCol.ariaSort).toEqual('none');
});
}); });
describe('updating the alert status', () => { describe('updating the alert status', () => {
......
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