Commit 4d816ba4 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Merge branch '230931-use-gl-truncate' into 'master'

Truncate long file paths

See merge request gitlab-org/gitlab!45254
parents 4d888545 26d750cc
...@@ -186,6 +186,7 @@ table { ...@@ -186,6 +186,7 @@ table {
.checkbox { .checkbox {
padding-left: $gl-spacing-scale-4; padding-left: $gl-spacing-scale-4;
padding-right: 0; padding-right: 0;
width: 1px;
+ td, + td,
+ th { + th {
...@@ -205,12 +206,20 @@ table { ...@@ -205,12 +206,20 @@ table {
width: 10%; width: 10%;
} }
.description {
max-width: 0;
}
.identifier { .identifier {
width: 16%; width: 16%;
} }
.scanner { .scanner {
width: 15%; width: 10%;
}
.activity {
width: 5%;
} }
} }
} }
...@@ -4,9 +4,10 @@ import { ...@@ -4,9 +4,10 @@ import {
GlFormCheckbox, GlFormCheckbox,
GlLink, GlLink,
GlSprintf, GlSprintf,
GlTable, GlTruncate,
GlSkeletonLoading, GlSkeletonLoading,
GlTooltipDirective, GlTooltipDirective,
GlTable,
} from '@gitlab/ui'; } from '@gitlab/ui';
import RemediatedBadge from 'ee/vulnerabilities/components/remediated_badge.vue'; import RemediatedBadge from 'ee/vulnerabilities/components/remediated_badge.vue';
import FiltersProducedNoResults from 'ee/security_dashboard/components/empty_states/filters_produced_no_results.vue'; import FiltersProducedNoResults from 'ee/security_dashboard/components/empty_states/filters_produced_no_results.vue';
...@@ -35,6 +36,7 @@ export default { ...@@ -35,6 +36,7 @@ export default {
GlSkeletonLoading, GlSkeletonLoading,
GlSprintf, GlSprintf,
GlTable, GlTable,
GlTruncate,
IssuesBadge, IssuesBadge,
LocalStorageSync, LocalStorageSync,
RemediatedBadge, RemediatedBadge,
...@@ -181,7 +183,8 @@ export default { ...@@ -181,7 +183,8 @@ export default {
{ {
key: 'activity', key: 'activity',
label: s__('Vulnerability|Activity'), label: s__('Vulnerability|Activity'),
thClass: 'gl-text-right', thClass: 'gl-text-right activity',
tdClass: 'activity',
}, },
]; ];
...@@ -373,7 +376,7 @@ export default { ...@@ -373,7 +376,7 @@ export default {
</template> </template>
<template #cell(severity)="{ item }"> <template #cell(severity)="{ item }">
<severity-badge class="js-severity gl-white-space-normal!" :severity="item.severity" /> <severity-badge class="js-severity" :severity="item.severity" />
</template> </template>
<template #cell(title)="{ item }"> <template #cell(title)="{ item }">
...@@ -399,7 +402,7 @@ export default { ...@@ -399,7 +402,7 @@ export default {
{{ item.project.nameWithNamespace }} {{ item.project.nameWithNamespace }}
</div> </div>
<div v-if="shouldShowVulnerabilityPath(item)" class="monospace"> <div v-if="shouldShowVulnerabilityPath(item)" class="monospace">
{{ createLocationString(item.location) }} <gl-truncate :text="createLocationString(item.location)" position="middle" />
</div> </div>
</div> </div>
</template> </template>
......
---
title: Truncate long file paths
merge_request: 45254
author:
type: changed
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import { GlDeprecatedSkeletonLoading as GlSkeletonLoading, GlTable } from '@gitlab/ui'; import { GlDeprecatedSkeletonLoading as GlSkeletonLoading, GlTable, GlTruncate } from '@gitlab/ui';
import { useLocalStorageSpy } from 'helpers/local_storage_helper'; import { useLocalStorageSpy } from 'helpers/local_storage_helper';
import RemediatedBadge from 'ee/vulnerabilities/components/remediated_badge.vue'; import RemediatedBadge from 'ee/vulnerabilities/components/remediated_badge.vue';
import IssuesBadge from 'ee/security_dashboard/components/issues_badge.vue'; import IssuesBadge from 'ee/security_dashboard/components/issues_badge.vue';
...@@ -54,7 +54,7 @@ describe('Vulnerability list component', () => { ...@@ -54,7 +54,7 @@ describe('Vulnerability list component', () => {
const findRowVulnerabilityCommentIcon = row => findRow(row).find(VulnerabilityCommentIcon); const findRowVulnerabilityCommentIcon = row => findRow(row).find(VulnerabilityCommentIcon);
const findDataCell = label => wrapper.find(`[data-testid="${label}"]`); const findDataCell = label => wrapper.find(`[data-testid="${label}"]`);
const findDataCells = label => wrapper.findAll(`[data-testid="${label}"]`); const findDataCells = label => wrapper.findAll(`[data-testid="${label}"]`);
const findCellText = label => findDataCell(label).text(); const findLocationTextWrapper = cell => cell.find(GlTruncate);
const findFiltersProducedNoResults = () => wrapper.find(FiltersProducedNoResults); const findFiltersProducedNoResults = () => wrapper.find(FiltersProducedNoResults);
const findDashboardHasNoVulnerabilities = () => wrapper.find(DashboardHasNoVulnerabilities); const findDashboardHasNoVulnerabilities = () => wrapper.find(DashboardHasNoVulnerabilities);
const findVendorNames = () => wrapper.find(`[data-testid="vulnerability-vendor"]`); const findVendorNames = () => wrapper.find(`[data-testid="vulnerability-vendor"]`);
...@@ -199,31 +199,37 @@ describe('Vulnerability list component', () => { ...@@ -199,31 +199,37 @@ describe('Vulnerability list component', () => {
it('should display the vulnerability locations for images', () => { it('should display the vulnerability locations for images', () => {
const { id, project, location } = newVulnerabilities[0]; const { id, project, location } = newVulnerabilities[0];
const cellText = findCellText(`location-${id}`); const cell = findDataCell(`location-${id}`);
expect(cellText).toContain(project.nameWithNamespace); expect(cell.text()).toContain(project.nameWithNamespace);
expect(cellText).toContain(location.image); expect(findLocationTextWrapper(cell).props()).toEqual({
expect(cellText).not.toContain('(line: '); text: location.image,
position: 'middle',
});
}); });
it('should display the vulnerability locations for code', () => { it('should display the vulnerability locations for code', () => {
const { id, project, location } = newVulnerabilities[1]; const { id, project, location } = newVulnerabilities[1];
const cellText = findCellText(`location-${id}`); const cell = findDataCell(`location-${id}`);
expect(cellText).toContain(project.nameWithNamespace); expect(cell.text()).toContain(project.nameWithNamespace);
expect(cellText).toContain(location.file); expect(findLocationTextWrapper(cell).props()).toEqual({
expect(cellText).toContain(`(line: ${location.startLine})`); text: `${location.file} (line: ${location.startLine})`,
position: 'middle',
});
}); });
it('should display the vulnerability locations for code with no line data', () => { it('should display the vulnerability locations for code with no line data', () => {
const { id, project, location } = newVulnerabilities[2]; const { id, project, location } = newVulnerabilities[2];
const cellText = findCellText(`location-${id}`); const cell = findDataCell(`location-${id}`);
expect(cellText).toContain(project.nameWithNamespace); expect(cell.text()).toContain(project.nameWithNamespace);
expect(cellText).toContain(location.file); expect(findLocationTextWrapper(cell).props()).toEqual({
expect(cellText).not.toContain('(line: '); text: location.file,
position: 'middle',
});
}); });
it('should not display the vulnerability locations for vulnerabilities without a location', () => { it('should not display the vulnerability locations for vulnerabilities without a location', () => {
const { id, project } = newVulnerabilities[4]; const { id, project } = newVulnerabilities[4];
const cellText = findCellText(`location-${id}`); const cellText = findDataCell(`location-${id}`).text();
expect(cellText).toEqual(project.nameWithNamespace); expect(cellText).toEqual(project.nameWithNamespace);
expect(cellText).not.toContain('(line: '); expect(cellText).not.toContain('(line: ');
}); });
...@@ -244,9 +250,12 @@ describe('Vulnerability list component', () => { ...@@ -244,9 +250,12 @@ describe('Vulnerability list component', () => {
it('should not display the vulnerability group/project locations for images', () => { it('should not display the vulnerability group/project locations for images', () => {
const { id, project, location } = newVulnerabilities[0]; const { id, project, location } = newVulnerabilities[0];
const cellText = findCellText(`location-${id}`); const cell = findDataCell(`location-${id}`);
expect(cellText).not.toContain(project.nameWithNamespace); expect(cell.text()).not.toContain(project.nameWithNamespace);
expect(cellText).toEqual(location.image); expect(findLocationTextWrapper(cell).props()).toEqual({
text: location.image,
position: 'middle',
});
}); });
it('should display the detected time', () => { it('should display the detected time', () => {
...@@ -258,16 +267,22 @@ describe('Vulnerability list component', () => { ...@@ -258,16 +267,22 @@ describe('Vulnerability list component', () => {
it('should display the vulnerability locations for code', () => { it('should display the vulnerability locations for code', () => {
const { id, project, location } = newVulnerabilities[1]; const { id, project, location } = newVulnerabilities[1];
const cellText = findCellText(`location-${id}`); const cell = findDataCell(`location-${id}`);
expect(cellText).not.toContain(project.nameWithNamespace); expect(cell.text()).not.toContain(project.nameWithNamespace);
expect(cellText).toEqual(`${location.file} (line: ${location.startLine})`); expect(findLocationTextWrapper(cell).props()).toEqual({
text: `${location.file} (line: ${location.startLine})`,
position: 'middle',
});
}); });
it('should not display the vulnerability group/project locations for code with no line data', () => { it('should not display the vulnerability group/project locations for code with no line data', () => {
const { id, project, location } = newVulnerabilities[2]; const { id, project, location } = newVulnerabilities[2];
const cellText = findCellText(`location-${id}`); const cell = findDataCell(`location-${id}`);
expect(cellText).not.toContain(project.nameWithNamespace); expect(cell.text()).not.toContain(project.nameWithNamespace);
expect(cellText).toEqual(location.file); expect(findLocationTextWrapper(cell).props()).toEqual({
text: location.file,
position: 'middle',
});
}); });
}); });
......
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