Commit c804992d authored by Miguel Rincon's avatar Miguel Rincon

Merge branch '300753-use-inject-instead-of-props' into 'master'

Update injected props

See merge request gitlab-org/gitlab!61136
parents a8022831 d74a51e7
...@@ -25,7 +25,7 @@ export default { ...@@ -25,7 +25,7 @@ export default {
variables() { variables() {
return { return {
fullPath: this.projectFullPath, fullPath: this.projectFullPath,
pipelineIid: this.pipelineIid, pipelineIid: this.pipeline.iid,
}; };
}, },
update(data) { update(data) {
...@@ -34,31 +34,12 @@ export default { ...@@ -34,31 +34,12 @@ export default {
}, },
}, },
}, },
inject: ['projectFullPath', 'pipeline', 'dashboardDocumentation', 'emptyStateSvgPath'],
props: { props: {
dashboardDocumentation: {
type: String,
required: true,
},
emptyStateSvgPath: {
type: String,
required: true,
},
pipelineId: {
type: Number,
required: true,
},
pipelineIid: {
type: Number,
required: true,
},
projectId: { projectId: {
type: Number, type: Number,
required: true, required: true,
}, },
sourceBranch: {
type: String,
required: true,
},
vulnerabilitiesEndpoint: { vulnerabilitiesEndpoint: {
type: String, type: String,
required: true, required: true,
...@@ -67,16 +48,6 @@ export default { ...@@ -67,16 +48,6 @@ export default {
type: Object, type: Object,
required: true, required: true,
}, },
projectFullPath: {
type: String,
required: false,
default: '',
},
pipelineJobsPath: {
type: String,
required: false,
default: '',
},
}, },
computed: { computed: {
shouldShowGraphqlVulnerabilityReport() { shouldShowGraphqlVulnerabilityReport() {
...@@ -95,8 +66,8 @@ export default { ...@@ -95,8 +66,8 @@ export default {
}, },
}, },
created() { created() {
this.setSourceBranch(this.sourceBranch); this.setSourceBranch(this.pipeline.sourceBranch);
this.setPipelineJobsPath(this.pipelineJobsPath); this.setPipelineJobsPath(this.pipeline.jobsPath);
this.setProjectId(this.projectId); this.setProjectId(this.projectId);
}, },
methods: { methods: {
...@@ -117,7 +88,7 @@ export default { ...@@ -117,7 +88,7 @@ export default {
v-if="!shouldShowGraphqlVulnerabilityReport" v-if="!shouldShowGraphqlVulnerabilityReport"
:vulnerabilities-endpoint="vulnerabilitiesEndpoint" :vulnerabilities-endpoint="vulnerabilitiesEndpoint"
:lock-to-project="{ id: projectId }" :lock-to-project="{ id: projectId }"
:pipeline-id="pipelineId" :pipeline-id="pipeline.id"
:loading-error-illustrations="loadingErrorIllustrations" :loading-error-illustrations="loadingErrorIllustrations"
:security-report-summary="securityReportSummary" :security-report-summary="securityReportSummary"
> >
......
...@@ -39,20 +39,22 @@ export default () => { ...@@ -39,20 +39,22 @@ export default () => {
}), }),
provide: { provide: {
dashboardType: DASHBOARD_TYPES.PIPELINE, dashboardType: DASHBOARD_TYPES.PIPELINE,
projectFullPath,
dashboardDocumentation,
emptyStateSvgPath,
pipeline: {
id: parseInt(pipelineId, 10),
iid: parseInt(pipelineIid, 10),
jobsPath: pipelineJobsPath,
sourceBranch,
},
}, },
render(createElement) { render(createElement) {
return createElement(PipelineSecurityDashboard, { return createElement(PipelineSecurityDashboard, {
props: { props: {
projectId: parseInt(projectId, 10), projectId: parseInt(projectId, 10),
pipelineId: parseInt(pipelineId, 10),
pipelineIid: parseInt(pipelineIid, 10),
vulnerabilitiesEndpoint, vulnerabilitiesEndpoint,
sourceBranch,
dashboardDocumentation,
emptyStateSvgPath,
loadingErrorIllustrations, loadingErrorIllustrations,
projectFullPath,
pipelineJobsPath,
}, },
}); });
}, },
......
...@@ -15,6 +15,7 @@ const pipelineId = 1234; ...@@ -15,6 +15,7 @@ const pipelineId = 1234;
const pipelineIid = 4321; const pipelineIid = 4321;
const projectId = 5678; const projectId = 5678;
const sourceBranch = 'feature-branch-1'; const sourceBranch = 'feature-branch-1';
const jobsPath = 'my-jobs-path';
const vulnerabilitiesEndpoint = '/vulnerabilities'; const vulnerabilitiesEndpoint = '/vulnerabilities';
const loadingErrorIllustrations = { const loadingErrorIllustrations = {
401: '/401.svg', 401: '/401.svg',
...@@ -28,7 +29,7 @@ describe('Pipeline Security Dashboard component', () => { ...@@ -28,7 +29,7 @@ describe('Pipeline Security Dashboard component', () => {
const findSecurityDashboard = () => wrapper.findComponent(SecurityDashboard); const findSecurityDashboard = () => wrapper.findComponent(SecurityDashboard);
const findVulnerabilityReport = () => wrapper.findComponent(VulnerabilityReport); const findVulnerabilityReport = () => wrapper.findComponent(VulnerabilityReport);
const factory = (options) => { const factory = ({ data, stubs, provide } = {}) => {
store = new Vuex.Store({ store = new Vuex.Store({
modules: { modules: {
vulnerabilities: { vulnerabilities: {
...@@ -51,21 +52,28 @@ describe('Pipeline Security Dashboard component', () => { ...@@ -51,21 +52,28 @@ describe('Pipeline Security Dashboard component', () => {
wrapper = shallowMount(PipelineSecurityDashboard, { wrapper = shallowMount(PipelineSecurityDashboard, {
localVue, localVue,
store, store,
propsData: { provide: {
dashboardDocumentation, projectFullPath: 'my-path',
emptyStateSvgPath, emptyStateSvgPath,
pipelineId, dashboardDocumentation,
pipelineIid, pipeline: {
id: pipelineId,
iid: pipelineIid,
jobsPath,
sourceBranch,
},
...provide,
},
propsData: {
projectId, projectId,
sourceBranch,
vulnerabilitiesEndpoint, vulnerabilitiesEndpoint,
loadingErrorIllustrations, loadingErrorIllustrations,
}, },
...options, stubs,
data() { data() {
return { return {
securityReportSummary: {}, securityReportSummary: {},
...options?.data, ...data,
}; };
}, },
}); });
...@@ -83,7 +91,7 @@ describe('Pipeline Security Dashboard component', () => { ...@@ -83,7 +91,7 @@ describe('Pipeline Security Dashboard component', () => {
it('dispatches the expected actions', () => { it('dispatches the expected actions', () => {
expect(store.dispatch.mock.calls).toEqual([ expect(store.dispatch.mock.calls).toEqual([
['vulnerabilities/setSourceBranch', sourceBranch], ['vulnerabilities/setSourceBranch', sourceBranch],
['pipelineJobs/setPipelineJobsPath', ''], ['pipelineJobs/setPipelineJobsPath', jobsPath],
['pipelineJobs/setProjectId', 5678], ['pipelineJobs/setProjectId', 5678],
]); ]);
}); });
......
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