Commit 2a93b6af authored by Phil Hughes's avatar Phil Hughes

Merge branch 'new-trials-status-popover-text' into 'master'

Fix Popover Trial Status Text for New Trials

See merge request gitlab-org/gitlab!68680
parents 90e8614c 5ff1f1d2
export function removeTrialSuffix(planName) {
return planName.replace(/ trial\b/i, '');
}
...@@ -3,5 +3,3 @@ export const TABLE_TYPE_FREE = 'free'; ...@@ -3,5 +3,3 @@ export const TABLE_TYPE_FREE = 'free';
export const TABLE_TYPE_TRIAL = 'trial'; export const TABLE_TYPE_TRIAL = 'trial';
export const DAYS_FOR_RENEWAL = 15; export const DAYS_FOR_RENEWAL = 15;
export const PLAN_TITLE_TRIAL_TEXT = ' Trial';
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
import { GlButton, GlLoadingIcon } from '@gitlab/ui'; import { GlButton, GlLoadingIcon } from '@gitlab/ui';
import { escape } from 'lodash'; import { escape } from 'lodash';
import { mapActions, mapState, mapGetters } from 'vuex'; import { mapActions, mapState, mapGetters } from 'vuex';
import { removeTrialSuffix } from 'ee/billings/billings_util';
import { import {
TABLE_TYPE_DEFAULT, TABLE_TYPE_DEFAULT,
TABLE_TYPE_FREE, TABLE_TYPE_FREE,
TABLE_TYPE_TRIAL, TABLE_TYPE_TRIAL,
DAYS_FOR_RENEWAL, DAYS_FOR_RENEWAL,
PLAN_TITLE_TRIAL_TEXT,
} from 'ee/billings/constants'; } from 'ee/billings/constants';
import ExtendReactivateTrialButton from 'ee/trials/extend_reactivate_trial/components/extend_reactivate_trial_button.vue'; import ExtendReactivateTrialButton from 'ee/trials/extend_reactivate_trial/components/extend_reactivate_trial_button.vue';
import createFlash from '~/flash'; import createFlash from '~/flash';
...@@ -79,7 +79,7 @@ export default { ...@@ -79,7 +79,7 @@ export default {
subscriptionHeader() { subscriptionHeader() {
const planName = this.isFreePlan const planName = this.isFreePlan
? s__('SubscriptionTable|Free') ? s__('SubscriptionTable|Free')
: escape(this.planName.replace(PLAN_TITLE_TRIAL_TEXT, '')); : escape(removeTrialSuffix(this.planName));
const suffix = this.isSubscription && this.plan.trial ? s__('SubscriptionTable|Trial') : ''; const suffix = this.isSubscription && this.plan.trial ? s__('SubscriptionTable|Trial') : '';
return `${this.namespaceName}: ${planName} ${suffix}`; return `${this.namespaceName}: ${planName} ${suffix}`;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import { GlButton, GlPopover, GlSprintf } from '@gitlab/ui'; import { GlButton, GlPopover, GlSprintf } 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 { removeTrialSuffix } from 'ee/billings/billings_util';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { formatDate } from '~/lib/utils/datetime_utility'; import { formatDate } from '~/lib/utils/datetime_utility';
import { sprintf } from '~/locale'; import { sprintf } from '~/locale';
...@@ -56,10 +57,13 @@ export default { ...@@ -56,10 +57,13 @@ export default {
formattedTrialEndDate() { formattedTrialEndDate() {
return formatDate(this.trialEndDate, trialEndDateFormatString); return formatDate(this.trialEndDate, trialEndDateFormatString);
}, },
planNameWithoutTrial() {
return removeTrialSuffix(this.planName);
},
upgradeButtonTitle() { upgradeButtonTitle() {
return sprintf(this.$options.i18n.upgradeButtonTitle, { return sprintf(this.$options.i18n.upgradeButtonTitle, {
groupName: this.groupName, groupName: this.groupName,
planName: this.planName, planName: removeTrialSuffix(this.planName),
}); });
}, },
}, },
...@@ -162,7 +166,7 @@ export default { ...@@ -162,7 +166,7 @@ export default {
<template #bold="{ content }"> <template #bold="{ content }">
<b>{{ sprintf(content, { trialEndDate: formattedTrialEndDate }) }}</b> <b>{{ sprintf(content, { trialEndDate: formattedTrialEndDate }) }}</b>
</template> </template>
<template #planName>{{ planName }}</template> <template #planName>{{ planNameWithoutTrial }}</template>
</gl-sprintf> </gl-sprintf>
<div class="gl-mt-5"> <div class="gl-mt-5">
......
<script> <script>
import { GlLink, GlProgressBar } from '@gitlab/ui'; import { GlLink, GlProgressBar } from '@gitlab/ui';
import { removeTrialSuffix } from 'ee/billings/billings_util';
import { sprintf } from '~/locale'; import { sprintf } from '~/locale';
import Tracking from '~/tracking'; import Tracking from '~/tracking';
import { EXPERIMENT_KEY, WIDGET } from './constants'; import { EXPERIMENT_KEY, WIDGET } from './constants';
...@@ -26,7 +27,7 @@ export default { ...@@ -26,7 +27,7 @@ export default {
const i18nWidgetTitle = i18n.widgetTitle.countableTranslator(this.daysRemaining); const i18nWidgetTitle = i18n.widgetTitle.countableTranslator(this.daysRemaining);
return sprintf(i18nWidgetTitle, { return sprintf(i18nWidgetTitle, {
planName: this.planName, planName: removeTrialSuffix(this.planName),
enDash: '', enDash: '',
num: this.daysRemaining, num: this.daysRemaining,
}); });
......
...@@ -86,6 +86,15 @@ describe('TrialStatusPopover component', () => { ...@@ -86,6 +86,15 @@ describe('TrialStatusPopover component', () => {
expectTracking(trackingEvents.compareBtnClick); expectTracking(trackingEvents.compareBtnClick);
}); });
it('does not include the word "Trial" if the plan name includes it', () => {
wrapper = createComponent({ planName: 'Ultimate Trial' }, mount);
const popoverText = wrapper.text();
expect(popoverText).toContain('We hope you’re enjoying the features of GitLab Ultimate.');
expect(popoverText).toMatch(/Upgrade Some Test Group to Ultimate(?! Trial)/);
});
describe('startInitiallyShown', () => { describe('startInitiallyShown', () => {
const userCalloutProviders = { const userCalloutProviders = {
userCalloutsPath: 'user_callouts/path', userCalloutsPath: 'user_callouts/path',
......
...@@ -64,6 +64,12 @@ describe('TrialStatusWidget component', () => { ...@@ -64,6 +64,12 @@ describe('TrialStatusWidget component', () => {
unmockTracking(); unmockTracking();
}); });
it('does not render Trial twice if the plan name includes "Trial"', () => {
wrapper = createComponent({ planName: 'Ultimate Trial' });
expect(wrapper.text()).toEqual('Ultimate Trial – 20 days left');
});
}); });
describe('with the optional containerId prop', () => { describe('with the optional containerId prop', () => {
......
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