Commit 23bdc738 authored by Tim Zallmann's avatar Tim Zallmann

Merge branch '249245-enable-sorting-vulnerabilities-by-report-type' into 'master'

Enable sorting vulnerabilities by report type

See merge request gitlab-org/gitlab!42980
parents 24942299 3c262da5
...@@ -21,6 +21,7 @@ import { formatDate } from '~/lib/utils/datetime_utility'; ...@@ -21,6 +21,7 @@ import { formatDate } from '~/lib/utils/datetime_utility';
import { s__, __, sprintf } from '~/locale'; import { s__, __, sprintf } from '~/locale';
import SelectionSummary from './selection_summary.vue'; import SelectionSummary from './selection_summary.vue';
import IssuesBadge from './issues_badge.vue'; import IssuesBadge from './issues_badge.vue';
import { convertToSnakeCase } from '~/lib/utils/text_utility';
import { VULNERABILITIES_PER_PAGE } from '../store/constants'; import { VULNERABILITIES_PER_PAGE } from '../store/constants';
export const SCANNER_ALERT_DISMISSED_LOCAL_STORAGE_KEY = export const SCANNER_ALERT_DISMISSED_LOCAL_STORAGE_KEY =
...@@ -165,6 +166,7 @@ export default { ...@@ -165,6 +166,7 @@ export default {
label: s__('Reports|Scanner'), label: s__('Reports|Scanner'),
thClass: 'scanner', thClass: 'scanner',
tdClass: 'scanner', tdClass: 'scanner',
sortable: this.isSortable,
}, },
{ {
key: 'activity', key: 'activity',
...@@ -277,7 +279,7 @@ export default { ...@@ -277,7 +279,7 @@ export default {
}, },
handleSortChange(args) { handleSortChange(args) {
if (args.sortBy) { if (args.sortBy) {
this.$emit('sort-changed', args); this.$emit('sort-changed', { ...args, sortBy: convertToSnakeCase(args.sortBy) });
} }
}, },
}, },
......
---
title: Enable sorting vulnerabiliies by state in the list view
merge_request: 42980
author:
type: added
...@@ -478,6 +478,12 @@ describe('Vulnerability list component', () => { ...@@ -478,6 +478,12 @@ describe('Vulnerability list component', () => {
expect(spy).toHaveBeenCalledWith(args); expect(spy).toHaveBeenCalledWith(args);
}); });
it('triggers the listener when sortBy is camelCased and transforms it to snake_case', () => {
const args = { sortBy: 'reportType', sortDesc: false };
findTable().vm.$emit('sort-changed', args);
expect(spy).toHaveBeenCalledWith({ ...args, sortBy: 'report_type' });
});
it('does not trigger the listener when sortBy is an empty value', () => { it('does not trigger the listener when sortBy is an empty value', () => {
findTable().vm.$emit('sort-changed', {}); findTable().vm.$emit('sort-changed', {});
expect(spy).not.toHaveBeenCalled(); expect(spy).not.toHaveBeenCalled();
......
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