Commit 18082245 authored by Savas Vedova's avatar Savas Vedova

Merge branch '347169-fix-selection-summary-not-showing' into 'master'

Fix selection summary not sticking properly on vulnerability report

See merge request gitlab-org/gitlab!78534
parents 72657050 9fa2197f
...@@ -11,6 +11,8 @@ import { ...@@ -11,6 +11,8 @@ import {
import projectVulnerabilitiesQuery from '../../graphql/queries/project_vulnerabilities.query.graphql'; import projectVulnerabilitiesQuery from '../../graphql/queries/project_vulnerabilities.query.graphql';
import { DASHBOARD_TYPES } from '../../store/constants'; import { DASHBOARD_TYPES } from '../../store/constants';
const PORTAL_NAME = 'vulnerability-report-sticky';
export default { export default {
components: { components: {
VulnerabilityFilters, VulnerabilityFilters,
...@@ -55,6 +57,7 @@ export default { ...@@ -55,6 +57,7 @@ export default {
fieldsToShow: FIELD_PRESETS[REPORT_TAB.OPERATIONAL], fieldsToShow: FIELD_PRESETS[REPORT_TAB.OPERATIONAL],
filtersToShow: FILTER_PRESETS[REPORT_TAB.OPERATIONAL], filtersToShow: FILTER_PRESETS[REPORT_TAB.OPERATIONAL],
REPORT_TAB, REPORT_TAB,
PORTAL_NAME,
projectVulnerabilitiesQuery, projectVulnerabilitiesQuery,
}; };
</script> </script>
...@@ -66,13 +69,14 @@ export default { ...@@ -66,13 +69,14 @@ export default {
:filters="$options.filtersToShow" :filters="$options.filtersToShow"
@filters-changed="updateGraphqlFilters" @filters-changed="updateGraphqlFilters"
/> />
<portal-target name="vulnerability-report-sticky" /> <portal-target :name="$options.PORTAL_NAME" />
</div> </div>
<vulnerability-list-graphql <vulnerability-list-graphql
:query="$options.projectVulnerabilitiesQuery" :query="$options.projectVulnerabilitiesQuery"
:fields="$options.fieldsToShow" :fields="$options.fieldsToShow"
:filters="graphqlFilters" :filters="graphqlFilters"
:portal-name="$options.PORTAL_NAME"
/> />
</div> </div>
</template> </template>
...@@ -76,6 +76,10 @@ export default { ...@@ -76,6 +76,10 @@ export default {
required: false, required: false,
default: false, default: false,
}, },
portalName: {
type: String,
required: true,
},
}, },
data() { data() {
return { return {
...@@ -242,7 +246,7 @@ export default { ...@@ -242,7 +246,7 @@ export default {
<template> <template>
<div> <div>
<portal to="vulnerability-report-sticky"> <portal :to="portalName">
<selection-summary <selection-summary
:selected-vulnerabilities="Object.values(selectedVulnerabilities)" :selected-vulnerabilities="Object.values(selectedVulnerabilities)"
:visible="shouldShowSelectionSummary" :visible="shouldShowSelectionSummary"
......
...@@ -40,6 +40,10 @@ export default { ...@@ -40,6 +40,10 @@ export default {
required: false, required: false,
default: false, default: false,
}, },
portalName: {
type: String,
required: true,
},
}, },
data() { data() {
return { return {
...@@ -126,6 +130,7 @@ export default { ...@@ -126,6 +130,7 @@ export default {
:vulnerabilities="vulnerabilities" :vulnerabilities="vulnerabilities"
:fields="fields" :fields="fields"
:should-show-project-namespace="showProjectNamespace" :should-show-project-namespace="showProjectNamespace"
:portal-name="portalName"
@sort-changed="updateSort" @sort-changed="updateSort"
/> />
......
<script> <script>
import { PortalTarget } from 'portal-vue';
import { DASHBOARD_TYPES } from 'ee/security_dashboard/store/constants'; import { DASHBOARD_TYPES } from 'ee/security_dashboard/store/constants';
import VulnerabilityCounts from './vulnerability_counts.vue'; import VulnerabilityCounts from './vulnerability_counts.vue';
import VulnerabilityListGraphql from './vulnerability_list_graphql.vue'; import VulnerabilityListGraphql from './vulnerability_list_graphql.vue';
...@@ -17,7 +16,6 @@ export default { ...@@ -17,7 +16,6 @@ export default {
VulnerabilityCounts, VulnerabilityCounts,
VulnerabilityListGraphql, VulnerabilityListGraphql,
VulnerabilityFilters, VulnerabilityFilters,
PortalTarget,
}, },
inject: ['dashboardType'], inject: ['dashboardType'],
props: { props: {
...@@ -56,6 +54,9 @@ export default { ...@@ -56,6 +54,9 @@ export default {
fieldsToShow() { fieldsToShow() {
return FIELD_PRESETS[this.type]; return FIELD_PRESETS[this.type];
}, },
portalName() {
return `vulnerability-report-sticky-${this.type}`;
},
}, },
methods: { methods: {
updateGraphqlFilters(graphqlFilters) { updateGraphqlFilters(graphqlFilters) {
...@@ -84,7 +85,7 @@ export default { ...@@ -84,7 +85,7 @@ export default {
<div class="security-dashboard-filters gl-mt-7"> <div class="security-dashboard-filters gl-mt-7">
<vulnerability-filters :filters="filtersToShow" @filters-changed="updateGraphqlFilters" /> <vulnerability-filters :filters="filtersToShow" @filters-changed="updateGraphqlFilters" />
<portal-target name="vulnerability-report-sticky" /> <portal-target :name="portalName" />
</div> </div>
<vulnerability-list-graphql <vulnerability-list-graphql
...@@ -93,6 +94,7 @@ export default { ...@@ -93,6 +94,7 @@ export default {
:fields="fieldsToShow" :fields="fieldsToShow"
:filters="graphqlFilters" :filters="graphqlFilters"
:show-project-namespace="showProjectFilter" :show-project-namespace="showProjectFilter"
:portal-name="portalName"
/> />
</div> </div>
</template> </template>
...@@ -19,6 +19,7 @@ exports[`Agent vulnerability report component renders 1`] = ` ...@@ -19,6 +19,7 @@ exports[`Agent vulnerability report component renders 1`] = `
<vulnerability-list-graphql-stub <vulnerability-list-graphql-stub
fields="[object Object],[object Object],[object Object],[object Object],,[object Object]" fields="[object Object],[object Object],[object Object],[object Object],,[object Object]"
filters="[object Object]" filters="[object Object]"
portalname="vulnerability-report-sticky"
query="[object Object]" query="[object Object]"
/> />
</div> </div>
......
...@@ -15,6 +15,7 @@ const localVue = createLocalVue(); ...@@ -15,6 +15,7 @@ const localVue = createLocalVue();
localVue.use(VueApollo); localVue.use(VueApollo);
const fullPath = 'path'; const fullPath = 'path';
const portalName = 'portal-name';
const createVulnerabilitiesRequestHandler = ({ hasNextPage }) => const createVulnerabilitiesRequestHandler = ({ hasNextPage }) =>
jest.fn().mockResolvedValue({ jest.fn().mockResolvedValue({
...@@ -52,6 +53,7 @@ describe('Vulnerability list GraphQL component', () => { ...@@ -52,6 +53,7 @@ describe('Vulnerability list GraphQL component', () => {
}, },
propsData: { propsData: {
query: vulnerabilitiesQuery, query: vulnerabilitiesQuery,
portalName,
filters, filters,
fields, fields,
showProjectNamespace, showProjectNamespace,
...@@ -125,10 +127,11 @@ describe('Vulnerability list GraphQL component', () => { ...@@ -125,10 +127,11 @@ describe('Vulnerability list GraphQL component', () => {
const showProjectNamespace = true; const showProjectNamespace = true;
createWrapper({ fields, showProjectNamespace }); createWrapper({ fields, showProjectNamespace });
expect(findVulnerabilityList().props('fields')).toBe(fields); expect(findVulnerabilityList().props()).toMatchObject({
expect(findVulnerabilityList().props('shouldShowProjectNamespace')).toBe( shouldShowProjectNamespace: showProjectNamespace,
showProjectNamespace, fields,
); portalName,
});
}); });
it('calls the vulnerabilities query with the data from the sort-changed event', async () => { it('calls the vulnerabilities query with the data from the sort-changed event', async () => {
......
...@@ -16,6 +16,7 @@ import { FIELDS } from 'ee/security_dashboard/components/shared/vulnerability_re ...@@ -16,6 +16,7 @@ import { FIELDS } from 'ee/security_dashboard/components/shared/vulnerability_re
import { generateVulnerabilities, vulnerabilities } from '../../mock_data'; import { generateVulnerabilities, vulnerabilities } from '../../mock_data';
const { DETECTED, STATUS, SEVERITY, DESCRIPTION, IDENTIFIER, TOOL, ACTIVITY } = FIELDS; const { DETECTED, STATUS, SEVERITY, DESCRIPTION, IDENTIFIER, TOOL, ACTIVITY } = FIELDS;
const portalName = 'portal-name';
describe('Vulnerability list component', () => { describe('Vulnerability list component', () => {
let wrapper; let wrapper;
...@@ -25,6 +26,7 @@ describe('Vulnerability list component', () => { ...@@ -25,6 +26,7 @@ describe('Vulnerability list component', () => {
propsData: { propsData: {
vulnerabilities: [], vulnerabilities: [],
fields: [DETECTED, STATUS, SEVERITY, DESCRIPTION, IDENTIFIER, TOOL, ACTIVITY], fields: [DETECTED, STATUS, SEVERITY, DESCRIPTION, IDENTIFIER, TOOL, ACTIVITY],
portalName,
...props, ...props,
}, },
stubs: { stubs: {
...@@ -148,7 +150,7 @@ describe('Vulnerability list component', () => { ...@@ -148,7 +150,7 @@ describe('Vulnerability list component', () => {
}); });
it('should portal the selection summary to the expected portal', () => { it('should portal the selection summary to the expected portal', () => {
expect(wrapper.find(Portal).attributes('to')).toBe('vulnerability-report-sticky'); expect(wrapper.find(Portal).attributes('to')).toBe(portalName);
}); });
it('should not show the selection summary if no vulnerabilities are selected', () => { it('should not show the selection summary if no vulnerabilities are selected', () => {
......
...@@ -121,9 +121,12 @@ describe('Vulnerability report component', () => { ...@@ -121,9 +121,12 @@ describe('Vulnerability report component', () => {
}); });
describe('sticky portal', () => { describe('sticky portal', () => {
it('has the portal target with the expected name', () => { it.each([REPORT_TAB.DEVELOPMENT, REPORT_TAB.OPERATIONAL])(
createWrapper(); 'has the portal target with the expected name for the %s report',
expect(findPortalTarget().props('name')).toBe('vulnerability-report-sticky'); (type) => {
}); createWrapper({ type });
expect(findPortalTarget().props('name')).toBe(`vulnerability-report-sticky-${type}`);
},
);
}); });
}); });
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