Commit 65a0a021 authored by Mark Florian's avatar Mark Florian

Merge branch '284471-use-provide-inject-for-group-full-path' into 'master'

Use provide/inject for groupFullPath instead of props

See merge request gitlab-org/gitlab!56472
parents ced2b137 42920455
...@@ -19,11 +19,8 @@ export default { ...@@ -19,11 +19,8 @@ export default {
GlLoadingIcon, GlLoadingIcon,
VulnerabilitiesCountList, VulnerabilitiesCountList,
}, },
inject: ['groupFullPath'],
props: { props: {
groupFullPath: {
type: String,
required: true,
},
vulnerabilitiesExportEndpoint: { vulnerabilitiesExportEndpoint: {
type: String, type: String,
required: true, required: true,
...@@ -88,7 +85,7 @@ export default { ...@@ -88,7 +85,7 @@ export default {
<template #sticky> <template #sticky>
<filters :projects="projects" @filterChange="handleFilterChange" /> <filters :projects="projects" @filterChange="handleFilterChange" />
</template> </template>
<group-security-vulnerabilities :group-full-path="groupFullPath" :filters="filters" /> <group-security-vulnerabilities :filters="filters" />
</security-dashboard-layout> </security-dashboard-layout>
</div> </div>
</template> </template>
...@@ -13,11 +13,8 @@ export default { ...@@ -13,11 +13,8 @@ export default {
GlIntersectionObserver, GlIntersectionObserver,
VulnerabilityList, VulnerabilityList,
}, },
inject: ['groupFullPath'],
props: { props: {
groupFullPath: {
type: String,
required: true,
},
filters: { filters: {
type: Object, type: Object,
required: false, required: false,
......
...@@ -25,9 +25,9 @@ export default { ...@@ -25,9 +25,9 @@ export default {
directives: { directives: {
GlTooltip: GlTooltipDirective, GlTooltip: GlTooltipDirective,
}, },
inject: ['groupFullPath'],
props: { props: {
query: { type: Object, required: true }, query: { type: Object, required: true },
groupFullPath: { type: String, required: false, default: undefined },
}, },
data() { data() {
return { return {
......
...@@ -32,6 +32,7 @@ export default { ...@@ -32,6 +32,7 @@ export default {
directives: { directives: {
'gl-tooltip': GlTooltipDirective, 'gl-tooltip': GlTooltipDirective,
}, },
inject: ['groupFullPath'],
props: { props: {
helpPagePath: { helpPagePath: {
type: String, type: String,
...@@ -42,11 +43,6 @@ export default { ...@@ -42,11 +43,6 @@ export default {
type: Object, type: Object,
required: true, required: true,
}, },
groupFullPath: {
type: String,
required: false,
default: undefined,
},
}, },
data() { data() {
return { return {
......
...@@ -18,12 +18,7 @@ export default { ...@@ -18,12 +18,7 @@ export default {
VulnerabilitySeverities, VulnerabilitySeverities,
VulnerabilityChart, VulnerabilityChart,
}, },
props: { inject: ['groupFullPath'],
groupFullPath: {
type: String,
required: true,
},
},
apollo: { apollo: {
projects: { projects: {
query: vulnerableProjectsQuery, query: vulnerableProjectsQuery,
...@@ -65,11 +60,8 @@ export default { ...@@ -65,11 +60,8 @@ export default {
<dashboard-not-configured /> <dashboard-not-configured />
</template> </template>
<template v-else-if="shouldShowCharts" #default> <template v-else-if="shouldShowCharts" #default>
<vulnerability-chart :query="vulnerabilityHistoryQuery" :group-full-path="groupFullPath" /> <vulnerability-chart :query="vulnerabilityHistoryQuery" />
<vulnerability-severities <vulnerability-severities :query="vulnerabilityGradesQuery" />
:query="vulnerabilityGradesQuery"
:group-full-path="groupFullPath"
/>
</template> </template>
<template v-else #loading> <template v-else #loading>
<gl-loading-icon size="lg" class="gl-mt-6" /> <gl-loading-icon size="lg" class="gl-mt-6" />
......
...@@ -61,6 +61,7 @@ export default (el, dashboardType) => { ...@@ -61,6 +61,7 @@ export default (el, dashboardType) => {
emptyStateSvgPath, emptyStateSvgPath,
notEnabledScannersHelpPath, notEnabledScannersHelpPath,
noPipelineRunScannersHelpPath, noPipelineRunScannersHelpPath,
groupFullPath,
securityConfigurationPath, securityConfigurationPath,
hasVulnerabilities: parseBoolean(hasVulnerabilities), hasVulnerabilities: parseBoolean(hasVulnerabilities),
scanners: scanners ? JSON.parse(scanners) : [], scanners: scanners ? JSON.parse(scanners) : [],
...@@ -92,7 +93,6 @@ export default (el, dashboardType) => { ...@@ -92,7 +93,6 @@ export default (el, dashboardType) => {
provide.autoFixMrsPath = autoFixMrsPath; provide.autoFixMrsPath = autoFixMrsPath;
} else if (dashboardType === DASHBOARD_TYPES.GROUP) { } else if (dashboardType === DASHBOARD_TYPES.GROUP) {
component = FirstClassGroupSecurityDashboard; component = FirstClassGroupSecurityDashboard;
props.groupFullPath = groupFullPath;
} else if (dashboardType === DASHBOARD_TYPES.INSTANCE) { } else if (dashboardType === DASHBOARD_TYPES.INSTANCE) {
provide.instanceDashboardSettingsPath = instanceDashboardSettingsPath; provide.instanceDashboardSettingsPath = instanceDashboardSettingsPath;
component = FirstClassInstanceSecurityDashboard; component = FirstClassInstanceSecurityDashboard;
......
...@@ -32,6 +32,7 @@ export default (el, dashboardType) => { ...@@ -32,6 +32,7 @@ export default (el, dashboardType) => {
const provide = { const provide = {
dashboardDocumentation: el.dataset.dashboardDocumentation, dashboardDocumentation: el.dataset.dashboardDocumentation,
emptyStateSvgPath: el.dataset.emptyStateSvgPath, emptyStateSvgPath: el.dataset.emptyStateSvgPath,
groupFullPath: el.dataset.groupFullPath,
securityConfigurationPath: el.dataset.securityConfigurationPath, securityConfigurationPath: el.dataset.securityConfigurationPath,
}; };
......
---
title: Use provide/inject for groupFullPath instead of props
merge_request: 56472
author:
type: other
...@@ -29,9 +29,9 @@ describe('First Class Group Dashboard Component', () => { ...@@ -29,9 +29,9 @@ describe('First Class Group Dashboard Component', () => {
propsData: { propsData: {
dashboardDocumentation, dashboardDocumentation,
emptyStateSvgPath, emptyStateSvgPath,
groupFullPath,
vulnerabilitiesExportEndpoint, vulnerabilitiesExportEndpoint,
}, },
provide: { groupFullPath },
data, data,
stubs: { stubs: {
SecurityDashboardLayout, SecurityDashboardLayout,
...@@ -66,7 +66,6 @@ describe('First Class Group Dashboard Component', () => { ...@@ -66,7 +66,6 @@ describe('First Class Group Dashboard Component', () => {
it('should render correctly', () => { it('should render correctly', () => {
expect(findGroupVulnerabilities().props()).toEqual({ expect(findGroupVulnerabilities().props()).toEqual({
groupFullPath,
filters: {}, filters: {},
}); });
}); });
......
...@@ -24,15 +24,13 @@ describe('First Class Group Dashboard Vulnerabilities Component', () => { ...@@ -24,15 +24,13 @@ describe('First Class Group Dashboard Vulnerabilities Component', () => {
const createWrapper = ({ $apollo = apolloMock, stubs } = {}) => { const createWrapper = ({ $apollo = apolloMock, stubs } = {}) => {
return shallowMount(FirstClassGroupVulnerabilities, { return shallowMount(FirstClassGroupVulnerabilities, {
propsData: {
groupFullPath,
},
stubs, stubs,
mocks: { mocks: {
$apollo, $apollo,
fetchNextPage: () => {}, fetchNextPage: () => {},
}, },
provide: { provide: {
groupFullPath,
hasVulnerabilities: true, hasVulnerabilities: true,
hasJiraVulnerabilitiesIntegrationEnabled: false, hasJiraVulnerabilitiesIntegrationEnabled: false,
}, },
......
...@@ -21,10 +21,11 @@ describe('First class vulnerability chart component', () => { ...@@ -21,10 +21,11 @@ describe('First class vulnerability chart component', () => {
const findActiveChartButton = () => findChartButtons().find('.selected'); const findActiveChartButton = () => findChartButtons().find('.selected');
const find90DaysChartButton = () => findChartButtons().find('[data-days="90"]'); const find90DaysChartButton = () => findChartButtons().find('[data-days="90"]');
const createComponent = ({ $apollo, propsData, stubs, data } = {}) => { const createComponent = ({ $apollo, propsData, stubs, data, provide } = {}) => {
const instance = shallowMount(VulnerabilityChart, { const instance = shallowMount(VulnerabilityChart, {
$apollo, $apollo,
propsData: { query: {}, ...propsData }, propsData: { query: {}, ...propsData },
provide: { groupFullPath: undefined, ...provide },
stubs: { stubs: {
...stubChildren(VulnerabilityChart), ...stubChildren(VulnerabilityChart),
...stubs, ...stubs,
...@@ -84,7 +85,7 @@ describe('First class vulnerability chart component', () => { ...@@ -84,7 +85,7 @@ describe('First class vulnerability chart component', () => {
describe('when loading the history chart for group level dashboard', () => { describe('when loading the history chart for group level dashboard', () => {
beforeEach(() => { beforeEach(() => {
wrapper = createComponent({ wrapper = createComponent({
propsData: { groupFullPath: 'gitlab-org' }, provide: { groupFullPath: 'gitlab-org' },
$apollo: { $apollo: {
queries: { vulnerabilitiesHistory: { group: responseData } }, queries: { vulnerabilitiesHistory: { group: responseData } },
}, },
......
...@@ -33,7 +33,7 @@ describe('Vulnerability Severity component', () => { ...@@ -33,7 +33,7 @@ describe('Vulnerability Severity component', () => {
return createMockApollo([...queries]); return createMockApollo([...queries]);
}; };
const createComponent = ({ propsData, data, apolloProvider }) => { const createComponent = ({ propsData, data, apolloProvider, provide }) => {
return shallowMount(VulnerabilitySeverity, { return shallowMount(VulnerabilitySeverity, {
localVue, localVue,
apolloProvider, apolloProvider,
...@@ -42,6 +42,7 @@ describe('Vulnerability Severity component', () => { ...@@ -42,6 +42,7 @@ describe('Vulnerability Severity component', () => {
helpPagePath, helpPagePath,
...propsData, ...propsData,
}, },
provide: { groupFullPath: undefined, ...provide },
stubs: { stubs: {
Accordion, Accordion,
AccordionItem, AccordionItem,
...@@ -69,7 +70,8 @@ describe('Vulnerability Severity component', () => { ...@@ -69,7 +70,8 @@ describe('Vulnerability Severity component', () => {
]); ]);
wrapper = createComponent({ wrapper = createComponent({
propsData: { groupFullPath: 'gitlab-org', query: groupVulnerabilityGradesQuery }, propsData: { query: groupVulnerabilityGradesQuery },
provide: { groupFullPath: 'gitlab-org' },
apolloProvider, apolloProvider,
}); });
......
...@@ -41,7 +41,7 @@ describe('Group Security Charts component', () => { ...@@ -41,7 +41,7 @@ describe('Group Security Charts component', () => {
}, },
}, },
}, },
propsData: { groupFullPath }, provide: { groupFullPath },
stubs: { stubs: {
SecurityChartsLayout, SecurityChartsLayout,
}, },
...@@ -100,11 +100,10 @@ describe('Group Security Charts component', () => { ...@@ -100,11 +100,10 @@ describe('Group Security Charts component', () => {
expect(dashboardNotConfigured.exists()).toBe(false); expect(dashboardNotConfigured.exists()).toBe(false);
expect(loadingIcon.exists()).toBe(false); expect(loadingIcon.exists()).toBe(false);
expect(vulnerabilityChart.exists()).toBe(true); expect(vulnerabilityChart.exists()).toBe(true);
expect(vulnerabilityChart.props()).toEqual({ query: vulnerabilityHistoryQuery, groupFullPath }); expect(vulnerabilityChart.props()).toEqual({ query: vulnerabilityHistoryQuery });
expect(vulnerabilitySeverities.exists()).toBe(true); expect(vulnerabilitySeverities.exists()).toBe(true);
expect(vulnerabilitySeverities.props()).toEqual({ expect(vulnerabilitySeverities.props()).toEqual({
query: vulnerabilityGradesQuery, query: vulnerabilityGradesQuery,
groupFullPath,
helpPagePath: '', helpPagePath: '',
}); });
}); });
......
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