Commit 6e634c99 authored by Lukas Eipert's avatar Lukas Eipert

Trigger refetching of vulns. from moderator

Instead of piping the change through the components we re-trigger
fetching the vulnerabilities from the moderator.
parent 31b126c1
......@@ -71,27 +71,20 @@ export default {
...mapActions('vulnerabilities', [
'createIssue',
'dismissVulnerability',
'fetchVulnerabilities',
'fetchVulnerabilitiesCount',
'fetchVulnerabilitiesHistory',
'revertDismissal',
'setVulnerabilitiesCountEndpoint',
'setVulnerabilitiesEndpoint',
'setVulnerabilitiesHistoryEndpoint',
]),
...mapActions('projects', ['setProjectsEndpoint', 'fetchProjects']),
filterChange() {
this.fetchVulnerabilities(this.activeFilters);
this.fetchVulnerabilitiesCount(this.activeFilters);
this.fetchVulnerabilitiesHistory(this.activeFilters);
},
},
};
</script>
<template>
<div>
<filters :dashboard-documentation="dashboardDocumentation" @change="filterChange" />
<filters :dashboard-documentation="dashboardDocumentation" />
<vulnerability-count-list />
<h4 class="my-4">{{ __('Vulnerability Chart') }}</h4>
<vulnerability-chart />
......
......@@ -40,7 +40,6 @@ export default {
filterId: this.filterId,
optionId: option.id,
});
this.$emit('change');
},
isSelected(option) {
return this.selection.has(option.id);
......
......@@ -27,7 +27,6 @@ export default {
class="col-sm-6 col-md-4 col-lg-2 p-2 js-filter"
:filter-id="filter.id"
:dashboard-documentation="dashboardDocumentation"
@change="$emit('change')"
/>
</div>
</div>
......
......@@ -44,7 +44,7 @@ export default {
},
},
created() {
this.fetchVulnerabilities();
this.fetchVulnerabilities(this.activeFilters);
},
methods: {
...mapActions('vulnerabilities', ['fetchVulnerabilities', 'openModal']),
......
......@@ -16,7 +16,6 @@ export default () => {
},
});
configureModerator(store);
return store;
......
import * as filtersMutationTypes from './modules/filters/mutation_types';
import * as projectsMutationTypes from './modules/projects/mutation_types';
export default function configureModerator(store) {
......@@ -18,6 +19,13 @@ export default function configureModerator(store) {
],
});
break;
case `filters/${filtersMutationTypes.SET_FILTER}`: {
const activeFilters = store.getters['filters/activeFilters'];
store.dispatch('vulnerabilities/fetchVulnerabilities', activeFilters);
store.dispatch('vulnerabilities/fetchVulnerabilitiesCount', activeFilters);
store.dispatch('vulnerabilities/fetchVulnerabilitiesHistory', activeFilters);
break;
}
default:
}
});
......
import createStore from 'ee/security_dashboard/store/index';
import * as projectsMutationTypes from 'ee/security_dashboard/store/modules/projects/mutation_types';
import * as filtersMutationTypes from 'ee/security_dashboard/store/modules/filters/mutation_types';
describe('moderator', () => {
let store;
......@@ -15,6 +16,7 @@ describe('moderator', () => {
projects: [{ name: 'foo', id: 1, otherProp: 'foobar' }],
});
expect(store.dispatch).toHaveBeenCalledTimes(1);
expect(store.dispatch).toHaveBeenCalledWith(
'filters/setFilterOptions',
Object({
......@@ -23,4 +25,26 @@ describe('moderator', () => {
}),
);
});
it('triggers fetching vulnerabilities after filters change', () => {
spyOn(store, 'dispatch').and.returnValue();
const activeFilters = store.getters['filters/activeFilters'];
store.commit(`filters/${filtersMutationTypes.SET_FILTER}`, {});
expect(store.dispatch).toHaveBeenCalledTimes(3);
expect(store.dispatch).toHaveBeenCalledWith(
'vulnerabilities/fetchVulnerabilities',
activeFilters,
);
expect(store.dispatch).toHaveBeenCalledWith(
'vulnerabilities/fetchVulnerabilitiesCount',
activeFilters,
);
expect(store.dispatch).toHaveBeenCalledWith(
'vulnerabilities/fetchVulnerabilitiesHistory',
activeFilters,
);
});
});
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