Commit 41b2240a authored by Alexander Turinske's avatar Alexander Turinske

Show count of extra identifiers in project dash

- on the project security dashboard, when there is more than one
  identifier, show a count of extra identifiers in the identifier column
parent bc46e4d5
<script>
import { difference } from 'lodash';
import { s__, __, sprintf } from '~/locale';
import { GlFormCheckbox, GlLink, GlSkeletonLoading, GlTable } from '@gitlab/ui';
import { GlFormCheckbox, GlLink, GlSkeletonLoading, GlSprintf, GlTable } from '@gitlab/ui';
import LocalStorageSync from '~/vue_shared/components/local_storage_sync.vue';
import RemediatedBadge from 'ee/vulnerabilities/components/remediated_badge.vue';
import FiltersProducedNoResults from 'ee/security_dashboard/components/empty_states/filters_produced_no_results.vue';
......@@ -25,6 +25,7 @@ export default {
GlFormCheckbox,
GlLink,
GlSkeletonLoading,
GlSprintf,
GlTable,
IssueLink,
LocalStorageSync,
......@@ -192,6 +193,9 @@ export default {
deselectAllVulnerabilities() {
this.selectedVulnerabilities = {};
},
extraIdentifierCount(identifiers) {
return identifiers?.length - 1;
},
primaryIdentifier(identifiers) {
return getPrimaryIdentifier(identifiers, 'externalType');
},
......@@ -330,9 +334,21 @@ export default {
</template>
<template #cell(identifier)="{ item }">
<span data-testid="vulnerability-identifier">
<div data-testid="vulnerability-identifier">
{{ primaryIdentifier(item.identifiers) }}
</span>
</div>
<div
v-if="extraIdentifierCount(item.identifiers)"
data-testid="vulnerability-more-identifiers"
class="gl-text-gray-500"
>
<span>+</span>
<gl-sprintf :message="__('%{count} more')">
<template #count>
{{ extraIdentifierCount(item.identifiers) }}
</template>
</gl-sprintf>
</div>
</template>
<template #cell(reportType)="{ item }">
......
---
title: Show count of extra identifiers in project dashboard
merge_request: 37256
author:
type: changed
......@@ -163,9 +163,12 @@ describe('Vulnerability list component', () => {
expect(cellText).not.toContain('(line: ');
});
it('should not display the vulnerability identifier', () => {
const cell = findDataCell('vulnerability-identifier');
expect(cell.exists()).toBe(false);
it('should not display the vulnerability identifier cell', () => {
const identifier = findDataCell('vulnerability-identifier');
expect(identifier.exists()).toBe(false);
const extraIdentifierCount = findDataCell('vulnerability-more-identifiers');
expect(extraIdentifierCount.exists()).toBe(false);
});
it('should not display the vulnerability report type', () => {
......@@ -208,11 +211,16 @@ describe('Vulnerability list component', () => {
expect(cellText).toEqual(location.file);
});
it('should correctly render the identifier', () => {
const cells = findDataCells('vulnerability-identifier');
it('should correctly render the identifier cell', () => {
const identifiers = findDataCells('vulnerability-identifier');
const extraIdentifierCounts = findDataCells('vulnerability-more-identifiers');
const firstIdentifiers = newVulnerabilities[0].identifiers;
expect(identifiers.at(0).text()).toBe(firstIdentifiers[0].name);
expect(extraIdentifierCounts.at(0).text()).toContain(firstIdentifiers.length - 1);
expect(cells.at(0).text()).toBe(newVulnerabilities[0].identifiers[0].name);
expect(cells.at(1).text()).toBe(newVulnerabilities[1].identifiers[0].name);
expect(identifiers.at(1).text()).toBe(newVulnerabilities[1].identifiers[0].name);
expect(extraIdentifierCounts.length).toBe(1);
});
it('should display the vulnerability report type', () => {
......
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