Commit 66a84b23 authored by Daniel Tian's avatar Daniel Tian Committed by Ezekiel Kigbo

Truncate long vulnerability names on security report

parent d6146737
<script> <script>
import { GlTooltipDirective, GlResizeObserverDirective } from '@gitlab/ui';
import { mapActions } from 'vuex'; import { mapActions } from 'vuex';
export default { export default {
directives: {
GlTooltip: GlTooltipDirective,
GlResizeObserverDirective,
},
props: { props: {
issue: { issue: {
type: Object, type: Object,
...@@ -13,19 +18,32 @@ export default { ...@@ -13,19 +18,32 @@ export default {
required: true, required: true,
}, },
}, },
data: () => ({
tooltipTitle: '',
}),
mounted() {
this.updateTooltipTitle();
},
methods: { methods: {
...mapActions(['openModal']), ...mapActions(['openModal']),
handleIssueClick() { handleIssueClick() {
const { issue, status, openModal } = this; const { issue, status, openModal } = this;
openModal({ issue, status }); openModal({ issue, status });
}, },
updateTooltipTitle() {
// Only show the tooltip if the text is truncated with an ellipsis.
this.tooltipTitle = this.$el.offsetWidth < this.$el.scrollWidth ? this.issue.title : '';
},
}, },
}; };
</script> </script>
<template> <template>
<button <button
type="button" v-gl-tooltip="{ boundary: 'viewport' }"
class="btn-link btn-blank text-left break-link vulnerability-name-button" v-gl-resize-observer-directive="updateTooltipTitle"
class="btn-link gl-text-truncate"
:aria-label="s__('Reports|Vulnerability Name')"
:title="tooltipTitle"
@click="handleIssueClick()" @click="handleIssueClick()"
> >
{{ issue.title }} {{ issue.title }}
......
...@@ -34,9 +34,13 @@ export default { ...@@ -34,9 +34,13 @@ export default {
}; };
</script> </script>
<template> <template>
<div class="report-block-list-issue-description gl-mt-2 gl-mb-2"> <div class="report-block-list-issue-description gl-mt-2 gl-mb-2 gl-w-full">
<div class="report-block-list-issue-description-text"> <div class="report-block-list-issue-description-text gl-display-flex gl-w-full">
<severity-badge v-if="issue.severity" class="d-inline-block" :severity="issue.severity" /> <severity-badge
v-if="issue.severity"
class="d-inline-block gl-mr-1"
:severity="issue.severity"
/>
<modal-open-name :issue="issue" :status="status" /> <modal-open-name :issue="issue" :status="status" />
</div> </div>
<report-link v-if="showReportLink && issue.path" :issue="issue" /> <report-link v-if="showReportLink && issue.path" :issue="issue" />
......
---
title: Truncate long vulnerability names on security report
merge_request: 38056
author:
type: fixed
...@@ -308,7 +308,7 @@ describe('Grouped security reports app', () => { ...@@ -308,7 +308,7 @@ describe('Grouped security reports app', () => {
}); });
it('opens modal with more information', () => { it('opens modal with more information', () => {
wrapper.vm.$el.querySelector('.break-link').click(); wrapper.vm.$el.querySelector('[aria-label="Vulnerability Name"]').click();
return Vue.nextTick().then(() => { return Vue.nextTick().then(() => {
expect(wrapper.vm.$el.querySelector('.modal-title').textContent.trim()).toEqual( expect(wrapper.vm.$el.querySelector('.modal-title').textContent.trim()).toEqual(
......
...@@ -20245,6 +20245,9 @@ msgstr "" ...@@ -20245,6 +20245,9 @@ msgstr ""
msgid "Reports|Vulnerability" msgid "Reports|Vulnerability"
msgstr "" msgstr ""
msgid "Reports|Vulnerability Name"
msgstr ""
msgid "Reports|no changed test results" msgid "Reports|no changed test results"
msgstr "" msgstr ""
......
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