Commit cd670e41 authored by Alexander Turinske's avatar Alexander Turinske Committed by Phil Hughes

Add extra identifier count to pipeline sec tab

- on the pipeline security tab, if there is more than one identifier,
  add a section that says how many more identifiers there are
- update tests
parent df588c34
<script> <script>
import { mapActions, mapState } from 'vuex'; import { mapActions, mapState } from 'vuex';
import { GlDeprecatedButton, GlFormCheckbox, GlSkeletonLoading } from '@gitlab/ui'; import { GlDeprecatedButton, GlFormCheckbox, GlSkeletonLoading, GlSprintf } from '@gitlab/ui';
import SeverityBadge from 'ee/vue_shared/security_reports/components/severity_badge.vue'; import SeverityBadge from 'ee/vue_shared/security_reports/components/severity_badge.vue';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import VulnerabilityActionButtons from './vulnerability_action_buttons.vue'; import VulnerabilityActionButtons from './vulnerability_action_buttons.vue';
...@@ -15,6 +15,7 @@ export default { ...@@ -15,6 +15,7 @@ export default {
GlDeprecatedButton, GlDeprecatedButton,
GlFormCheckbox, GlFormCheckbox,
GlSkeletonLoading, GlSkeletonLoading,
GlSprintf,
Icon, Icon,
SeverityBadge, SeverityBadge,
VulnerabilityActionButtons, VulnerabilityActionButtons,
...@@ -64,9 +65,16 @@ export default { ...@@ -64,9 +65,16 @@ export default {
const path = this.vulnerability.create_vulnerability_feedback_issue_path; const path = this.vulnerability.create_vulnerability_feedback_issue_path;
return Boolean(path) && !this.hasIssue; return Boolean(path) && !this.hasIssue;
}, },
extraIdentifierCount() {
const { identifiers } = this.vulnerability;
return identifiers?.length - 1;
},
isSelected() { isSelected() {
return Boolean(this.selectedVulnerabilities[this.vulnerability.id]); return Boolean(this.selectedVulnerabilities[this.vulnerability.id]);
}, },
shouldShowExtraIdentifierCount() {
return this.extraIdentifierCount > 0;
},
useConvertReportType() { useConvertReportType() {
return convertReportType(this.vulnerability.report_type); return convertReportType(this.vulnerability.report_type);
}, },
...@@ -148,11 +156,17 @@ export default { ...@@ -148,11 +156,17 @@ export default {
<div class="table-section gl-white-space-normal section-15"> <div class="table-section gl-white-space-normal section-15">
<div class="table-mobile-header" role="rowheader">{{ s__('Reports|Identifier') }}</div> <div class="table-mobile-header" role="rowheader">{{ s__('Reports|Identifier') }}</div>
<div <div class="table-mobile-content">
class="table-mobile-content gl-text-overflow-ellipsis gl-overflow-hidden" <div class="gl-text-overflow-ellipsis gl-overflow-hidden" :title="vulnerabilityIdentifier">
:title="vulnerabilityIdentifier" {{ vulnerabilityIdentifier }}
> </div>
{{ vulnerabilityIdentifier }} <div v-if="shouldShowExtraIdentifierCount" class="gl-text-gray-500">
<gl-sprintf :message="__('+ %{count} more')">
<template #count>
{{ extraIdentifierCount }}
</template>
</gl-sprintf>
</div>
</div> </div>
</div> </div>
......
---
title: Add extra identifier count to pipeline sec tab
merge_request: 37654
author:
type: changed
...@@ -5,6 +5,7 @@ import createStore from 'ee/security_dashboard/store'; ...@@ -5,6 +5,7 @@ import createStore from 'ee/security_dashboard/store';
import { mount, shallowMount, createLocalVue } from '@vue/test-utils'; import { mount, shallowMount, createLocalVue } from '@vue/test-utils';
import mockDataVulnerabilities from '../store/modules/vulnerabilities/data/mock_data_vulnerabilities'; import mockDataVulnerabilities from '../store/modules/vulnerabilities/data/mock_data_vulnerabilities';
import { DASHBOARD_TYPES } from 'ee/security_dashboard/store/constants'; import { DASHBOARD_TYPES } from 'ee/security_dashboard/store/constants';
import { trimText } from 'helpers/text_helper';
const localVue = createLocalVue(); const localVue = createLocalVue();
localVue.use(Vuex); localVue.use(Vuex);
...@@ -82,8 +83,10 @@ describe('Security Dashboard Table Row', () => { ...@@ -82,8 +83,10 @@ describe('Security Dashboard Table Row', () => {
).toContain(vulnerability.severity); ).toContain(vulnerability.severity);
}); });
it('should render the identifier name', () => { it('should render the identifier cell', () => {
expect(findContent(2).text()).toContain(vulnerability.identifiers[0].name); const { identifiers } = vulnerability;
expect(findContent(2).text()).toContain(identifiers[0].name);
expect(trimText(findContent(2).text())).toContain(`${identifiers.length - 1} more`);
}); });
it('should render the report type', () => { it('should render the report type', () => {
...@@ -239,4 +242,17 @@ describe('Security Dashboard Table Row', () => { ...@@ -239,4 +242,17 @@ describe('Security Dashboard Table Row', () => {
}); });
}); });
}); });
describe('with less than two identifiers', () => {
const vulnerability = mockDataVulnerabilities[1];
beforeEach(() => {
createComponent(shallowMount, { props: { vulnerability } });
});
it('should render the identifier cell', () => {
const { identifiers } = vulnerability;
expect(findContent(2).text()).toBe(identifiers[0].name);
});
});
}); });
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