Commit a083879e authored by lauraMon's avatar lauraMon

Improves with some refacotoring

parent d6a471ef
......@@ -34,7 +34,6 @@ import Tracking from '~/tracking';
const tdClass = 'table-col d-flex d-md-table-cell align-items-center';
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';
const findDefaultSortColumn = () => document.querySelector('.js-started-at');
const initialPaginationState = {
currentPage: 1,
......@@ -193,6 +192,8 @@ export default {
statusFilter: [],
filteredByStatus: '',
pagination: initialPaginationState,
sortBy: 'startedAt',
sortDesc: true,
};
},
computed: {
......@@ -229,9 +230,6 @@ export default {
},
mounted() {
this.trackPageViews();
if (this.alertManagementEnabled) {
findDefaultSortColumn().ariaSort = 'descending';
}
},
methods: {
filterAlertsByStatus(tabIndex) {
......@@ -244,9 +242,6 @@ export default {
const sortDirection = sortDesc ? 'DESC' : 'ASC';
const sortColumn = convertToSnakeCase(sortBy).toUpperCase();
if (sortBy !== 'startedAt') {
findDefaultSortColumn().ariaSort = 'none';
}
this.resetPagination();
this.sort = `${sortColumn}_${sortDirection}`;
},
......@@ -347,6 +342,8 @@ export default {
stacked="md"
:tbody-tr-class="tbodyTrClass"
:no-local-sorting="true"
:sort-desc.sync="sortDesc"
:sort-by.sync="sortBy"
sort-icon-left
@row-clicked="navigateToAlertDetails"
@sort-changed="fetchSortedData"
......
......@@ -91,10 +91,7 @@ describe('AlertManagementList', () => {
});
}
const mockStartedAtCol = {};
beforeEach(() => {
jest.spyOn(document, 'querySelector').mockReturnValue(mockStartedAtCol);
mountComponent();
});
......@@ -352,14 +349,6 @@ describe('AlertManagementList', () => {
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', () => {
......
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