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">
<h4>{{ s__('CloudLicense|Your subscription') }}</h4>
<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> <h3 class="gl-mb-7 gl-mt-6 gl-text-center">{{ mainTitle }}</h3>
<cloud-license-subscription-activation-form v-if="!subscriptionData" /> <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,25 +72,57 @@ export default { ...@@ -53,25 +72,57 @@ export default {
}; };
</script> </script>
<template> <template>
<gl-card>
<template #header>
<h5 class="gl-my-0 gl-font-weight-bold">{{ s__('CloudLicense|Activate subscription') }}</h5>
</template>
<p>
<gl-sprintf
:message="
s__('CloudLicense|Learn how to %{linkStart}activate your subscription%{linkEnd}.')
"
>
<template #link="{ content }">
<gl-link href="" target="_blank">{{ content }}</gl-link>
</template>
</gl-sprintf>
</p>
<gl-form @submit.stop.prevent="submit"> <gl-form @submit.stop.prevent="submit">
<gl-form-group> <gl-form-group class="gl-mb-0">
<div class="gl-display-flex gl-flex-wrap gl-justify-content-center"> <div class="gl-display-flex gl-flex-wrap">
<label class="gl-text-center gl-w-full" for="activation-code-group"> <label class="gl-w-full" for="activation-code-group">
{{ s__('CloudLicense|Paste your activation code below') }} {{ s__('CloudLicense|Activation code') }}
</label> </label>
<gl-form-input <gl-form-input
id="activation-code-group" id="activation-code-group"
v-model="activationCode" v-model="activationCode"
:disabled="isLoading" :disabled="isLoading"
:placeholder="s__('CloudLicense|Paste your activation code')" :placeholder="s__('CloudLicense|Paste your activation code')"
class="gl-mr-3" class="gl-w-full gl-mb-4"
required required
size="xl"
/> />
<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 <gl-button
:disabled="isLoading" :disabled="activateButtonDisabled"
category="primary" category="primary"
class="gl-align-self-end" class="gl-mt-6"
data-testid="activate-button" data-testid="activate-button"
type="submit" type="submit"
variant="confirm" variant="confirm"
...@@ -81,4 +132,5 @@ export default { ...@@ -81,4 +132,5 @@ export default {
</div> </div>
</gl-form-group> </gl-form-group>
</gl-form> </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