Commit 0e14bb24 authored by Savas Vedova's avatar Savas Vedova

Default state filter to confirmed and confirmed

- Update tests
- Update documentation
parent 25a98527
...@@ -69,6 +69,8 @@ You can filter the vulnerabilities by: ...@@ -69,6 +69,8 @@ You can filter the vulnerabilities by:
- Severity - Severity
- Report type - Report type
By default, detected and confirmed vulnerabilities will be displayed.
You can also dismiss vulnerabilities in the table: You can also dismiss vulnerabilities in the table:
1. Select the checkbox for each vulnerability you want to dismiss. 1. Select the checkbox for each vulnerability you want to dismiss.
...@@ -97,6 +99,8 @@ You can filter which vulnerabilities the Security Dashboard displays by: ...@@ -97,6 +99,8 @@ You can filter which vulnerabilities the Security Dashboard displays by:
- Report type - Report type
- Project - Project
By default, detected and confirmed vulnerabilities will be displayed.
A table lists the vulnerabilities, sorted by severity. The table shows each vulnerability's status, A table lists the vulnerabilities, sorted by severity. The table shows each vulnerability's status,
severity, and description. Clicking a vulnerability takes you to its [Vulnerability Details](../vulnerabilities) severity, and description. Clicking a vulnerability takes you to its [Vulnerability Details](../vulnerabilities)
page to view more information about that vulnerability. page to view more information about that vulnerability.
......
<script> <script>
import { isEqual } from 'lodash'; import { isEqual } from 'lodash';
import { ALL } from 'ee/security_dashboard/store/modules/filters/constants'; import { ALL, STATE } from 'ee/security_dashboard/store/modules/filters/constants';
import { setFilter } from 'ee/security_dashboard/store/modules/filters/utils'; import { setFilter } from 'ee/security_dashboard/store/modules/filters/utils';
import DashboardFilter from 'ee/security_dashboard/components/filter.vue'; import DashboardFilter from 'ee/security_dashboard/components/filter.vue';
import { initFirstClassVulnerabilityFilters, mapProjects } from 'ee/security_dashboard/helpers'; import { initFirstClassVulnerabilityFilters, mapProjects } from 'ee/security_dashboard/helpers';
...@@ -67,6 +67,11 @@ export default { ...@@ -67,6 +67,11 @@ export default {
}, },
}, },
}, },
created() {
if (Object.keys(this.selectedFilters).length === 0) {
this.$router.push({ query: { state: [STATE.DETECTED, STATE.CONFIRMED] } });
}
},
methods: { methods: {
setFilter(options) { setFilter(options) {
this.filters = setFilter(this.filters, options); this.filters = setFilter(this.filters, options);
......
import { s__ } from '~/locale'; import { s__ } from '~/locale';
export const ALL = 'all'; export const ALL = 'all';
export const STATE = {
DETECTED: 'DETECTED',
CONFIRMED: 'CONFIRMED',
};
export const BASE_FILTERS = { export const BASE_FILTERS = {
severity: { severity: {
......
---
title: By default display only confirmed and detected vulnerabilities
merge_request: 37914
author:
type: changed
...@@ -43,10 +43,6 @@ describe('First class vulnerability filters component', () => { ...@@ -43,10 +43,6 @@ describe('First class vulnerability filters component', () => {
expect(findFilters()).toHaveLength(filters.length); expect(findFilters()).toHaveLength(filters.length);
}); });
it('should pass down the filter information to the first filter', () => {
expect(findStateFilter().props().filter).toEqual(filters[0]);
});
it('should call the setFilter mutation when setting a filter', () => { it('should call the setFilter mutation when setting a filter', () => {
const stub = jest.fn(); const stub = jest.fn();
const options = { foo: 'bar' }; const options = { foo: 'bar' };
...@@ -108,6 +104,22 @@ describe('First class vulnerability filters component', () => { ...@@ -108,6 +104,22 @@ describe('First class vulnerability filters component', () => {
}); });
}); });
describe('when no filter is persisted in the URL', () => {
beforeEach(() => {
wrapper = createComponent({
propsData: { projects },
});
});
it('should redirect the user to an updated the URL and default the filters to CONFIRMED + DETECTED state', () => {
expect(findStateFilter().props('filter')).toEqual(
expect.objectContaining({
selection: new Set(['DETECTED', 'CONFIRMED']),
}),
);
});
});
describe.each` describe.each`
filter | value | selector filter | value | selector
${'state'} | ${'DETECTED,DISMISSED'} | ${findStateFilter} ${'state'} | ${'DETECTED,DISMISSED'} | ${findStateFilter}
......
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