Commit 9f8db2e4 authored by Vitali Tatarintev's avatar Vitali Tatarintev

Merge branch '300994-auditor-user-can-bulk-select' into 'master'

Do not display bulk selection when user is auditor

See merge request gitlab-org/gitlab!62685
parents a61676b6 bd27eb02
...@@ -51,6 +51,9 @@ export default { ...@@ -51,6 +51,9 @@ export default {
hasJiraVulnerabilitiesIntegrationEnabled: { hasJiraVulnerabilitiesIntegrationEnabled: {
default: false, default: false,
}, },
canAdminVulnerability: {
default: false,
},
dashboardType: {}, dashboardType: {},
}, },
...@@ -60,11 +63,6 @@ export default { ...@@ -60,11 +63,6 @@ export default {
required: false, required: false,
default: () => ({}), default: () => ({}),
}, },
shouldShowSelection: {
type: Boolean,
required: false,
default: true,
},
vulnerabilities: { vulnerabilities: {
type: Array, type: Array,
required: true, required: true,
...@@ -109,7 +107,7 @@ export default { ...@@ -109,7 +107,7 @@ export default {
return Object.keys(this.selectedVulnerabilities).length; return Object.keys(this.selectedVulnerabilities).length;
}, },
shouldShowSelectionSummary() { shouldShowSelectionSummary() {
return this.shouldShowSelection && this.numOfSelectedVulnerabilities > 0; return this.canAdminVulnerability && this.numOfSelectedVulnerabilities > 0;
}, },
theadClass() { theadClass() {
return this.shouldShowSelectionSummary ? 'below-selection-summary' : ''; return this.shouldShowSelectionSummary ? 'below-selection-summary' : '';
...@@ -119,7 +117,7 @@ export default { ...@@ -119,7 +117,7 @@ export default {
{ {
key: 'checkbox', key: 'checkbox',
class: 'checkbox', class: 'checkbox',
skip: !this.shouldShowSelection, skip: !this.canAdminVulnerability,
}, },
{ {
key: 'detected', key: 'detected',
......
import Vue from 'vue'; import Vue from 'vue';
import { parseBoolean } from '~/lib/utils/common_utils';
import PipelineSecurityDashboard from './components/pipeline_security_dashboard.vue'; import PipelineSecurityDashboard from './components/pipeline_security_dashboard.vue';
import apolloProvider from './graphql/provider'; import apolloProvider from './graphql/provider';
import createDashboardStore from './store'; import createDashboardStore from './store';
...@@ -24,6 +25,7 @@ export default () => { ...@@ -24,6 +25,7 @@ export default () => {
emptyStateForbiddenSvgPath, emptyStateForbiddenSvgPath,
projectFullPath, projectFullPath,
pipelineJobsPath, pipelineJobsPath,
canAdminVulnerability,
} = el.dataset; } = el.dataset;
const loadingErrorIllustrations = { const loadingErrorIllustrations = {
...@@ -42,6 +44,7 @@ export default () => { ...@@ -42,6 +44,7 @@ export default () => {
projectFullPath, projectFullPath,
dashboardDocumentation, dashboardDocumentation,
emptyStateSvgPath, emptyStateSvgPath,
canAdminVulnerability: parseBoolean(canAdminVulnerability),
pipeline: { pipeline: {
id: parseInt(pipelineId, 10), id: parseInt(pipelineId, 10),
iid: parseInt(pipelineIid, 10), iid: parseInt(pipelineIid, 10),
......
...@@ -36,6 +36,7 @@ export default (el, dashboardType) => { ...@@ -36,6 +36,7 @@ export default (el, dashboardType) => {
hasJiraVulnerabilitiesIntegrationEnabled, hasJiraVulnerabilitiesIntegrationEnabled,
securityConfigurationPath, securityConfigurationPath,
surveyRequestSvgPath, surveyRequestSvgPath,
canAdminVulnerability,
} = el.dataset; } = el.dataset;
if (isUnavailable) { if (isUnavailable) {
...@@ -68,6 +69,7 @@ export default (el, dashboardType) => { ...@@ -68,6 +69,7 @@ export default (el, dashboardType) => {
projectFullPath, projectFullPath,
autoFixDocumentation, autoFixDocumentation,
autoFixMrsPath, autoFixMrsPath,
canAdminVulnerability: parseBoolean(canAdminVulnerability),
hasVulnerabilities: parseBoolean(hasVulnerabilities), hasVulnerabilities: parseBoolean(hasVulnerabilities),
scanners: scanners ? JSON.parse(scanners) : [], scanners: scanners ? JSON.parse(scanners) : [],
hasJiraVulnerabilitiesIntegrationEnabled: parseBoolean( hasJiraVulnerabilitiesIntegrationEnabled: parseBoolean(
......
...@@ -191,7 +191,8 @@ module EE ...@@ -191,7 +191,8 @@ module EE
security_dashboard_help_path: help_page_path('user/application_security/security_dashboard/index'), security_dashboard_help_path: help_page_path('user/application_security/security_dashboard/index'),
auto_fix_documentation: help_page_path('user/application_security/index', anchor: 'auto-fix-merge-requests'), auto_fix_documentation: help_page_path('user/application_security/index', anchor: 'auto-fix-merge-requests'),
auto_fix_mrs_path: project_merge_requests_path(@project, label_name: 'GitLab-auto-fix'), auto_fix_mrs_path: project_merge_requests_path(@project, label_name: 'GitLab-auto-fix'),
scanners: VulnerabilityScanners::ListService.new(project).execute.to_json scanners: VulnerabilityScanners::ListService.new(project).execute.to_json,
can_admin_vulnerability: can?(current_user, :admin_vulnerability, project).to_s
}.merge!(security_dashboard_pipeline_data(project)) }.merge!(security_dashboard_pipeline_data(project))
end end
end end
......
...@@ -20,7 +20,8 @@ ...@@ -20,7 +20,8 @@
vulnerability_exports_endpoint: vulnerability_exports_endpoint_path, vulnerability_exports_endpoint: vulnerability_exports_endpoint_path,
empty_state_unauthorized_svg_path: image_path('illustrations/user-not-logged-in.svg'), empty_state_unauthorized_svg_path: image_path('illustrations/user-not-logged-in.svg'),
empty_state_forbidden_svg_path: image_path('illustrations/lock_promotion.svg'), empty_state_forbidden_svg_path: image_path('illustrations/lock_promotion.svg'),
project_full_path: project.path_with_namespace } } project_full_path: project.path_with_namespace,
can_admin_vulnerability: can?(current_user, :admin_vulnerability, project).to_s } }
- if pipeline.expose_license_scanning_data? - if pipeline.expose_license_scanning_data?
#js-tab-licenses.tab-pane #js-tab-licenses.tab-pane
......
...@@ -114,7 +114,6 @@ describe('Group Security Dashboard Vulnerabilities Component', () => { ...@@ -114,7 +114,6 @@ describe('Group Security Dashboard Vulnerabilities Component', () => {
expect(findVulnerabilities().props()).toEqual({ expect(findVulnerabilities().props()).toEqual({
filters: {}, filters: {},
isLoading: false, isLoading: false,
shouldShowSelection: true,
shouldShowProjectNamespace: true, shouldShowProjectNamespace: true,
vulnerabilities, vulnerabilities,
}); });
......
...@@ -95,7 +95,6 @@ describe('Instance Security Dashboard Vulnerabilities Component', () => { ...@@ -95,7 +95,6 @@ describe('Instance Security Dashboard Vulnerabilities Component', () => {
expect(findVulnerabilities().props()).toEqual({ expect(findVulnerabilities().props()).toEqual({
filters: {}, filters: {},
isLoading: false, isLoading: false,
shouldShowSelection: true,
shouldShowProjectNamespace: true, shouldShowProjectNamespace: true,
vulnerabilities, vulnerabilities,
}); });
......
...@@ -35,6 +35,7 @@ describe('Vulnerability list component', () => { ...@@ -35,6 +35,7 @@ describe('Vulnerability list component', () => {
noPipelineRunScannersHelpPath: '#', noPipelineRunScannersHelpPath: '#',
hasVulnerabilities: true, hasVulnerabilities: true,
hasJiraVulnerabilitiesIntegrationEnabled: false, hasJiraVulnerabilitiesIntegrationEnabled: false,
canAdminVulnerability: true,
...provide, ...provide,
}), }),
}); });
...@@ -201,14 +202,17 @@ describe('Vulnerability list component', () => { ...@@ -201,14 +202,17 @@ describe('Vulnerability list component', () => {
); );
}); });
describe('when vulnerability selection is disabled', () => { describe('when user has no permission to admin vulnerabilities', () => {
beforeEach(() => { beforeEach(() => {
wrapper = createWrapper({ wrapper = createWrapper({
props: { vulnerabilities, shouldShowSelection: false }, props: { vulnerabilities },
provide: {
canAdminVulnerability: false,
},
}); });
}); });
it('should not show the checkboxes if shouldShowSelection is passed in', () => { it('should not show the checkboxes', () => {
expect(findDataCell('vulnerability-checkbox-all').exists()).toBe(false); expect(findDataCell('vulnerability-checkbox-all').exists()).toBe(false);
expect(findDataCell('vulnerability-checkbox').exists()).toBe(false); expect(findDataCell('vulnerability-checkbox').exists()).toBe(false);
}); });
......
...@@ -127,6 +127,7 @@ RSpec.describe ProjectsHelper do ...@@ -127,6 +127,7 @@ RSpec.describe ProjectsHelper do
group.add_owner(user) group.add_owner(user)
stub_licensed_features(jira_vulnerabilities_integration: true) stub_licensed_features(jira_vulnerabilities_integration: true)
allow(helper).to receive(:current_user).and_return(user) allow(helper).to receive(:current_user).and_return(user)
allow(helper).to receive(:can?).and_return(true)
end end
context 'project without vulnerabilities' do context 'project without vulnerabilities' do
...@@ -163,7 +164,8 @@ RSpec.describe ProjectsHelper do ...@@ -163,7 +164,8 @@ RSpec.describe ProjectsHelper do
no_pipeline_run_scanners_help_path: "/#{project.full_path}/-/pipelines/new", no_pipeline_run_scanners_help_path: "/#{project.full_path}/-/pipelines/new",
auto_fix_documentation: help_page_path('user/application_security/index', anchor: 'auto-fix-merge-requests'), auto_fix_documentation: help_page_path('user/application_security/index', anchor: 'auto-fix-merge-requests'),
auto_fix_mrs_path: end_with('/merge_requests?label_name=GitLab-auto-fix'), auto_fix_mrs_path: end_with('/merge_requests?label_name=GitLab-auto-fix'),
scanners: '[{"id":123,"vendor":"Security Vendor","report_type":"SAST"}]' scanners: '[{"id":123,"vendor":"Security Vendor","report_type":"SAST"}]',
can_admin_vulnerability: 'true'
} }
end end
......
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