Commit b473d089 authored by David O'Regan's avatar David O'Regan

Merge branch '327997-add-promo-image-to-informational-popover' into 'master'

Add the golden tanuki promo image to the informational popover

See merge request gitlab-org/gitlab!60325
parents 638ac193 2f6e92f1
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import { GlPopover } from '@gitlab/ui'; import { GlPopover } from '@gitlab/ui';
import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils'; import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils';
import { debounce } from 'lodash'; import { debounce } from 'lodash';
import { n__, s__, sprintf } from '~/locale'; import { __, n__, s__, sprintf } from '~/locale';
import Tracking from '~/tracking'; import Tracking from '~/tracking';
const RESIZE_EVENT_DEBOUNCE_MS = 150; const RESIZE_EVENT_DEBOUNCE_MS = 150;
...@@ -34,6 +34,16 @@ export default { ...@@ -34,6 +34,16 @@ export default {
type: String, type: String,
required: true, required: true,
}, },
promoImageAltText: {
type: String,
required: false,
default: __('SVG illustration'),
},
promoImagePath: {
type: String,
required: false,
default: undefined,
},
targetId: { targetId: {
type: String, type: String,
required: true, required: true,
...@@ -107,6 +117,16 @@ export default { ...@@ -107,6 +117,16 @@ export default {
> >
<template #title>{{ popoverTitle }}</template> <template #title>{{ popoverTitle }}</template>
<div v-if="promoImagePath" class="gl-display-flex gl-justify-content-center gl-mt-n3 gl-mb-4">
<img
:src="promoImagePath"
:alt="promoImageAltText"
height="40"
width="40"
data-testid="promo-img"
/>
</div>
{{ popoverContent }} {{ popoverContent }}
</gl-popover> </gl-popover>
</template> </template>
...@@ -26,6 +26,8 @@ export const initPaidFeatureCalloutPopover = () => { ...@@ -26,6 +26,8 @@ export const initPaidFeatureCalloutPopover = () => {
featureName, featureName,
planNameForTrial, planNameForTrial,
planNameForUpgrade, planNameForUpgrade,
promoImageAltText,
promoImagePath,
targetId, targetId,
} = el.dataset; } = el.dataset;
...@@ -39,6 +41,8 @@ export const initPaidFeatureCalloutPopover = () => { ...@@ -39,6 +41,8 @@ export const initPaidFeatureCalloutPopover = () => {
featureName, featureName,
planNameForTrial, planNameForTrial,
planNameForUpgrade, planNameForUpgrade,
promoImageAltText,
promoImagePath,
targetId, targetId,
}, },
}), }),
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
- feature_name = 'merge request approvals' - feature_name = 'merge request approvals'
.gl-xs-ml-3.gl-sm-mr-3.gl-mb-2.gl-order-1.gl-sm-order-init .gl-xs-ml-3.gl-sm-mr-3.gl-mb-2.gl-order-1.gl-sm-order-init
#js-paid-feature-badge{ data: paid_feature_badge_data_attrs(feature_name) } #js-paid-feature-badge{ data: paid_feature_badge_data_attrs(feature_name) }
#js-paid-feature-popover{ data: paid_feature_popover_data_attrs(group: root_group, feature_name: feature_name) } #js-paid-feature-popover{ data: paid_feature_popover_data_attrs(group: root_group, feature_name: feature_name).merge(promo_image_path: image_path('illustrations/golden_tanuki.svg'), promo_image_alt_text: s_('ImageAltText|Sparkling golden tanuki logo')) }
= form.label :approver_ids, "Approval rules" = form.label :approver_ids, "Approval rules"
.col-sm-10 .col-sm-10
= render_if_exists 'shared/issuable/approver_suggestion', issuable: issuable, presenter: presenter = render_if_exists 'shared/issuable/approver_suggestion', issuable: issuable, presenter: presenter
...@@ -4,6 +4,7 @@ import { shallowMount } from '@vue/test-utils'; ...@@ -4,6 +4,7 @@ import { shallowMount } from '@vue/test-utils';
import PaidFeatureCalloutPopover from 'ee/paid_feature_callouts/components/paid_feature_callout_popover.vue'; import PaidFeatureCalloutPopover from 'ee/paid_feature_callouts/components/paid_feature_callout_popover.vue';
import { mockTracking } from 'helpers/tracking_helper'; import { mockTracking } from 'helpers/tracking_helper';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
describe('PaidFeatureCalloutPopover', () => { describe('PaidFeatureCalloutPopover', () => {
let trackingSpy; let trackingSpy;
...@@ -20,9 +21,11 @@ describe('PaidFeatureCalloutPopover', () => { ...@@ -20,9 +21,11 @@ describe('PaidFeatureCalloutPopover', () => {
}; };
const createComponent = (props = defaultProps) => { const createComponent = (props = defaultProps) => {
return shallowMount(PaidFeatureCalloutPopover, { return extendedWrapper(
shallowMount(PaidFeatureCalloutPopover, {
propsData: props, propsData: props,
}); }),
);
}; };
afterEach(() => { afterEach(() => {
...@@ -64,6 +67,60 @@ describe('PaidFeatureCalloutPopover', () => { ...@@ -64,6 +67,60 @@ describe('PaidFeatureCalloutPopover', () => {
}); });
}); });
describe('promo image', () => {
const findPromoImage = () => wrapper.findByTestId('promo-img');
describe('with the optional promoImagePath prop', () => {
beforeEach(() => {
wrapper = createComponent({
...defaultProps,
promoImagePath: 'path/to/some/image.svg',
});
});
it('renders the promo image', () => {
expect(findPromoImage().exists()).toBe(true);
});
describe('with the optional promoImageAltText prop', () => {
beforeEach(() => {
wrapper = createComponent({
...defaultProps,
promoImagePath: 'path/to/some/image.svg',
promoImageAltText: 'My fancy alt text',
});
});
it('renders the promo image with the given alt text', () => {
expect(findPromoImage().attributes('alt')).toBe('My fancy alt text');
});
});
describe('without the optional promoImageAltText prop', () => {
beforeEach(() => {
wrapper = createComponent({
...defaultProps,
promoImagePath: 'path/to/some/image.svg',
});
});
it('renders the promo image with default alt text', () => {
expect(findPromoImage().attributes('alt')).toBe('SVG illustration');
});
});
});
describe('without the optional promoImagePath prop', () => {
beforeEach(() => {
wrapper = createComponent();
});
it('does not render a promo image', () => {
expect(findPromoImage().exists()).toBe(false);
});
});
});
describe('onShown', () => { describe('onShown', () => {
beforeEach(() => { beforeEach(() => {
trackingSpy = mockTracking(undefined, undefined, jest.spyOn); trackingSpy = mockTracking(undefined, undefined, jest.spyOn);
......
...@@ -16474,6 +16474,9 @@ msgstr "" ...@@ -16474,6 +16474,9 @@ msgstr ""
msgid "Image details" msgid "Image details"
msgstr "" msgstr ""
msgid "ImageAltText|Sparkling golden tanuki logo"
msgstr ""
msgid "ImageDiffViewer|2-up" msgid "ImageDiffViewer|2-up"
msgstr "" msgstr ""
...@@ -27954,6 +27957,9 @@ msgstr "" ...@@ -27954,6 +27957,9 @@ msgstr ""
msgid "SSL verification" msgid "SSL verification"
msgstr "" msgstr ""
msgid "SVG illustration"
msgstr ""
msgid "Satisfied" msgid "Satisfied"
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