Commit 40b81b90 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch '325738-adjust-activation-form' into 'master'

Cloud License - Adjust Subscription Activation Form

See merge request gitlab-org/gitlab!57738
parents 487caca8 d188d6b9
...@@ -35,7 +35,13 @@ export default { ...@@ -35,7 +35,13 @@ export default {
<template> <template>
<div class="gl-display-flex gl-justify-content-center gl-flex-direction-column"> <div class="gl-display-flex gl-justify-content-center gl-flex-direction-column">
<h3 class="gl-mb-7 gl-mt-6 gl-text-center">{{ mainTitle }}</h3> <h4>{{ s__('CloudLicense|Your subscription') }}</h4>
<cloud-license-subscription-activation-form v-if="!subscriptionData" /> <hr />
<div class="row">
<div class="col-12 col-lg-8 offset-lg-2">
<h3 class="gl-mb-7 gl-mt-6 gl-text-center">{{ mainTitle }}</h3>
<cloud-license-subscription-activation-form v-if="!subscriptionData" />
</div>
</div>
</div> </div>
</template> </template>
<script> <script>
import { GlButton, GlForm, GlFormGroup, GlFormInput } from '@gitlab/ui'; import {
GlButton,
GlCard,
GlForm,
GlFormCheckbox,
GlFormGroup,
GlFormInput,
GlLink,
GlSprintf,
} from '@gitlab/ui';
import activateSubscriptionMutation from 'ee/pages/admin/cloud_licenses/graphql/mutations/activate_subscription.mutation.graphql'; import activateSubscriptionMutation from 'ee/pages/admin/cloud_licenses/graphql/mutations/activate_subscription.mutation.graphql';
export const SUBSCRIPTION_ACTIVATION_EVENT = 'subscription-activation'; export const SUBSCRIPTION_ACTIVATION_EVENT = 'subscription-activation';
...@@ -8,16 +17,26 @@ export default { ...@@ -8,16 +17,26 @@ export default {
name: 'CloudLicenseSubscriptionActivationForm', name: 'CloudLicenseSubscriptionActivationForm',
components: { components: {
GlButton, GlButton,
GlCard,
GlForm, GlForm,
GlFormGroup, GlFormGroup,
GlFormInput, GlFormInput,
GlFormCheckbox,
GlSprintf,
GlLink,
}, },
data() { data() {
return { return {
activationCode: null, activationCode: null,
isLoading: false, isLoading: false,
termsAccepted: false,
}; };
}, },
computed: {
activateButtonDisabled() {
return this.isLoading || !this.termsAccepted;
},
},
methods: { methods: {
submit() { submit() {
this.isLoading = true; this.isLoading = true;
...@@ -53,32 +72,65 @@ export default { ...@@ -53,32 +72,65 @@ export default {
}; };
</script> </script>
<template> <template>
<gl-form @submit.stop.prevent="submit"> <gl-card>
<gl-form-group> <template #header>
<div class="gl-display-flex gl-flex-wrap gl-justify-content-center"> <h5 class="gl-my-0 gl-font-weight-bold">{{ s__('CloudLicense|Activate subscription') }}</h5>
<label class="gl-text-center gl-w-full" for="activation-code-group"> </template>
{{ s__('CloudLicense|Paste your activation code below') }}
</label> <p>
<gl-form-input <gl-sprintf
id="activation-code-group" :message="
v-model="activationCode" s__('CloudLicense|Learn how to %{linkStart}activate your subscription%{linkEnd}.')
:disabled="isLoading" "
:placeholder="s__('CloudLicense|Paste your activation code')" >
class="gl-mr-3" <template #link="{ content }">
required <gl-link href="" target="_blank">{{ content }}</gl-link>
size="xl" </template>
/> </gl-sprintf>
<gl-button </p>
:disabled="isLoading" <gl-form @submit.stop.prevent="submit">
category="primary" <gl-form-group class="gl-mb-0">
class="gl-align-self-end" <div class="gl-display-flex gl-flex-wrap">
data-testid="activate-button" <label class="gl-w-full" for="activation-code-group">
type="submit" {{ s__('CloudLicense|Activation code') }}
variant="confirm" </label>
> <gl-form-input
{{ s__('CloudLicense|Activate') }} id="activation-code-group"
</gl-button> v-model="activationCode"
</div> :disabled="isLoading"
</gl-form-group> :placeholder="s__('CloudLicense|Paste your activation code')"
</gl-form> class="gl-w-full gl-mb-4"
required
/>
<gl-form-checkbox v-model="termsAccepted">
<gl-sprintf
:message="
s__(
'CloudLicense|I agree that my use of the GitLab Software is subject to the Subscription Agreement located at the %{linkStart}Terms of Service%{linkEnd}, unless otherwise agreed to in writing with GitLab.',
)
"
>
<template #link="{ content }">
<gl-link href="https://about.gitlab.com/terms/" target="_blank">{{
content
}}</gl-link>
</template>
</gl-sprintf>
</gl-form-checkbox>
<gl-button
:disabled="activateButtonDisabled"
category="primary"
class="gl-mt-6"
data-testid="activate-button"
type="submit"
variant="confirm"
>
{{ s__('CloudLicense|Activate') }}
</gl-button>
</div>
</gl-form-group>
</gl-form>
</gl-card>
</template> </template>
import { GlForm, GlFormInput } from '@gitlab/ui'; import { GlForm, GlFormInput, GlFormCheckbox } from '@gitlab/ui';
import { createLocalVue, shallowMount } from '@vue/test-utils'; import { createLocalVue, shallowMount } from '@vue/test-utils';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import CloudLicenseSubscriptionActivationForm, { import CloudLicenseSubscriptionActivationForm, {
...@@ -25,8 +25,10 @@ describe('CloudLicenseApp', () => { ...@@ -25,8 +25,10 @@ describe('CloudLicenseApp', () => {
}; };
const findActivateButton = () => wrapper.findByTestId('activate-button'); const findActivateButton = () => wrapper.findByTestId('activate-button');
const findAgreementCheckbox = () => wrapper.findComponent(GlFormCheckbox);
const findActivationCodeInput = () => wrapper.findComponent(GlFormInput); const findActivationCodeInput = () => wrapper.findComponent(GlFormInput);
const findActivateSubscriptionForm = () => wrapper.findComponent(GlForm); const findActivateSubscriptionForm = () => wrapper.findComponent(GlForm);
const enableAcceptAgreementCheckbox = () => findAgreementCheckbox().vm.$emit('input', true);
const GlFormInputStub = stubComponent(GlFormInput, { const GlFormInputStub = stubComponent(GlFormInput, {
template: `<input />`, template: `<input />`,
...@@ -69,6 +71,21 @@ describe('CloudLicenseApp', () => { ...@@ -69,6 +71,21 @@ describe('CloudLicenseApp', () => {
it('has an `Activate` button', () => { it('has an `Activate` button', () => {
expect(findActivateButton().text()).toBe('Activate'); expect(findActivateButton().text()).toBe('Activate');
});
it('has a checkbox to accept subscription agreement', () => {
expect(findAgreementCheckbox().exists()).toBe(true);
});
it('disables the activate button if the agreement is unaccepted', () => {
expect(findActivateButton().props('disabled')).toBe(true);
});
it('enables the activate button if the agreement is accepted', async () => {
expect(findActivateButton().props('disabled')).toBe(true);
enableAcceptAgreementCheckbox();
await wrapper.vm.$nextTick();
expect(findActivateButton().props('disabled')).toBe(false); expect(findActivateButton().props('disabled')).toBe(false);
}); });
}); });
......
...@@ -6435,12 +6435,24 @@ msgstr "" ...@@ -6435,12 +6435,24 @@ msgstr ""
msgid "CloudLicense|Activate" msgid "CloudLicense|Activate"
msgstr "" msgstr ""
msgid "CloudLicense|Activate subscription"
msgstr ""
msgid "CloudLicense|Activation code"
msgstr ""
msgid "CloudLicense|I agree that my use of the GitLab Software is subject to the Subscription Agreement located at the %{linkStart}Terms of Service%{linkEnd}, unless otherwise agreed to in writing with GitLab."
msgstr ""
msgid "CloudLicense|ID" msgid "CloudLicense|ID"
msgstr "" msgstr ""
msgid "CloudLicense|Last Sync" msgid "CloudLicense|Last Sync"
msgstr "" msgstr ""
msgid "CloudLicense|Learn how to %{linkStart}activate your subscription%{linkEnd}."
msgstr ""
msgid "CloudLicense|Licensed to" msgid "CloudLicense|Licensed to"
msgstr "" msgstr ""
...@@ -6450,9 +6462,6 @@ msgstr "" ...@@ -6450,9 +6462,6 @@ msgstr ""
msgid "CloudLicense|Paste your activation code" msgid "CloudLicense|Paste your activation code"
msgstr "" msgstr ""
msgid "CloudLicense|Paste your activation code below"
msgstr ""
msgid "CloudLicense|Plan" msgid "CloudLicense|Plan"
msgstr "" msgstr ""
...@@ -6471,6 +6480,9 @@ msgstr "" ...@@ -6471,6 +6480,9 @@ msgstr ""
msgid "CloudLicense|This instance is currently using the %{planName} plan." msgid "CloudLicense|This instance is currently using the %{planName} plan."
msgstr "" msgstr ""
msgid "CloudLicense|Your subscription"
msgstr ""
msgid "Cluster" msgid "Cluster"
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