And taking the opportunity to refactor the security reports store
Sam Beckham
@samdbeckham
Current Branch
Default Branch
// ee/.../vue_shared/security_reports/store/mediator.js
import * as types from './mutation_types';
const updateIssueActionsMap = {
sast: 'sast/updateVulnerability',
dependency_scanning: 'updateDependencyScanningIssue',
container_scanning: 'updateContainerScanningIssue',
dast: 'updateDastIssue',
};
export default function configureMediator(store) {
store.subscribe(({ type, payload }) => {
switch (type) {
case types.RECEIVE_DISMISS_VULNERABILITY_SUCCESS:
if (updateIssueActionsMap[payload.category]) {
store.dispatch(
updateIssueActionsMap[payload.category],
payload
);
}
break;
default:
}
});
}
import * as filtersMutationTypes from './modules/filters/mutation_types';
import * as projectsMutationTypes from './modules/projects/mutation_types';
import { BASE_FILTERS } from './modules/filters/constants';
export default function configureModerator(store) {
store.subscribe(({ type, payload }) => {
switch (type) {
case `projects/${projectsMutationTypes.RECEIVE_PROJECTS_SUCCESS}`:
store.dispatch('filters/setFilterOptions', {
filterId: 'project_id',
options: [
BASE_FILTERS.project_id,
...payload.projects.map(project => ({
name: project.name,
id: project.id.toString(),
})),
],
});
break;
case `filters/${filtersMutationTypes.SET_ALL_FILTERS}`:
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:
}
});
}