Commit 3c262da5 authored by Alan (Maciej) Paruszewski's avatar Alan (Maciej) Paruszewski Committed by Tim Zallmann

Enable sorting vulnerabilities by report type

parent f9fad2a8
......@@ -21,6 +21,7 @@ import { formatDate } from '~/lib/utils/datetime_utility';
import { s__, __, sprintf } from '~/locale';
import SelectionSummary from './selection_summary.vue';
import IssuesBadge from './issues_badge.vue';
import { convertToSnakeCase } from '~/lib/utils/text_utility';
import { VULNERABILITIES_PER_PAGE } from '../store/constants';
export const SCANNER_ALERT_DISMISSED_LOCAL_STORAGE_KEY =
......@@ -165,6 +166,7 @@ export default {
label: s__('Reports|Scanner'),
thClass: 'scanner',
tdClass: 'scanner',
sortable: this.isSortable,
},
{
key: 'activity',
......@@ -277,7 +279,7 @@ export default {
},
handleSortChange(args) {
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', () => {
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', () => {
findTable().vm.$emit('sort-changed', {});
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