Commit 9e9cb618 authored by Daniel Tian's avatar Daniel Tian Committed by Kushal Pandya

Remove old scanner filter and only use new filter on vuln report page [RUN ALL...

Remove old scanner filter and only use new filter on vuln report page [RUN ALL RSPEC] [RUN AS-IF-FOSS]
parent c6a85564
<script>
import { debounce } from 'lodash';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import {
stateFilter,
severityFilter,
......@@ -15,7 +14,6 @@ import StandardFilter from './filters/standard_filter.vue';
export default {
components: { StandardFilter, ScannerFilter, ActivityFilter },
mixins: [glFeatureFlagsMixin()],
inject: ['dashboardType'],
props: {
projects: { type: Array, required: false, default: undefined },
......@@ -23,23 +21,16 @@ export default {
data() {
return {
filterQuery: {},
standardFilters: [stateFilter, severityFilter],
};
},
computed: {
isPipeline() {
return this.dashboardType === DASHBOARD_TYPES.PIPELINE;
},
standardFilters() {
return this.shouldShowCustomScannerFilter
? [stateFilter, severityFilter]
: [stateFilter, severityFilter, scannerFilter];
},
shouldShowProjectFilter() {
return Boolean(this.projects?.length);
},
shouldShowCustomScannerFilter() {
return this.glFeatures.customSecurityScanners;
},
projectFilter() {
return getProjectFilter(this.projects);
},
......@@ -71,11 +62,7 @@ export default {
:data-testid="filter.id"
@filter-changed="updateFilterQuery"
/>
<scanner-filter
v-if="shouldShowCustomScannerFilter"
:filter="$options.scannerFilter"
@filter-changed="updateFilterQuery"
/>
<scanner-filter :filter="$options.scannerFilter" @filter-changed="updateFilterQuery" />
<activity-filter
v-if="!isPipeline"
:filter="$options.activityFilter"
......
......@@ -36,7 +36,7 @@ export const createScannerOption = (vendor, reportType) => {
const type = reportType.toUpperCase();
return {
id: gon.features?.customSecurityScanners ? `${vendor}.${type}` : type,
id: `${vendor}.${type}`,
reportType: reportType.toUpperCase(),
name: convertReportType(reportType),
scannerIds: [],
......@@ -45,7 +45,7 @@ export const createScannerOption = (vendor, reportType) => {
export const scannerFilter = {
name: s__('SecurityReports|Scanner'),
id: gon.features?.customSecurityScanners ? 'scanner' : 'reportType',
id: 'scanner',
options: Object.keys(REPORT_TYPES).map((x) => createScannerOption(DEFAULT_SCANNER, x)),
allOption: BASE_FILTERS.report_type,
defaultOptions: [],
......
......@@ -6,7 +6,6 @@ module Groups
layout 'group'
before_action do
push_frontend_feature_flag(:custom_security_scanners, current_user)
push_frontend_feature_flag(:vulnerability_management_survey, type: :ops, default_enabled: :yaml)
end
......
......@@ -7,7 +7,6 @@ module Projects
include SecurityDashboardsPermissions
before_action do
push_frontend_feature_flag(:custom_security_scanners, current_user)
push_frontend_feature_flag(:vulnerability_management_survey, type: :ops, default_enabled: :yaml)
end
......
......@@ -5,7 +5,6 @@ module Security
layout 'instance_security'
before_action do
push_frontend_feature_flag(:custom_security_scanners, current_user)
push_frontend_feature_flag(:vulnerability_management_survey, type: :ops, default_enabled: :yaml)
end
end
......
---
title: Remove old scanner filter and only use new filter on vulnerability report page
merge_request: 61959
author:
type: added
---
name: custom_security_scanners
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/49710
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/299295
milestone: '13.9'
type: development
group: group::threat insights
default_enabled: false
......@@ -38,10 +38,6 @@ describe('Scanner Filter component', () => {
const createWrapper = () => {
filter = cloneDeep(scannerFilter);
filter.options = filter.options.map((option) => ({
...option,
id: `GitLab.${option.id}`,
}));
wrapper = shallowMount(ScannerFilter, {
localVue,
......@@ -51,10 +47,6 @@ describe('Scanner Filter component', () => {
});
};
beforeEach(() => {
gon.features = { customSecurityScanners: true };
});
afterEach(() => {
wrapper.destroy();
// Clear out the querystring if one exists, it persists between tests.
......@@ -113,7 +105,7 @@ describe('Scanner Filter component', () => {
it('emits filter-changed event with expected data for selected options', async () => {
const ids = ['GitLab.SAST', 'Custom.SAST'];
router.replace({ query: { [filter.id]: ids } });
router.replace({ query: { [scannerFilter.id]: ids } });
const selectedScanners = scanners.filter((x) => ids.includes(`${x.vendor}.${x.report_type}`));
createWrapper();
await wrapper.vm.$nextTick();
......
......@@ -3,7 +3,7 @@ import ActivityFilter from 'ee/security_dashboard/components/filters/activity_fi
import ScannerFilter from 'ee/security_dashboard/components/filters/scanner_filter.vue';
import StandardFilter from 'ee/security_dashboard/components/filters/standard_filter.vue';
import Filters from 'ee/security_dashboard/components/first_class_vulnerability_filters.vue';
import { scannerFilter, getProjectFilter } from 'ee/security_dashboard/helpers';
import { getProjectFilter } from 'ee/security_dashboard/helpers';
import { DASHBOARD_TYPES } from 'ee/security_dashboard/store/constants';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
......@@ -16,8 +16,7 @@ describe('First class vulnerability filters component', () => {
];
const findStandardFilters = () => wrapper.findAllComponents(StandardFilter);
const findStandardScannerFilter = () => wrapper.findByTestId(scannerFilter.id);
const findCustomScannerFilter = () => wrapper.findComponent(ScannerFilter);
const findScannerFilter = () => wrapper.findComponent(ScannerFilter);
const findActivityFilter = () => wrapper.findComponent(ActivityFilter);
const findProjectFilter = () => wrapper.findByTestId(getProjectFilter([]).id);
......@@ -38,31 +37,14 @@ describe('First class vulnerability filters component', () => {
wrapper = null;
});
it.each`
flagValue | isStandardFilterShown | isCustomFilterShown
${true} | ${false} | ${true}
${false} | ${true} | ${false}
`(
`renders correct scanner filter component when customSecurityScanners feature flag is $flagValue`,
({ flagValue, isStandardFilterShown, isCustomFilterShown }) => {
wrapper = createComponent({
provide: {
glFeatures: { customSecurityScanners: flagValue },
},
});
expect(findCustomScannerFilter().exists()).toBe(isCustomFilterShown);
expect(findStandardScannerFilter().exists()).toBe(isStandardFilterShown);
},
);
describe('on render without project filter', () => {
beforeEach(() => {
wrapper = createComponent();
});
it('should render the default filters', () => {
expect(findStandardFilters()).toHaveLength(3);
expect(findStandardFilters()).toHaveLength(2);
expect(findScannerFilter().exists()).toBe(true);
expect(findActivityFilter().exists()).toBe(true);
expect(findProjectFilter().exists()).toBe(false);
});
......
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