Commit 3f11cf97 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch 'ag-332490-activate-cl' into 'master'

Add button for mid-term upgrade

See merge request gitlab-org/gitlab!64325
parents 1fa77357 b5f49121
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import { GlButton, GlModalDirective } from '@gitlab/ui'; import { GlButton, GlModalDirective } from '@gitlab/ui';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { import {
activateCloudLicense,
enterActivationCode, enterActivationCode,
licensedToHeaderText, licensedToHeaderText,
manageSubscriptionButtonText, manageSubscriptionButtonText,
...@@ -24,6 +25,7 @@ export const modalId = 'subscription-activation-modal'; ...@@ -24,6 +25,7 @@ export const modalId = 'subscription-activation-modal';
export default { export default {
i18n: { i18n: {
activateCloudLicense,
enterActivationCode, enterActivationCode,
licensedToHeaderText, licensedToHeaderText,
manageSubscriptionButtonText, manageSubscriptionButtonText,
...@@ -69,6 +71,12 @@ export default { ...@@ -69,6 +71,12 @@ export default {
}; };
}, },
computed: { computed: {
canActivateSubscription() {
return this.isLicenseFileType;
},
canEnterActivationCode() {
return this.isCloudType;
},
canManageSubscription() { canManageSubscription() {
return this.customersPortalUrl && this.hasSubscription; return this.customersPortalUrl && this.hasSubscription;
}, },
...@@ -95,6 +103,7 @@ export default { ...@@ -95,6 +103,7 @@ export default {
}, },
shouldShowFooter() { shouldShowFooter() {
return ( return (
this.canActivateSubscription ||
this.canRemoveLicense || this.canRemoveLicense ||
this.canManageSubscription || this.canManageSubscription ||
this.canSyncSubscription || this.canSyncSubscription ||
...@@ -161,11 +170,20 @@ export default { ...@@ -161,11 +170,20 @@ export default {
{{ $options.i18n.syncSubscriptionButtonText }} {{ $options.i18n.syncSubscriptionButtonText }}
</gl-button> </gl-button>
<gl-button <gl-button
v-if="hasSubscription" v-if="canActivateSubscription"
v-gl-modal="$options.modal.id"
category="primary"
variant="confirm"
data-testid="subscription-activate-subscription-action"
>
{{ $options.i18n.activateCloudLicense }}
</gl-button>
<gl-button
v-if="canEnterActivationCode"
v-gl-modal="$options.modal.id" v-gl-modal="$options.modal.id"
category="primary" category="primary"
variant="confirm" variant="confirm"
data-testid="subscription-activation-action" data-testid="subscription-enter-code-action"
> >
{{ $options.i18n.enterActivationCode }} {{ $options.i18n.enterActivationCode }}
</gl-button> </gl-button>
......
...@@ -17,6 +17,7 @@ export const howToActivateSubscription = s__( ...@@ -17,6 +17,7 @@ export const howToActivateSubscription = s__(
export const activateLabel = s__('SuperSonics|Activate'); export const activateLabel = s__('SuperSonics|Activate');
export const activateSubscription = s__('SuperSonics|Activate subscription'); export const activateSubscription = s__('SuperSonics|Activate subscription');
export const enterActivationCode = s__('SuperSonics|Enter activation code'); export const enterActivationCode = s__('SuperSonics|Enter activation code');
export const activateCloudLicense = s__('SuperSonics|Activate cloud license');
export const noActiveSubscription = s__(`SuperSonics|You do not have an active subscription`); export const noActiveSubscription = s__(`SuperSonics|You do not have an active subscription`);
export const subscriptionDetailsHeaderText = s__('SuperSonics|Subscription details'); export const subscriptionDetailsHeaderText = s__('SuperSonics|Subscription details');
export const licensedToHeaderText = s__('SuperSonics|Licensed to'); export const licensedToHeaderText = s__('SuperSonics|Licensed to');
......
...@@ -70,7 +70,7 @@ RSpec.describe 'Admin views Subscription', :js do ...@@ -70,7 +70,7 @@ RSpec.describe 'Admin views Subscription', :js do
context 'when activating another subscription' do context 'when activating another subscription' do
before do before do
click_button('Enter activation code') click_button('Activate cloud license')
end end
it 'shows the activation modal' do it 'shows the activation modal' do
......
...@@ -43,8 +43,9 @@ describe('Subscription Breakdown', () => { ...@@ -43,8 +43,9 @@ describe('Subscription Breakdown', () => {
const findDetailsUserInfo = () => wrapper.findComponent(SubscriptionDetailsUserInfo); const findDetailsUserInfo = () => wrapper.findComponent(SubscriptionDetailsUserInfo);
const findLicenseUploadAction = () => wrapper.findByTestId('license-upload-action'); const findLicenseUploadAction = () => wrapper.findByTestId('license-upload-action');
const findLicenseRemoveAction = () => wrapper.findByTestId('license-remove-action'); const findLicenseRemoveAction = () => wrapper.findByTestId('license-remove-action');
const findSubscriptionActivationAction = () => const findActivateSubscriptionAction = () =>
wrapper.findByTestId('subscription-activation-action'); wrapper.findByTestId('subscription-activate-subscription-action');
const findEnterCodeAction = () => wrapper.findByTestId('subscription-enter-code-action');
const findSubscriptionMangeAction = () => wrapper.findByTestId('subscription-manage-action'); const findSubscriptionMangeAction = () => wrapper.findByTestId('subscription-manage-action');
const findSubscriptionSyncAction = () => wrapper.findByTestId('subscription-sync-action'); const findSubscriptionSyncAction = () => wrapper.findByTestId('subscription-sync-action');
const findSubscriptionActivationModal = () => wrapper.findComponent(SubscriptionActivationModal); const findSubscriptionActivationModal = () => wrapper.findComponent(SubscriptionActivationModal);
...@@ -137,12 +138,6 @@ describe('Subscription Breakdown', () => { ...@@ -137,12 +138,6 @@ describe('Subscription Breakdown', () => {
expect(findDetailsCardFooter().exists()).toBe(true); expect(findDetailsCardFooter().exists()).toBe(true);
}); });
it('shows a button to activate a new subscription', () => {
createComponent({ stubs: { GlCard, SubscriptionDetailsCard } });
expect(findSubscriptionActivationAction().exists()).toBe(true);
});
it('presents a subscription activation modal', () => { it('presents a subscription activation modal', () => {
expect(findSubscriptionActivationModal().exists()).toBe(true); expect(findSubscriptionActivationModal().exists()).toBe(true);
}); });
...@@ -248,6 +243,36 @@ describe('Subscription Breakdown', () => { ...@@ -248,6 +243,36 @@ describe('Subscription Breakdown', () => {
expect(findLicenseRemoveAction().exists()).toBe(shouldShow); expect(findLicenseRemoveAction().exists()).toBe(shouldShow);
}, },
); );
it.each`
type | shouldShow
${subscriptionTypes.LICENSE_FILE} | ${true}
${subscriptionTypes.CLOUD} | ${false}
`(
'with url is $url and type is $type the activate cloud license button is shown: $shouldShow',
({ type, shouldShow }) => {
const props = { subscription: { ...license.ULTIMATE, type } };
const stubs = { GlCard, SubscriptionDetailsCard };
createComponent({ props, stubs });
expect(findActivateSubscriptionAction().exists()).toBe(shouldShow);
},
);
it.each`
type | shouldShow
${subscriptionTypes.LICENSE_FILE} | ${false}
${subscriptionTypes.CLOUD} | ${true}
`(
'with url is $url and type is $type the enter activation code button is shown: $shouldShow',
({ type, shouldShow }) => {
const props = { subscription: { ...license.ULTIMATE, type } };
const stubs = { GlCard, SubscriptionDetailsCard };
createComponent({ props, stubs });
expect(findEnterCodeAction().exists()).toBe(shouldShow);
},
);
}); });
describe('with a license file', () => { describe('with a license file', () => {
...@@ -269,6 +294,14 @@ describe('Subscription Breakdown', () => { ...@@ -269,6 +294,14 @@ describe('Subscription Breakdown', () => {
it('does not show the sync subscription notifications', () => { it('does not show the sync subscription notifications', () => {
expect(findSubscriptionSyncNotifications().exists()).toBe(false); expect(findSubscriptionSyncNotifications().exists()).toBe(false);
}); });
it('shows a modal', () => {
const props = { subscription: { ...licenseFile } };
createComponent({ props, stubs: { GlCard, SubscriptionDetailsCard } });
findActivateSubscriptionAction().vm.$emit('click');
expect(glModalDirective).toHaveBeenCalledWith(modalId);
});
}); });
describe('sync a subscription success', () => { describe('sync a subscription success', () => {
...@@ -372,7 +405,7 @@ describe('Subscription Breakdown', () => { ...@@ -372,7 +405,7 @@ describe('Subscription Breakdown', () => {
describe('activating a new subscription', () => { describe('activating a new subscription', () => {
it('shows a modal', () => { it('shows a modal', () => {
createComponent({ stubs: { GlCard, SubscriptionDetailsCard } }); createComponent({ stubs: { GlCard, SubscriptionDetailsCard } });
findSubscriptionActivationAction().vm.$emit('click'); findEnterCodeAction().vm.$emit('click');
expect(glModalDirective).toHaveBeenCalledWith(modalId); expect(glModalDirective).toHaveBeenCalledWith(modalId);
}); });
......
...@@ -31389,6 +31389,9 @@ msgstr "" ...@@ -31389,6 +31389,9 @@ msgstr ""
msgid "SuperSonics|Activate" msgid "SuperSonics|Activate"
msgstr "" msgstr ""
msgid "SuperSonics|Activate cloud license"
msgstr ""
msgid "SuperSonics|Activate subscription" msgid "SuperSonics|Activate subscription"
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