Commit 384491a7 authored by David Pisek's avatar David Pisek Committed by Kushal Pandya

Make issue vulnerability popover less subtle

parent f736f85c
<script> <script>
import jiraLogo from '@gitlab/svgs/dist/illustrations/logos/jira.svg'; import jiraLogo from '@gitlab/svgs/dist/illustrations/logos/jira.svg';
import { GlIcon, GlLink, GlTooltipDirective, GlSafeHtmlDirective } from '@gitlab/ui'; import { GlIcon, GlLink, GlTooltipDirective, GlSafeHtmlDirective, GlSprintf } from '@gitlab/ui';
export default { export default {
components: { components: {
GlIcon, GlIcon,
GlLink, GlLink,
GlSprintf,
}, },
directives: { directives: {
GlTooltip: GlTooltipDirective, GlTooltip: GlTooltipDirective,
...@@ -23,11 +24,13 @@ export default { ...@@ -23,11 +24,13 @@ export default {
}, },
computed: { computed: {
iconName() { iconName() {
return this.issue.state === this.$options.STATE_OPENED ? 'issue-open-m' : 'issue-close'; return this.issueIsClosed ? 'issue-closed' : 'issues';
},
issueIsClosed() {
return this.issue.state === 'closed';
}, },
}, },
jiraLogo, jiraLogo,
STATE_OPENED: 'opened',
}; };
</script> </script>
<template> <template>
...@@ -45,11 +48,14 @@ export default { ...@@ -45,11 +48,14 @@ export default {
></span> ></span>
<gl-icon <gl-icon
v-else v-else
class="gl-mr-1" class="gl-mr-2"
:class="{ 'gl-text-green-600': issue.state === $options.STATE_OPENED }" :class="{ 'gl-text-green-600': !issueIsClosed }"
:name="iconName" :name="iconName"
/> />
#{{ issue.iid }} <gl-sprintf v-if="issueIsClosed" :message="__('#%{issueIid} (closed)')">
<template #issueIid>{{ issue.iid }}</template>
</gl-sprintf>
<span v-else>#{{ issue.iid }}</span>
<gl-icon v-if="isJira" :size="12" name="external-link" class="gl-ml-1" /> <gl-icon v-if="isJira" :size="12" name="external-link" class="gl-ml-1" />
</gl-link> </gl-link>
</template> </template>
import { GlIcon, GlLink } from '@gitlab/ui'; import { GlIcon, GlLink, GlSprintf } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import IssueLink from 'ee/vulnerabilities/components/issue_link.vue'; import IssueLink from 'ee/vulnerabilities/components/issue_link.vue';
import { getBinding, createMockDirective } from 'helpers/vue_mock_directive'; import { getBinding, createMockDirective } from 'helpers/vue_mock_directive';
...@@ -21,6 +21,8 @@ describe('IssueLink component', () => { ...@@ -21,6 +21,8 @@ describe('IssueLink component', () => {
directives: { directives: {
GlTooltip: createMockDirective(), GlTooltip: createMockDirective(),
}, },
// this allows us to retrieve the rendered text
stubs: { GlSprintf },
}), }),
); );
}; };
...@@ -53,10 +55,10 @@ describe('IssueLink component', () => { ...@@ -53,10 +55,10 @@ describe('IssueLink component', () => {
describe('internal issues', () => { describe('internal issues', () => {
describe.each` describe.each`
state | icon state | icon | shouldContainClosedText
${'opened'} | ${'issue-open-m'} ${'opened'} | ${'issues'} | ${false}
${'closed'} | ${'issue-close'} ${'closed'} | ${'issue-closed'} | ${true}
`('with state "$state"', ({ state, icon }) => { `('with state "$state"', ({ state, icon, shouldContainClosedText }) => {
beforeEach(() => { beforeEach(() => {
wrapper = createWrapper({ propsData: { issue: createIssue({ state }) } }); wrapper = createWrapper({ propsData: { issue: createIssue({ state }) } });
}); });
...@@ -64,6 +66,12 @@ describe('IssueLink component', () => { ...@@ -64,6 +66,12 @@ describe('IssueLink component', () => {
it('should contain the correct issue icon', () => { it('should contain the correct issue icon', () => {
expect(findIcon().attributes('name')).toBe(icon); expect(findIcon().attributes('name')).toBe(icon);
}); });
it(`${
shouldContainClosedText ? 'should' : 'should not'
} contain a text that marks it as closed`, () => {
expect(findIssueLink().text().includes('closed')).toBe(shouldContainClosedText);
});
}); });
}); });
......
...@@ -86,6 +86,9 @@ msgstr "" ...@@ -86,6 +86,9 @@ msgstr ""
msgid "\"el\" parameter is required for createInstance()" msgid "\"el\" parameter is required for createInstance()"
msgstr "" msgstr ""
msgid "#%{issueIid} (closed)"
msgstr ""
msgid "#general, #development" msgid "#general, #development"
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