Commit 77c5ad96 authored by Vitaly Slobodin's avatar Vitaly Slobodin

Add ExtendReactivateTrialButton to the SubscriptionTable

Duplicate the button to the SubscriptionTable to let
users to extend or to reactivate their trial.
parent 766c2819
...@@ -9,7 +9,7 @@ export default { ...@@ -9,7 +9,7 @@ export default {
}, },
inject: { inject: {
namespaceId: { namespaceId: {
default: '', default: null,
}, },
}, },
created() { created() {
......
...@@ -9,6 +9,7 @@ import { ...@@ -9,6 +9,7 @@ import {
DAYS_FOR_RENEWAL, DAYS_FOR_RENEWAL,
PLAN_TITLE_TRIAL_TEXT, 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 createFlash from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { getDayDifference } from '~/lib/utils/datetime/date_calculation_utility'; import { getDayDifference } from '~/lib/utils/datetime/date_calculation_utility';
...@@ -24,6 +25,7 @@ export default { ...@@ -24,6 +25,7 @@ export default {
GlButton, GlButton,
GlLoadingIcon, GlLoadingIcon,
SubscriptionTableRow, SubscriptionTableRow,
ExtendReactivateTrialButton,
}, },
mixins: [glFeatureFlagsMixin()], mixins: [glFeatureFlagsMixin()],
inject: { inject: {
...@@ -34,7 +36,7 @@ export default { ...@@ -34,7 +36,7 @@ export default {
default: '', default: '',
}, },
namespaceId: { namespaceId: {
default: '', default: null,
}, },
customerPortalUrl: { customerPortalUrl: {
default: '', default: '',
...@@ -54,6 +56,9 @@ export default { ...@@ -54,6 +56,9 @@ export default {
refreshSeatsHref: { refreshSeatsHref: {
default: '', default: '',
}, },
availableTrialAction: {
default: null,
},
}, },
computed: { computed: {
...mapState([ ...mapState([
...@@ -182,7 +187,14 @@ export default { ...@@ -182,7 +187,14 @@ export default {
data-testid="subscription-header" data-testid="subscription-header"
> >
<strong>{{ subscriptionHeader }}</strong> <strong>{{ subscriptionHeader }}</strong>
<div class="controls"> <div class="gl-display-flex">
<extend-reactivate-trial-button
v-if="availableTrialAction"
:namespace-id="namespaceId"
:action="availableTrialAction"
:plan-name="planName"
class="gl-mr-3"
/>
<gl-button <gl-button
v-for="(button, index) in buttons" v-for="(button, index) in buttons"
:key="button.text" :key="button.text"
......
...@@ -24,13 +24,14 @@ export default (containerId = 'js-billing-plans') => { ...@@ -24,13 +24,14 @@ export default (containerId = 'js-billing-plans') => {
planName, planName,
freePersonalNamespace, freePersonalNamespace,
refreshSeatsHref, refreshSeatsHref,
action,
} = containerEl.dataset; } = containerEl.dataset;
return new Vue({ return new Vue({
el: containerEl, el: containerEl,
store: new Vuex.Store(initialStore()), store: new Vuex.Store(initialStore()),
provide: { provide: {
namespaceId, namespaceId: Number(namespaceId),
namespaceName, namespaceName,
addSeatsHref, addSeatsHref,
planUpgradeHref, planUpgradeHref,
...@@ -40,6 +41,7 @@ export default (containerId = 'js-billing-plans') => { ...@@ -40,6 +41,7 @@ export default (containerId = 'js-billing-plans') => {
planName, planName,
freePersonalNamespace: parseBoolean(freePersonalNamespace), freePersonalNamespace: parseBoolean(freePersonalNamespace),
refreshSeatsHref, refreshSeatsHref,
availableTrialAction: action,
}, },
render(createElement) { render(createElement) {
return createElement(SubscriptionApp); return createElement(SubscriptionApp);
......
import initSubscriptions from 'ee/billings/subscriptions'; import initSubscriptions from 'ee/billings/subscriptions';
import { shouldExtendReactivateTrialButtonMount } from 'ee/trials/extend_reactivate_trial';
import PersistentUserCallout from '~/persistent_user_callout'; import PersistentUserCallout from '~/persistent_user_callout';
PersistentUserCallout.factory(document.querySelector('.js-gold-trial-callout')); PersistentUserCallout.factory(document.querySelector('.js-gold-trial-callout'));
shouldExtendReactivateTrialButtonMount();
initSubscriptions(); initSubscriptions();
...@@ -6,6 +6,7 @@ import SubscriptionTable from 'ee/billings/subscriptions/components/subscription ...@@ -6,6 +6,7 @@ import SubscriptionTable from 'ee/billings/subscriptions/components/subscription
import SubscriptionTableRow from 'ee/billings/subscriptions/components/subscription_table_row.vue'; import SubscriptionTableRow from 'ee/billings/subscriptions/components/subscription_table_row.vue';
import initialStore from 'ee/billings/subscriptions/store'; import initialStore from 'ee/billings/subscriptions/store';
import * as types from 'ee/billings/subscriptions/store/mutation_types'; import * as types from 'ee/billings/subscriptions/store/mutation_types';
import ExtendReactivateTrialButton from 'ee/trials/extend_reactivate_trial/components/extend_reactivate_trial_button.vue';
import { mockDataSubscription } from 'ee_jest/billings/mock_data'; import { mockDataSubscription } from 'ee_jest/billings/mock_data';
import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
...@@ -361,4 +362,33 @@ describe('SubscriptionTable component', () => { ...@@ -361,4 +362,33 @@ describe('SubscriptionTable component', () => {
expect(findRefreshSeatsButton().exists()).toBe(false); expect(findRefreshSeatsButton().exists()).toBe(false);
}); });
}); });
describe.each`
availableTrialAction | buttonVisible
${null} | ${false}
${'extend'} | ${true}
${'reactivate'} | ${true}
`(
'with availableTrialAction=$availableTrialAction',
({ availableTrialAction, buttonVisible }) => {
beforeEach(() => {
createComponentWithStore({
provide: {
namespaceId: 1,
availableTrialAction,
},
});
});
if (buttonVisible) {
it('renders the trial button', () => {
expect(wrapper.findComponent(ExtendReactivateTrialButton).isVisible()).toBe(true);
});
} else {
it('does not render the trial button', () => {
expect(wrapper.findComponent(ExtendReactivateTrialButton).exists()).toBe(false);
});
}
},
);
}); });
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