diff options
author | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 13:34:23 -0600 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 13:34:23 -0600 |
commit | 6438df3a1e0fb944485cebf07976160184697d72 (patch) | |
tree | 00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /app/assets/javascripts/vue_shared/security_reports/utils.js | |
parent | 42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff) | |
download | gitlab-ce-6438df3a1e0fb944485cebf07976160184697d72.tar.gz |
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'app/assets/javascripts/vue_shared/security_reports/utils.js')
-rw-r--r-- | app/assets/javascripts/vue_shared/security_reports/utils.js | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/app/assets/javascripts/vue_shared/security_reports/utils.js b/app/assets/javascripts/vue_shared/security_reports/utils.js index 827a87f9aaf..ad819bf7081 100644 --- a/app/assets/javascripts/vue_shared/security_reports/utils.js +++ b/app/assets/javascripts/vue_shared/security_reports/utils.js @@ -1,4 +1,18 @@ -import { securityReportTypeEnumToReportType } from './constants'; +import { capitalize } from 'lodash'; +import { + securityReportTypeEnumToReportType, + REPORT_FILE_TYPES, +} from 'ee_else_ce/vue_shared/security_reports/constants'; + +const addReportTypeIfExists = (acc, reportTypes, reportType, getName, downloadPath) => { + if (reportTypes && reportTypes.includes(reportType)) { + acc.push({ + reportType, + name: getName(reportType), + path: downloadPath, + }); + } +}; export const extractSecurityReportArtifacts = (reportTypes, data) => { const jobs = data.project?.mergeRequest?.headPipeline?.jobs?.nodes ?? []; @@ -7,14 +21,21 @@ export const extractSecurityReportArtifacts = (reportTypes, data) => { const artifacts = job.artifacts?.nodes ?? []; artifacts.forEach(({ downloadPath, fileType }) => { - const reportType = securityReportTypeEnumToReportType[fileType]; - if (reportType && reportTypes.includes(reportType)) { - acc.push({ - name: job.name, - reportType, - path: downloadPath, - }); - } + addReportTypeIfExists( + acc, + reportTypes, + securityReportTypeEnumToReportType[fileType], + () => job.name, + downloadPath, + ); + + addReportTypeIfExists( + acc, + reportTypes, + REPORT_FILE_TYPES[fileType], + (reportType) => `${job.name} ${capitalize(reportType)}`, + downloadPath, + ); }); return acc; |