Commit 2ef8e7b8 authored by Serhii Yarynovskyi's avatar Serhii Yarynovskyi Committed by Paul Slaughter

Update trial status reminder design

- https://gitlab.com/gitlab-org/gitlab/-/merge_requests/80611

Changelog: changed
EE: true
parent 85832b8e
import { n__, s__ } from '~/locale'; import { s__ } from '~/locale';
const CLICK_BUTTON_ACTION = 'click_button'; const CLICK_BUTTON_ACTION = 'click_button';
const RESIZE_EVENT_DEBOUNCE_MS = 150; const RESIZE_EVENT_DEBOUNCE_MS = 150;
...@@ -8,15 +8,8 @@ export const EXPERIMENT_KEY = 'group_contact_sales'; ...@@ -8,15 +8,8 @@ export const EXPERIMENT_KEY = 'group_contact_sales';
export const WIDGET = { export const WIDGET = {
i18n: { i18n: {
widgetTitle: { widgetTitle: s__('Trials|%{planName} Trial'),
countableTranslator(count) { widgetRemainingDays: s__('Trials|Day %{daysUsed}/%{duration}'),
return n__(
'Trials|%{planName} Trial %{enDash} %{num} day left',
'Trials|%{planName} Trial %{enDash} %{num} days left',
count,
);
},
},
}, },
trackingEvents: { trackingEvents: {
widgetClick: { action: 'click_link', label: 'trial_status_widget' }, widgetClick: { action: 'click_link', label: 'trial_status_widget' },
......
...@@ -16,6 +16,8 @@ export default { ...@@ -16,6 +16,8 @@ export default {
mixins: [trackingMixin], mixins: [trackingMixin],
inject: { inject: {
containerId: { default: null }, containerId: { default: null },
trialDaysUsed: {},
trialDuration: {},
daysRemaining: {}, daysRemaining: {},
navIconImagePath: {}, navIconImagePath: {},
percentageComplete: {}, percentageComplete: {},
...@@ -24,12 +26,12 @@ export default { ...@@ -24,12 +26,12 @@ export default {
}, },
computed: { computed: {
widgetTitle() { widgetTitle() {
const i18nWidgetTitle = i18n.widgetTitle.countableTranslator(this.daysRemaining); return sprintf(i18n.widgetTitle, { planName: removeTrialSuffix(this.planName) });
},
return sprintf(i18nWidgetTitle, { widgetRemainingDays() {
planName: removeTrialSuffix(this.planName), return sprintf(i18n.widgetRemainingDays, {
enDash: '', daysUsed: this.trialDaysUsed,
num: this.daysRemaining, duration: this.trialDuration,
}); });
}, },
}, },
...@@ -49,17 +51,20 @@ export default { ...@@ -49,17 +51,20 @@ export default {
class="gl-display-flex gl-flex-direction-column gl-align-items-stretch gl-w-full" class="gl-display-flex gl-flex-direction-column gl-align-items-stretch gl-w-full"
@click="onWidgetClick" @click="onWidgetClick"
> >
<span class="gl-display-flex gl-align-items-center"> <div class="gl-display-flex gl-w-full">
<span class="nav-icon-container svg-container"> <span class="nav-icon-container svg-container">
<img :src="navIconImagePath" width="16" class="svg" /> <img :src="navIconImagePath" width="16" class="svg" />
</span> </span>
<span class="nav-item-name gl-white-space-normal"> <span class="nav-item-name">
{{ widgetTitle }} {{ widgetTitle }}
</span> </span>
</span> <span class="collapse-text gl-font-sm gl-mr-auto">
<span class="gl-display-flex gl-align-items-stretch gl-mt-3"> {{ widgetRemainingDays }}
</span>
</div>
<div class="gl-display-flex gl-align-items-stretch gl-mt-2">
<gl-progress-bar :value="percentageComplete" class="gl-flex-grow-1" /> <gl-progress-bar :value="percentageComplete" class="gl-flex-grow-1" />
</span> </div>
</div> </div>
</gl-link> </gl-link>
</template> </template>
...@@ -9,6 +9,8 @@ export const initTrialStatusWidget = () => { ...@@ -9,6 +9,8 @@ export const initTrialStatusWidget = () => {
const { const {
containerId, containerId,
trialDaysUsed,
trialDuration,
daysRemaining, daysRemaining,
navIconImagePath, navIconImagePath,
percentageComplete, percentageComplete,
...@@ -20,6 +22,8 @@ export const initTrialStatusWidget = () => { ...@@ -20,6 +22,8 @@ export const initTrialStatusWidget = () => {
el, el,
provide: { provide: {
containerId, containerId,
trialDaysUsed: Number(trialDaysUsed) || 0,
trialDuration: Number(trialDuration) || 0,
daysRemaining: Number(daysRemaining), daysRemaining: Number(daysRemaining),
navIconImagePath, navIconImagePath,
percentageComplete: Number(percentageComplete), percentageComplete: Number(percentageComplete),
......
...@@ -25,6 +25,8 @@ module TrialStatusWidgetHelper ...@@ -25,6 +25,8 @@ module TrialStatusWidgetHelper
def trial_status_widget_data_attrs(group) def trial_status_widget_data_attrs(group)
trial_status_common_data_attrs(group).merge( trial_status_common_data_attrs(group).merge(
trial_days_used: group.gitlab_subscription&.trial_days_used,
trial_duration: group.gitlab_subscription&.trial_duration,
days_remaining: group.trial_days_remaining, days_remaining: group.trial_days_remaining,
nav_icon_image_path: image_path('illustrations/golden_tanuki.svg'), nav_icon_image_path: image_path('illustrations/golden_tanuki.svg'),
percentage_complete: group.trial_percentage_complete percentage_complete: group.trial_percentage_complete
......
...@@ -3,14 +3,14 @@ ...@@ -3,14 +3,14 @@
exports[`TrialStatusWidget component without the optional containerId prop matches the snapshot 1`] = ` exports[`TrialStatusWidget component without the optional containerId prop matches the snapshot 1`] = `
<gl-link-stub <gl-link-stub
href="billing/path-for/group" href="billing/path-for/group"
title="Ultimate Trial – 20 days left" title="Ultimate Trial"
> >
<div <div
class="gl-display-flex gl-flex-direction-column gl-align-items-stretch gl-w-full" class="gl-display-flex gl-flex-direction-column gl-align-items-stretch gl-w-full"
data-testid="widget-menu" data-testid="widget-menu"
> >
<span <div
class="gl-display-flex gl-align-items-center" class="gl-display-flex gl-w-full"
> >
<span <span
class="nav-icon-container svg-container" class="nav-icon-container svg-container"
...@@ -23,22 +23,30 @@ exports[`TrialStatusWidget component without the optional containerId prop match ...@@ -23,22 +23,30 @@ exports[`TrialStatusWidget component without the optional containerId prop match
</span> </span>
<span <span
class="nav-item-name gl-white-space-normal" class="nav-item-name"
> >
Ultimate Trial – 20 days left Ultimate Trial
</span> </span>
</span>
<span
class="collapse-text gl-font-sm gl-mr-auto"
>
Day 10/30
</span>
</div>
<span <div
class="gl-display-flex gl-align-items-stretch gl-mt-3" class="gl-display-flex gl-align-items-stretch gl-mt-2"
> >
<gl-progress-bar-stub <gl-progress-bar-stub
class="gl-flex-grow-1" class="gl-flex-grow-1"
value="10" value="10"
/> />
</span> </div>
</div> </div>
</gl-link-stub> </gl-link-stub>
`; `;
...@@ -8,14 +8,18 @@ describe('TrialStatusWidget component', () => { ...@@ -8,14 +8,18 @@ describe('TrialStatusWidget component', () => {
let wrapper; let wrapper;
const { trackingEvents } = WIDGET; const { trackingEvents } = WIDGET;
const defaultDaysRemaining = 20; const trialDaysUsed = 10;
const trialDuration = 30;
const daysRemaining = 20;
const findGlLink = () => wrapper.findComponent(GlLink); const findGlLink = () => wrapper.findComponent(GlLink);
const createComponent = (providers = {}) => { const createComponent = (providers = {}) => {
return shallowMount(TrialStatusWidget, { return shallowMount(TrialStatusWidget, {
provide: { provide: {
daysRemaining: defaultDaysRemaining, trialDaysUsed,
trialDuration,
daysRemaining,
navIconImagePath: 'illustrations/golden_tanuki.svg', navIconImagePath: 'illustrations/golden_tanuki.svg',
percentageComplete: 10, percentageComplete: 10,
planName: 'Ultimate', planName: 'Ultimate',
...@@ -65,7 +69,7 @@ describe('TrialStatusWidget component', () => { ...@@ -65,7 +69,7 @@ describe('TrialStatusWidget component', () => {
it('does not render Trial twice if the plan name includes "Trial"', () => { it('does not render Trial twice if the plan name includes "Trial"', () => {
wrapper = createComponent({ planName: 'Ultimate Trial' }); wrapper = createComponent({ planName: 'Ultimate Trial' });
expect(wrapper.text()).toEqual('Ultimate Trial – 20 days left'); expect(wrapper.text()).toMatchInterpolatedText('Ultimate Trial Day 10/30');
}); });
}); });
......
...@@ -6,6 +6,7 @@ RSpec.describe TrialStatusWidgetHelper, :saas do ...@@ -6,6 +6,7 @@ RSpec.describe TrialStatusWidgetHelper, :saas do
describe 'data attributes for mounting Vue components', :freeze_time do describe 'data attributes for mounting Vue components', :freeze_time do
let(:trial_length) { 30 } # days let(:trial_length) { 30 } # days
let(:trial_days_remaining) { 18 } let(:trial_days_remaining) { 18 }
let(:trial_days_used) { trial_length - trial_days_remaining }
let(:trial_end_date) { Date.current.advance(days: trial_days_remaining) } let(:trial_end_date) { Date.current.advance(days: trial_days_remaining) }
let(:trial_start_date) { Date.current.advance(days: trial_days_remaining - trial_length) } let(:trial_start_date) { Date.current.advance(days: trial_days_remaining - trial_length) }
let(:trial_percentage_complete) { (trial_length - trial_days_remaining) * 100 / trial_length } let(:trial_percentage_complete) { (trial_length - trial_days_remaining) * 100 / trial_length }
...@@ -89,6 +90,8 @@ RSpec.describe TrialStatusWidgetHelper, :saas do ...@@ -89,6 +90,8 @@ RSpec.describe TrialStatusWidgetHelper, :saas do
it 'returns the needed data attributes for mounting the widget Vue component' do it 'returns the needed data attributes for mounting the widget Vue component' do
expect(data_attrs).to match( expect(data_attrs).to match(
shared_expected_attrs.merge( shared_expected_attrs.merge(
trial_days_used: trial_days_used,
trial_duration: trial_length,
nav_icon_image_path: '/image-path/for-file.svg', nav_icon_image_path: '/image-path/for-file.svg',
percentage_complete: trial_percentage_complete percentage_complete: trial_percentage_complete
) )
......
...@@ -38575,10 +38575,8 @@ msgstr "" ...@@ -38575,10 +38575,8 @@ msgstr ""
msgid "Trending" msgid "Trending"
msgstr "" msgstr ""
msgid "Trials|%{planName} Trial %{enDash} %{num} day left" msgid "Trials|%{planName} Trial"
msgid_plural "Trials|%{planName} Trial %{enDash} %{num} days left" msgstr ""
msgstr[0] ""
msgstr[1] ""
msgid "Trials|Compare all plans" msgid "Trials|Compare all plans"
msgstr "" msgstr ""
...@@ -38586,6 +38584,9 @@ msgstr "" ...@@ -38586,6 +38584,9 @@ msgstr ""
msgid "Trials|Create a new group to start your GitLab Ultimate trial." msgid "Trials|Create a new group to start your GitLab Ultimate trial."
msgstr "" msgstr ""
msgid "Trials|Day %{daysUsed}/%{duration}"
msgstr ""
msgid "Trials|Go back to GitLab" msgid "Trials|Go back to GitLab"
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