Remove securityReportsTypes constant

Populate the MR widget store with convertObjectPropsToCamelCase and
remove securityReportsTypes constant
parent 6e217460
import { securityReportsTypes } from 'ee/vue_shared/security_reports/constants';
import CEMergeRequestStore from '~/vue_merge_request_widget/stores/mr_widget_store'; import CEMergeRequestStore from '~/vue_merge_request_widget/stores/mr_widget_store';
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
import { mapApprovalsResponse, mapApprovalRulesResponse } from '../mappers'; import { mapApprovalsResponse, mapApprovalRulesResponse } from '../mappers';
import CodeQualityComparisonWorker from '../workers/code_quality_comparison_worker'; import CodeQualityComparisonWorker from '../workers/code_quality_comparison_worker';
...@@ -39,14 +39,7 @@ export default class MergeRequestStore extends CEMergeRequestStore { ...@@ -39,14 +39,7 @@ export default class MergeRequestStore extends CEMergeRequestStore {
this.licenseManagement = data.license_management; this.licenseManagement = data.license_management;
this.metricsReportsPath = data.metrics_reports_path; this.metricsReportsPath = data.metrics_reports_path;
const enabledReports = data.enabled_reports || {}; this.enabledSecurityReports = convertObjectPropsToCamelCase(data.enabled_reports);
this.enabledSecurityReports = {
[securityReportsTypes.SAST]: Boolean(enabledReports.sast),
[securityReportsTypes.CONTAINER_SCANNING]: Boolean(enabledReports.container_scanning),
[securityReportsTypes.DAST]: Boolean(enabledReports.dast),
[securityReportsTypes.DEPENDENCY_SCANNING]: Boolean(enabledReports.dependency_scanning),
[securityReportsTypes.LICENSE_MANAGEMENT]: Boolean(enabledReports.license_management),
};
this.blockingMergeRequests = data.blocking_merge_requests; this.blockingMergeRequests = data.blocking_merge_requests;
......
/* eslint-disable import/prefer-default-export */
export const securityReportsTypes = {
SAST: 'sast',
CONTAINER_SCANNING: 'containerScanning',
DAST: 'dast',
DEPENDENCY_SCANNING: 'dependencyScanning',
LICENSE_MANAGEMENT: 'licenseManagement',
};
...@@ -5,7 +5,6 @@ import ReportSection from '~/reports/components/report_section.vue'; ...@@ -5,7 +5,6 @@ import ReportSection from '~/reports/components/report_section.vue';
import SummaryRow from '~/reports/components/summary_row.vue'; import SummaryRow from '~/reports/components/summary_row.vue';
import IssuesList from '~/reports/components/issues_list.vue'; import IssuesList from '~/reports/components/issues_list.vue';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import { securityReportsTypes } from './constants';
import IssueModal from './components/modal.vue'; import IssueModal from './components/modal.vue';
import securityReportsMixin from './mixins/security_report_mixin'; import securityReportsMixin from './mixins/security_report_mixin';
import createStore from './store'; import createStore from './store';
...@@ -175,7 +174,7 @@ export default { ...@@ -175,7 +174,7 @@ export default {
return `${this.pipelinePath}/security`; return `${this.pipelinePath}/security`;
}, },
hasContainerScanningReports() { hasContainerScanningReports() {
const type = securityReportsTypes.CONTAINER_SCANNING; const type = 'containerScanning';
if (this.isMergeRequestReportApiEnabled(type)) { if (this.isMergeRequestReportApiEnabled(type)) {
return this.enabledReports[type]; return this.enabledReports[type];
} }
...@@ -183,13 +182,13 @@ export default { ...@@ -183,13 +182,13 @@ export default {
return Boolean(head || diffEndpoint); return Boolean(head || diffEndpoint);
}, },
hasDependencyScanningReports() { hasDependencyScanningReports() {
return this.hasReportsType(securityReportsTypes.DEPENDENCY_SCANNING); return this.hasReportsType('dependencyScanning');
}, },
hasDastReports() { hasDastReports() {
return this.hasReportsType(securityReportsTypes.DAST); return this.hasReportsType('dast');
}, },
hasSastReports() { hasSastReports() {
return this.hasReportsType(securityReportsTypes.SAST); return this.hasReportsType('sast');
}, },
}, },
......
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