Commit 03ec1af6 authored by Savas Vedova's avatar Savas Vedova

Do not display submit vulnerability to guests

When a user has no access to admin vulnerabilities do not
display the submit vulnerability button in the vulnerability report.
parent a3a63d3f
......@@ -19,10 +19,17 @@ export default {
newVulnerabilityPath: {
default: '',
},
canAdminVulnerability: {
default: false,
},
},
computed: {
shouldShowNewVulnerabilityButton() {
return this.glFeatures.newVulnerabilityForm && Boolean(this.newVulnerabilityPath);
return (
this.glFeatures.newVulnerabilityForm &&
Boolean(this.newVulnerabilityPath) &&
this.canAdminVulnerability
);
},
},
i18n: {
......
......@@ -20,6 +20,7 @@ describe('Vulnerability report header component', () => {
it('shows the submit vulnerability button when new vulnerability path is defined', () => {
createWrapper({
provide: {
canAdminVulnerability: true,
newVulnerabilityPath: '/vulnerabilities/new',
glFeatures: { newVulnerabilityForm: true },
},
......@@ -33,6 +34,19 @@ describe('Vulnerability report header component', () => {
it('does not show the submit vulnerability button when new vulnerability path is not defined', () => {
createWrapper({
provide: {
canAdminVulnerability: true,
glFeatures: { newVulnerabilityForm: true },
},
});
expect(wrapper.findByText('Submit vulnerability').exists()).toBe(false);
});
it('does not should the submit vulnerability button when user cannot admin vulnerabilities', () => {
createWrapper({
provide: {
canAdminVulnerability: false,
newVulnerabilityPath: '/vulnerabilities/new',
glFeatures: { newVulnerabilityForm: true },
},
});
......@@ -43,6 +57,7 @@ describe('Vulnerability report header component', () => {
it('does not show the submit vulnerability button when the feature flag is not enabled', () => {
createWrapper({
provide: {
canAdminVulnerability: true,
newVulnerabilityPath: '/vulnerabilities/new',
},
});
......
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