Commit 5b26c460 authored by Olena Horal-Koretska's avatar Olena Horal-Koretska

Merge branch '284471-standard-filter-rename-simple-filter' into 'master'

Rename standard_filter.vue to simple_filter.vue

See merge request gitlab-org/gitlab!65616
parents 1a8cd89e 0ce447db
<script> <script>
import { GlToggle } from '@gitlab/ui'; import { GlToggle } from '@gitlab/ui';
import { mapState, mapActions } from 'vuex'; import { mapState, mapActions } from 'vuex';
import { severityFilter, standardScannerFilter } from 'ee/security_dashboard/helpers'; import { severityFilter, simpleScannerFilter } from 'ee/security_dashboard/helpers';
import { DISMISSAL_STATES } from 'ee/security_dashboard/store/modules/filters/constants'; import { DISMISSAL_STATES } from 'ee/security_dashboard/store/modules/filters/constants';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import StandardFilter from '../shared/filters/standard_filter.vue'; import SimpleFilter from '../shared/filters/simple_filter.vue';
export default { export default {
i18n: { i18n: {
toggleLabel: s__('SecurityReports|Hide dismissed'), toggleLabel: s__('SecurityReports|Hide dismissed'),
}, },
components: { components: {
StandardFilter, SimpleFilter,
GlToggle, GlToggle,
}, },
data() { data() {
return { return {
filterConfigs: [severityFilter, standardScannerFilter], filterConfigs: [severityFilter, simpleScannerFilter],
}; };
}, },
computed: { computed: {
...@@ -39,7 +39,7 @@ export default { ...@@ -39,7 +39,7 @@ export default {
<template> <template>
<div class="dashboard-filters border-bottom bg-gray-light"> <div class="dashboard-filters border-bottom bg-gray-light">
<div class="row mx-0 p-2"> <div class="row mx-0 p-2">
<standard-filter <simple-filter
v-for="filter in filterConfigs" v-for="filter in filterConfigs"
:key="filter.id" :key="filter.id"
class="col-sm-6 col-md-4 col-lg-2 p-2 js-filter" class="col-sm-6 col-md-4 col-lg-2 p-2 js-filter"
......
...@@ -4,13 +4,13 @@ import { xor, remove } from 'lodash'; ...@@ -4,13 +4,13 @@ import { xor, remove } from 'lodash';
import { activityOptions } from 'ee/security_dashboard/helpers'; import { activityOptions } from 'ee/security_dashboard/helpers';
import FilterBody from './filter_body.vue'; import FilterBody from './filter_body.vue';
import FilterItem from './filter_item.vue'; import FilterItem from './filter_item.vue';
import StandardFilter from './standard_filter.vue'; import SimpleFilter from './simple_filter.vue';
const { NO_ACTIVITY, WITH_ISSUES, NO_LONGER_DETECTED } = activityOptions; const { NO_ACTIVITY, WITH_ISSUES, NO_LONGER_DETECTED } = activityOptions;
export default { export default {
components: { FilterBody, FilterItem, GlDropdownDivider }, components: { FilterBody, FilterItem, GlDropdownDivider },
extends: StandardFilter, extends: SimpleFilter,
computed: { computed: {
filterObject() { filterObject() {
// This is the object used to update the GraphQL query. // This is the object used to update the GraphQL query.
......
...@@ -4,17 +4,17 @@ import { ...@@ -4,17 +4,17 @@ import {
stateFilter, stateFilter,
severityFilter, severityFilter,
vendorScannerFilter, vendorScannerFilter,
standardScannerFilter, simpleScannerFilter,
activityFilter, activityFilter,
getProjectFilter, getProjectFilter,
} from 'ee/security_dashboard/helpers'; } from 'ee/security_dashboard/helpers';
import { DASHBOARD_TYPES } from 'ee/security_dashboard/store/constants'; import { DASHBOARD_TYPES } from 'ee/security_dashboard/store/constants';
import ActivityFilter from './activity_filter.vue'; import ActivityFilter from './activity_filter.vue';
import ScannerFilter from './scanner_filter.vue'; import ScannerFilter from './scanner_filter.vue';
import StandardFilter from './standard_filter.vue'; import SimpleFilter from './simple_filter.vue';
export default { export default {
components: { StandardFilter, ScannerFilter, ActivityFilter }, components: { SimpleFilter, ScannerFilter, ActivityFilter },
inject: ['dashboardType'], inject: ['dashboardType'],
props: { props: {
projects: { type: Array, required: false, default: undefined }, projects: { type: Array, required: false, default: undefined },
...@@ -22,7 +22,6 @@ export default { ...@@ -22,7 +22,6 @@ export default {
data() { data() {
return { return {
filterQuery: {}, filterQuery: {},
standardFilters: [stateFilter, severityFilter],
}; };
}, },
computed: { computed: {
...@@ -44,14 +43,16 @@ export default { ...@@ -44,14 +43,16 @@ export default {
this.filterQuery = { ...this.filterQuery, ...query }; this.filterQuery = { ...this.filterQuery, ...query };
this.emitFilterChange(); this.emitFilterChange();
}, },
// When this component is first shown, every filter will emit its own @filter-changed event at, // When this component is first shown, every filter will emit its own @filter-changed event at
// which will trigger this method multiple times. We'll debounce it so that it only runs once. // the same time, which will trigger this method multiple times. We'll debounce it so that it
// only runs once.
emitFilterChange: debounce(function emit() { emitFilterChange: debounce(function emit() {
this.$emit('filterChange', this.filterQuery); this.$emit('filterChange', this.filterQuery);
}), }),
}, },
simpleFilters: [stateFilter, severityFilter],
vendorScannerFilter, vendorScannerFilter,
standardScannerFilter, simpleScannerFilter,
activityFilter, activityFilter,
}; };
</script> </script>
...@@ -60,8 +61,8 @@ export default { ...@@ -60,8 +61,8 @@ export default {
<div <div
class="vulnerability-report-filters gl-p-5 gl-bg-gray-10 gl-border-b-1 gl-border-b-solid gl-border-b-gray-100" class="vulnerability-report-filters gl-p-5 gl-bg-gray-10 gl-border-b-1 gl-border-b-solid gl-border-b-gray-100"
> >
<standard-filter <simple-filter
v-for="filter in standardFilters" v-for="filter in $options.simpleFilters"
:key="filter.id" :key="filter.id"
:filter="filter" :filter="filter"
:data-testid="filter.id" :data-testid="filter.id"
...@@ -73,10 +74,10 @@ export default { ...@@ -73,10 +74,10 @@ export default {
:filter="$options.vendorScannerFilter" :filter="$options.vendorScannerFilter"
@filter-changed="updateFilterQuery" @filter-changed="updateFilterQuery"
/> />
<standard-filter <simple-filter
v-else v-else
:filter="$options.standardScannerFilter" :filter="$options.simpleScannerFilter"
:data-testid="$options.standardScannerFilter.id" :data-testid="$options.simpleScannerFilter.id"
@filter-changed="updateFilterQuery" @filter-changed="updateFilterQuery"
/> />
...@@ -85,7 +86,7 @@ export default { ...@@ -85,7 +86,7 @@ export default {
:filter="$options.activityFilter" :filter="$options.activityFilter"
@filter-changed="updateFilterQuery" @filter-changed="updateFilterQuery"
/> />
<standard-filter <simple-filter
v-if="shouldShowProjectFilter" v-if="shouldShowProjectFilter"
:filter="projectFilter" :filter="projectFilter"
:data-testid="projectFilter.id" :data-testid="projectFilter.id"
......
...@@ -5,7 +5,7 @@ import { DEFAULT_SCANNER, SCANNER_ID_PREFIX } from 'ee/security_dashboard/consta ...@@ -5,7 +5,7 @@ import { DEFAULT_SCANNER, SCANNER_ID_PREFIX } from 'ee/security_dashboard/consta
import { createScannerOption } from 'ee/security_dashboard/helpers'; import { createScannerOption } from 'ee/security_dashboard/helpers';
import FilterBody from './filter_body.vue'; import FilterBody from './filter_body.vue';
import FilterItem from './filter_item.vue'; import FilterItem from './filter_item.vue';
import StandardFilter from './standard_filter.vue'; import SimpleFilter from './simple_filter.vue';
export default { export default {
components: { components: {
...@@ -15,7 +15,7 @@ export default { ...@@ -15,7 +15,7 @@ export default {
FilterBody, FilterBody,
FilterItem, FilterItem,
}, },
extends: StandardFilter, extends: SimpleFilter,
inject: ['scanners'], inject: ['scanners'],
computed: { computed: {
options() { options() {
......
...@@ -46,7 +46,7 @@ export const createScannerOption = (vendor, reportType) => { ...@@ -46,7 +46,7 @@ export const createScannerOption = (vendor, reportType) => {
// This is used on the pipeline security tab, group-level report, and instance-level report. It's // This is used on the pipeline security tab, group-level report, and instance-level report. It's
// used by the scanner filter that shows a flat list of scan types (DAST, SAST, etc) with no vendor // used by the scanner filter that shows a flat list of scan types (DAST, SAST, etc) with no vendor
// grouping. // grouping.
export const standardScannerFilter = { export const simpleScannerFilter = {
name: s__('SecurityReports|Scanner'), name: s__('SecurityReports|Scanner'),
id: 'reportType', id: 'reportType',
options: parseOptions(REPORT_TYPES), options: parseOptions(REPORT_TYPES),
......
...@@ -2,7 +2,7 @@ import { GlToggle } from '@gitlab/ui'; ...@@ -2,7 +2,7 @@ import { GlToggle } from '@gitlab/ui';
import { shallowMount, mount, createLocalVue } from '@vue/test-utils'; import { shallowMount, mount, createLocalVue } from '@vue/test-utils';
import Vuex from 'vuex'; import Vuex from 'vuex';
import Filters from 'ee/security_dashboard/components/pipeline/filters.vue'; import Filters from 'ee/security_dashboard/components/pipeline/filters.vue';
import { standardScannerFilter } from 'ee/security_dashboard/helpers'; import { simpleScannerFilter } from 'ee/security_dashboard/helpers';
import createStore from 'ee/security_dashboard/store'; import createStore from 'ee/security_dashboard/store';
import state from 'ee/security_dashboard/store/modules/filters/state'; import state from 'ee/security_dashboard/store/modules/filters/state';
import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper';
...@@ -75,8 +75,8 @@ describe('Filter component', () => { ...@@ -75,8 +75,8 @@ describe('Filter component', () => {
// scanner filter item. // scanner filter item.
mock.mockClear(); mock.mockClear();
const filterId = standardScannerFilter.id; const filterId = simpleScannerFilter.id;
const optionId = standardScannerFilter.options[2].id; const optionId = simpleScannerFilter.options[2].id;
const option = wrapper.findByTestId(`${filterId}:${optionId}`); const option = wrapper.findByTestId(`${filterId}:${optionId}`);
option.vm.$emit('click'); option.vm.$emit('click');
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
......
...@@ -2,8 +2,8 @@ import { shallowMount } from '@vue/test-utils'; ...@@ -2,8 +2,8 @@ import { shallowMount } from '@vue/test-utils';
import ActivityFilter from 'ee/security_dashboard/components/shared/filters/activity_filter.vue'; import ActivityFilter from 'ee/security_dashboard/components/shared/filters/activity_filter.vue';
import Filters from 'ee/security_dashboard/components/shared/filters/filters_layout.vue'; import Filters from 'ee/security_dashboard/components/shared/filters/filters_layout.vue';
import ScannerFilter from 'ee/security_dashboard/components/shared/filters/scanner_filter.vue'; import ScannerFilter from 'ee/security_dashboard/components/shared/filters/scanner_filter.vue';
import StandardFilter from 'ee/security_dashboard/components/shared/filters/standard_filter.vue'; import SimpleFilter from 'ee/security_dashboard/components/shared/filters/simple_filter.vue';
import { getProjectFilter, standardScannerFilter } from 'ee/security_dashboard/helpers'; import { getProjectFilter, simpleScannerFilter } from 'ee/security_dashboard/helpers';
import { DASHBOARD_TYPES } from 'ee/security_dashboard/store/constants'; import { DASHBOARD_TYPES } from 'ee/security_dashboard/store/constants';
import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper';
...@@ -15,8 +15,8 @@ describe('First class vulnerability filters component', () => { ...@@ -15,8 +15,8 @@ describe('First class vulnerability filters component', () => {
{ id: 'gid://gitlab/Project/12', name: 'GitLab Com' }, { id: 'gid://gitlab/Project/12', name: 'GitLab Com' },
]; ];
const findStandardFilters = () => wrapper.findAllComponents(StandardFilter); const findSimpleFilters = () => wrapper.findAllComponents(SimpleFilter);
const findStandardScannerFilter = () => wrapper.findByTestId(standardScannerFilter.id); const findSimpleScannerFilter = () => wrapper.findByTestId(simpleScannerFilter.id);
const findVendorScannerFilter = () => wrapper.findComponent(ScannerFilter); const findVendorScannerFilter = () => wrapper.findComponent(ScannerFilter);
const findActivityFilter = () => wrapper.findComponent(ActivityFilter); const findActivityFilter = () => wrapper.findComponent(ActivityFilter);
const findProjectFilter = () => wrapper.findByTestId(getProjectFilter([]).id); const findProjectFilter = () => wrapper.findByTestId(getProjectFilter([]).id);
...@@ -43,7 +43,7 @@ describe('First class vulnerability filters component', () => { ...@@ -43,7 +43,7 @@ describe('First class vulnerability filters component', () => {
}); });
it('should render the default filters', () => { it('should render the default filters', () => {
expect(findStandardFilters()).toHaveLength(2); expect(findSimpleFilters()).toHaveLength(2);
expect(findActivityFilter().exists()).toBe(true); expect(findActivityFilter().exists()).toBe(true);
expect(findProjectFilter().exists()).toBe(false); expect(findProjectFilter().exists()).toBe(false);
}); });
...@@ -85,15 +85,15 @@ describe('First class vulnerability filters component', () => { ...@@ -85,15 +85,15 @@ describe('First class vulnerability filters component', () => {
describe('scanner filter', () => { describe('scanner filter', () => {
it.each` it.each`
type | dashboardType type | dashboardType
${'vendor'} | ${DASHBOARD_TYPES.PROJECT} ${'vendor'} | ${DASHBOARD_TYPES.PROJECT}
${'standard'} | ${DASHBOARD_TYPES.GROUP} ${'simple'} | ${DASHBOARD_TYPES.GROUP}
${'standard'} | ${DASHBOARD_TYPES.INSTANCE} ${'simple'} | ${DASHBOARD_TYPES.INSTANCE}
${'standard'} | ${DASHBOARD_TYPES.PIPELINE} ${'simple'} | ${DASHBOARD_TYPES.PIPELINE}
`('shows the $type scanner filter on the $dashboardType report', ({ type, dashboardType }) => { `('shows the $type scanner filter on the $dashboardType report', ({ type, dashboardType }) => {
wrapper = createComponent({ provide: { dashboardType } }); wrapper = createComponent({ provide: { dashboardType } });
expect(findStandardScannerFilter().exists()).toBe(type === 'standard'); expect(findSimpleScannerFilter().exists()).toBe(type === 'simple');
expect(findVendorScannerFilter().exists()).toBe(type === 'vendor'); expect(findVendorScannerFilter().exists()).toBe(type === 'vendor');
}); });
}); });
......
import { createLocalVue, shallowMount } from '@vue/test-utils'; import { createLocalVue, shallowMount } from '@vue/test-utils';
import VueRouter from 'vue-router'; import VueRouter from 'vue-router';
import FilterBody from 'ee/security_dashboard/components/shared/filters/filter_body.vue'; import FilterBody from 'ee/security_dashboard/components/shared/filters/filter_body.vue';
import StandardFilter from 'ee/security_dashboard/components/shared/filters/standard_filter.vue'; import SimpleFilter from 'ee/security_dashboard/components/shared/filters/simple_filter.vue';
const localVue = createLocalVue(); const localVue = createLocalVue();
localVue.use(VueRouter); localVue.use(VueRouter);
...@@ -20,11 +20,11 @@ const filter = { ...@@ -20,11 +20,11 @@ const filter = {
const optionsAt = (indexes) => filter.options.filter((x) => indexes.includes(x.index)); const optionsAt = (indexes) => filter.options.filter((x) => indexes.includes(x.index));
const optionIdsAt = (indexes) => optionsAt(indexes).map((x) => x.id); const optionIdsAt = (indexes) => optionsAt(indexes).map((x) => x.id);
describe('Standard Filter component', () => { describe('Simple Filter component', () => {
let wrapper; let wrapper;
const createWrapper = (filterOptions, props) => { const createWrapper = (filterOptions, props) => {
wrapper = shallowMount(StandardFilter, { wrapper = shallowMount(SimpleFilter, {
localVue, localVue,
router, router,
propsData: { filter: { ...filter, ...filterOptions }, ...props }, propsData: { filter: { ...filter, ...filterOptions }, ...props },
......
...@@ -11,7 +11,7 @@ module QA ...@@ -11,7 +11,7 @@ module QA
super super
base.class_eval do base.class_eval do
view 'ee/app/assets/javascripts/security_dashboard/components/filters/standard_filter.vue' do view 'ee/app/assets/javascripts/security_dashboard/components/filters/simple_filter.vue' do
element :filter_dropdown, ':data-qa-selector="qaSelector"' # rubocop:disable QA/ElementWithPattern element :filter_dropdown, ':data-qa-selector="qaSelector"' # rubocop:disable QA/ElementWithPattern
element :filter_dropdown_content element :filter_dropdown_content
end end
......
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