Commit 41a3dd23 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Merge branch '241757-Hide-Create-Issue-When-Tracker-Disabled' into 'master'

Hide "Create Issue" On Vulnerability Page When Issues Are Disabled

See merge request gitlab-org/gitlab!43725
parents a33572f8 1664c740
...@@ -59,6 +59,9 @@ export default { ...@@ -59,6 +59,9 @@ export default {
isIssueAlreadyCreated() { isIssueAlreadyCreated() {
return Boolean(this.state.relatedIssues.find(i => i.lockIssueRemoval)); return Boolean(this.state.relatedIssues.find(i => i.lockIssueRemoval));
}, },
canCreateIssue() {
return !this.isIssueAlreadyCreated && !this.isFetching && Boolean(this.createIssueUrl);
},
}, },
inject: { inject: {
vulnerabilityId: { vulnerabilityId: {
...@@ -261,7 +264,7 @@ export default { ...@@ -261,7 +264,7 @@ export default {
<template #headerText> <template #headerText>
{{ $options.i18n.relatedIssues }} {{ $options.i18n.relatedIssues }}
</template> </template>
<template v-if="!isIssueAlreadyCreated && !isFetching" #headerActions> <template v-if="canCreateIssue" #headerActions>
<gl-button <gl-button
ref="createIssue" ref="createIssue"
variant="success" variant="success"
......
---
title: Hide "Create Issue" On Vulnerability Page When Issues Are Disabled
merge_request: 43725
author: Kev @KevSlashNull
type: fixed
...@@ -33,7 +33,7 @@ describe('Vulnerability related issues component', () => { ...@@ -33,7 +33,7 @@ describe('Vulnerability related issues component', () => {
const issue1 = { id: 3, vulnerabilityLinkId: 987 }; const issue1 = { id: 3, vulnerabilityLinkId: 987 };
const issue2 = { id: 25, vulnerabilityLinkId: 876 }; const issue2 = { id: 25, vulnerabilityLinkId: 876 };
const createWrapper = async (data = {}, opts) => { const createWrapper = async (data = {}, provide = {}, opts) => {
wrapper = shallowMount(RelatedIssues, { wrapper = shallowMount(RelatedIssues, {
propsData, propsData,
data: () => data, data: () => data,
...@@ -44,6 +44,7 @@ describe('Vulnerability related issues component', () => { ...@@ -44,6 +44,7 @@ describe('Vulnerability related issues component', () => {
reportType, reportType,
issueTrackingHelpPath, issueTrackingHelpPath,
permissionsHelpPath, permissionsHelpPath,
...provide,
}, },
...opts, ...opts,
}); });
...@@ -270,6 +271,7 @@ describe('Vulnerability related issues component', () => { ...@@ -270,6 +271,7 @@ describe('Vulnerability related issues component', () => {
isFetching: false, isFetching: false,
state: { relatedIssues: [issue1, { ...issue2, vulnerabilityLinkType: 'created' }] }, state: { relatedIssues: [issue1, { ...issue2, vulnerabilityLinkType: 'created' }] },
}, },
{},
{ stubs: { RelatedIssuesBlock } }, { stubs: { RelatedIssuesBlock } },
); );
}); });
...@@ -289,7 +291,7 @@ describe('Vulnerability related issues component', () => { ...@@ -289,7 +291,7 @@ describe('Vulnerability related issues component', () => {
beforeEach(async () => { beforeEach(async () => {
mockAxios.onGet(propsData.endpoint).replyOnce(httpStatusCodes.OK, [issue1, issue2]); mockAxios.onGet(propsData.endpoint).replyOnce(httpStatusCodes.OK, [issue1, issue2]);
createWrapper({}, { stubs: { RelatedIssuesBlock } }); createWrapper({}, {}, { stubs: { RelatedIssuesBlock } });
await axios.waitForAll(); await axios.waitForAll();
}); });
...@@ -327,4 +329,17 @@ describe('Vulnerability related issues component', () => { ...@@ -327,4 +329,17 @@ describe('Vulnerability related issues component', () => {
expect(findAlert().exists()).toBe(false); expect(findAlert().exists()).toBe(false);
}); });
}); });
describe('when project issue tracking is disabled', () => {
it('hides the "Create Issue" button', () => {
createWrapper(
{},
{
createIssueUrl: undefined,
},
);
expect(findCreateIssueButton().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