Commit 866a7f49 authored by Filipa Lacerda's avatar Filipa Lacerda

Moves popover button to it's own component

parent 98b294e0
...@@ -20,8 +20,8 @@ export default { ...@@ -20,8 +20,8 @@ export default {
}; };
</script> </script>
<template> <template>
<div class="report-block-list-issue"> <div class="report-block-list-issue prepend-left-default append-right-default">
<div class="report-block-list-icon append-right-10 prepend-left-10"> <div class="report-block-list-icon append-right-10 prepend-left-5">
<ci-icon :status="iconStatus" /> <ci-icon :status="iconStatus" />
</div> </div>
<div class="report-block-list-issue-description"> <div class="report-block-list-issue-description">
......
<script>
import Icon from '~/vue_shared/components/icon.vue';
import popover from '~/vue_shared/directives/popover';
export default {
name: 'SecurityReportsHelpPopover',
components: {
Icon,
},
directives: {
popover,
},
props: {
options: {
type: Object,
required: true,
},
},
computed: {
popoverOptions() {
return {
html: true,
trigger: 'focus',
placement: 'top',
template:
'<div class="popover" role="tooltip"><div class="arrow"></div><p class="popover-title"></p><div class="popover-content"></div></div>',
...this.options,
};
},
},
};
</script>
<template>
<button
type="button"
class="btn-transparent btn-blank"
v-popover="popoverOptions"
tabindex="0"
>
<icon name="question" />
</button>
</template>
...@@ -13,8 +13,8 @@ export default { ...@@ -13,8 +13,8 @@ export default {
}; };
</script> </script>
<template> <template>
<div class="report-block-list-issue"> <div class="report-block-list-issue prepend-left-default append-right-default">
<div class="report-block-list-icon append-right-15 prepend-left-10"> <div class="report-block-list-icon append-right-10 prepend-left-5">
<loading-icon /> <loading-icon />
</div> </div>
<div class="report-block-list-issue-description"> <div class="report-block-list-issue-description">
......
<script> <script>
import Icon from '~/vue_shared/components/icon.vue';
import CiIcon from '~/vue_shared/components/ci_icon.vue'; import CiIcon from '~/vue_shared/components/ci_icon.vue';
import popover from '~/vue_shared/directives/popover'; import Popover from './help_popover.vue';
/** /**
* Renders the summary row for each security report * Renders the summary row for each security report
...@@ -10,11 +9,8 @@ import popover from '~/vue_shared/directives/popover'; ...@@ -10,11 +9,8 @@ import popover from '~/vue_shared/directives/popover';
export default { export default {
name: 'SecuritySummaryRow', name: 'SecuritySummaryRow',
components: { components: {
Icon,
CiIcon, CiIcon,
}, Popover,
directives: {
popover,
}, },
props: { props: {
summary: { summary: {
...@@ -25,26 +21,12 @@ export default { ...@@ -25,26 +21,12 @@ export default {
type: String, type: String,
required: true, required: true,
}, },
popoverTitle: { popoverOptions: {
type: String, type: Object,
required: true,
},
popoverContent: {
type: String,
required: true, required: true,
}, },
}, },
computed: { computed: {
popoverOptions() {
return {
html: true,
trigger: 'focus',
placement: 'top',
title: this.popoverTitle,
content: this.popoverContent,
template: '<div class="popover" role="tooltip"><div class="arrow"></div><p class="popover-title"></p><div class="popover-content"></div></div>',
};
},
iconStatus() { iconStatus() {
return { return {
group: this.statusIcon, group: this.statusIcon,
...@@ -55,24 +37,17 @@ export default { ...@@ -55,24 +37,17 @@ export default {
}; };
</script> </script>
<template> <template>
<div class="report-block-list-issue"> <div class="report-block-list-issue prepend-left-default append-right-default">
<div class="report-block-list-icon append-right-10 prepend-left-10"> <div class="report-block-list-icon append-right-10 prepend-left-5">
<ci-icon :status="iconStatus" /> <ci-icon :status="iconStatus" />
</div> </div>
<div class="report-block-list-issue-description"> <div class="report-block-list-issue-description prepend-top-5 append-bottom-5">
<div class="report-block-list-issue-description-text append-right-5"> <div class="report-block-list-issue-description-text append-right-5">
{{ summary }} {{ summary }}
</div> </div>
<button <popover :options="popoverOptions" />
type="button"
class="btn-transparent btn-blank"
v-popover="popoverOptions"
tabindex="0"
>
<icon name="question" />
</button>
</div> </div>
</div> </div>
</template> </template>
...@@ -8,8 +8,10 @@ describe('Summary row', () => { ...@@ -8,8 +8,10 @@ describe('Summary row', () => {
const props = { const props = {
summary: 'SAST detected 1 new vulnerability and 1 fixed vulnerability', summary: 'SAST detected 1 new vulnerability and 1 fixed vulnerability',
popoverTitle: 'Static Application Security Testing (SAST)', popoverOptions: {
popoverContent: '<a>Learn more about SAST</a>', title: 'Static Application Security Testing (SAST)',
content: '<a>Learn more about SAST</a>',
},
statusIcon: 'warning', statusIcon: 'warning',
}; };
...@@ -32,9 +34,4 @@ describe('Summary row', () => { ...@@ -32,9 +34,4 @@ describe('Summary row', () => {
'js-ci-status-icon-warning', 'js-ci-status-icon-warning',
); );
}); });
it('renders tooltip with provided title and content', () => {
expect(vm.popoverOptions.title).toEqual(props.popoverTitle);
expect(vm.popoverOptions.content).toEqual(props.popoverContent);
});
}); });
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