Commit 34adfb1e authored by Savas Vedova's avatar Savas Vedova

Merge branch '353962-reset-paging-when-sort-changed' into 'master'

Reset paging when sort is changed on vulnerability report

See merge request gitlab-org/gitlab!81870
parents e9561b30 8e98a446
...@@ -268,6 +268,7 @@ export default { ...@@ -268,6 +268,7 @@ export default {
:thead-class="theadClass" :thead-class="theadClass"
:sort-desc="sort.sortDesc" :sort-desc="sort.sortDesc"
:sort-by="sort.sortBy" :sort-by="sort.sortBy"
sort-direction="last"
sort-icon-left sort-icon-left
no-local-sorting no-local-sorting
stacked="sm" stacked="sm"
......
...@@ -164,9 +164,14 @@ export default { ...@@ -164,9 +164,14 @@ export default {
this.vulnerabilities = []; this.vulnerabilities = [];
} }
}, },
sort() { sort(newSort, oldSort) {
// Clear out the vulnerabilities so that the skeleton loader is shown. // Clear out the vulnerabilities so that the skeleton loader is shown.
this.vulnerabilities = []; this.vulnerabilities = [];
// Anything that changes the querystring will also trigger this watcher (because sort is
// recomputed), so we need to check that the sort has changed before we reset the paging.
if (newSort.sortBy !== oldSort.sortBy || newSort.sortDesc !== oldSort.sortDesc) {
this.resetPaging();
}
}, },
}, },
methods: { methods: {
......
...@@ -237,6 +237,24 @@ describe('Vulnerability list GraphQL component', () => { ...@@ -237,6 +237,24 @@ describe('Vulnerability list GraphQL component', () => {
expect.objectContaining({ sort: 'state_desc' }), expect.objectContaining({ sort: 'state_desc' }),
); );
}); });
it('will reset paging if the sort has changed', async () => {
createWrapper();
router.push({ query: { after: 'abc' } });
findVulnerabilityList().vm.$emit('update:sort', SORT_OBJECT);
await nextTick();
expect(router.currentRoute.query.after).toBeUndefined();
});
it('will not reset paging when the page changes but sorting has not', async () => {
router.push({ query: SORT_OBJECT });
createWrapper();
router.push({ query: { ...router.currentRoute.query, after: 'abc' } });
await nextTick();
expect(router.currentRoute.query.after).toBe('abc');
});
}); });
describe('intersection observer', () => { describe('intersection observer', () => {
......
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