Commit 7013161f authored by Angelo Gulina's avatar Angelo Gulina Committed by Kushal Pandya

Subscription Activation: Upload License Link

parent 5fdc6450
...@@ -7,6 +7,7 @@ import { ...@@ -7,6 +7,7 @@ import {
connectivityErrorAlert, connectivityErrorAlert,
connectivityIssue, connectivityIssue,
howToActivateSubscription, howToActivateSubscription,
uploadLegacyLicense,
} from '../constants'; } from '../constants';
import SubscriptionActivationForm from './subscription_activation_form.vue'; import SubscriptionActivationForm from './subscription_activation_form.vue';
...@@ -22,11 +23,7 @@ export default { ...@@ -22,11 +23,7 @@ export default {
connectivityIssueSubtitle: connectivityErrorAlert.subtitle, connectivityIssueSubtitle: connectivityErrorAlert.subtitle,
connectivityIssueHelpText: connectivityErrorAlert.helpText, connectivityIssueHelpText: connectivityErrorAlert.helpText,
howToActivateSubscription, howToActivateSubscription,
}, uploadLegacyLicense,
links: {
adminLicenseUrl,
subscriptionActivationHelpLink,
troubleshootingHelpLink,
}, },
components: { components: {
GlAlert, GlAlert,
...@@ -35,6 +32,12 @@ export default { ...@@ -35,6 +32,12 @@ export default {
GlSprintf, GlSprintf,
SubscriptionActivationForm, SubscriptionActivationForm,
}, },
inject: ['licenseUploadPath'],
links: {
adminLicenseUrl,
subscriptionActivationHelpLink,
troubleshootingHelpLink,
},
data() { data() {
return { return {
error: null, error: null,
...@@ -98,5 +101,13 @@ export default { ...@@ -98,5 +101,13 @@ export default {
class="gl-p-5" class="gl-p-5"
@subscription-activation-failure="handleFormActivationFailure" @subscription-activation-failure="handleFormActivationFailure"
/> />
<template #footer>
<gl-link
v-if="licenseUploadPath"
data-testid="upload-license-link"
:href="licenseUploadPath"
>{{ $options.i18n.uploadLegacyLicense }}</gl-link
>
</template>
</gl-card> </gl-card>
</template> </template>
...@@ -37,6 +37,7 @@ export const detailsLabels = { ...@@ -37,6 +37,7 @@ export const detailsLabels = {
startsAt: s__('SuperSonics|Started'), startsAt: s__('SuperSonics|Started'),
}; };
export const uploadLegacyLicense = s__('SuperSonics|Upload a legacy license');
export const billableUsersTitle = s__('CloudLicense|Billable users'); export const billableUsersTitle = s__('CloudLicense|Billable users');
export const maximumUsersTitle = s__('CloudLicense|Maximum users'); export const maximumUsersTitle = s__('CloudLicense|Maximum users');
export const usersInSubscriptionTitle = s__('CloudLicense|Users in subscription'); export const usersInSubscriptionTitle = s__('CloudLicense|Users in subscription');
......
...@@ -23,7 +23,13 @@ export default () => { ...@@ -23,7 +23,13 @@ export default () => {
return null; return null;
} }
const { hasActiveLicense, freeTrialPath, buySubscriptionPath, subscriptionSyncPath } = el.dataset; const {
buySubscriptionPath,
freeTrialPath,
hasActiveLicense,
licenseUploadPath,
subscriptionSyncPath,
} = el.dataset;
const connectivityHelpURL = helpPagePath('/user/admin_area/license.html', { const connectivityHelpURL = helpPagePath('/user/admin_area/license.html', {
anchor: 'activate-gitlab-ee-with-a-license', anchor: 'activate-gitlab-ee-with-a-license',
}); });
...@@ -32,9 +38,10 @@ export default () => { ...@@ -32,9 +38,10 @@ export default () => {
el, el,
apolloProvider, apolloProvider,
provide: { provide: {
freeTrialPath,
buySubscriptionPath, buySubscriptionPath,
connectivityHelpURL, connectivityHelpURL,
freeTrialPath,
licenseUploadPath,
subscriptionSyncPath, subscriptionSyncPath,
}, },
render: (h) => render: (h) =>
......
...@@ -57,7 +57,8 @@ module LicenseHelper ...@@ -57,7 +57,8 @@ module LicenseHelper
has_active_license: (has_active_license? ? 'true' : 'false'), has_active_license: (has_active_license? ? 'true' : 'false'),
free_trial_path: new_trial_url, free_trial_path: new_trial_url,
buy_subscription_path: ::EE::SUBSCRIPTIONS_PLANS_URL, buy_subscription_path: ::EE::SUBSCRIPTIONS_PLANS_URL,
subscription_sync_path: sync_seat_link_admin_license_path subscription_sync_path: sync_seat_link_admin_license_path,
license_upload_path: new_admin_license_path
} }
end end
......
...@@ -59,5 +59,13 @@ RSpec.describe 'Admin views Cloud License', :js do ...@@ -59,5 +59,13 @@ RSpec.describe 'Admin views Cloud License', :js do
expect(page).to have_content('You do not have an active subscription') expect(page).to have_content('You do not have an active subscription')
end end
end end
context 'Upload Legacy License' do
it 'shows a link to upload a legacy license' do
page.within(find('#content-body', match: :first)) do
expect(page).to have_link('Upload a legacy license', href: new_admin_license_path)
end
end
end
end end
end end
import { GlAlert, GlLink, GlSprintf } from '@gitlab/ui'; import { GlAlert, GlCard, GlLink, GlSprintf } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import SubscriptionActivationCard, { import SubscriptionActivationCard, {
subscriptionActivationHelpLink, subscriptionActivationHelpLink,
...@@ -13,15 +13,21 @@ import { extendedWrapper } from 'helpers/vue_test_utils_helper'; ...@@ -13,15 +13,21 @@ import { extendedWrapper } from 'helpers/vue_test_utils_helper';
describe('CloudLicenseApp', () => { describe('CloudLicenseApp', () => {
let wrapper; let wrapper;
const licenseUploadPath = 'license/upload';
const findConnectivityErrorAlert = () => wrapper.findComponent(GlAlert); const findConnectivityErrorAlert = () => wrapper.findComponent(GlAlert);
const findSubscriptionActivationForm = () => wrapper.findComponent(SubscriptionActivationForm); const findSubscriptionActivationForm = () => wrapper.findComponent(SubscriptionActivationForm);
const findUploadLink = () => wrapper.findByTestId('upload-license-link');
const createComponent = ({ props = {}, stubs = {} } = {}) => { const createComponent = ({ props = {}, stubs = {}, provide = {} } = {}) => {
wrapper = extendedWrapper( wrapper = extendedWrapper(
shallowMount(SubscriptionActivationCard, { shallowMount(SubscriptionActivationCard, {
propsData: { propsData: {
...props, ...props,
}, },
provide: {
licenseUploadPath,
...provide,
},
stubs, stubs,
}), }),
); );
...@@ -43,6 +49,31 @@ describe('CloudLicenseApp', () => { ...@@ -43,6 +49,31 @@ describe('CloudLicenseApp', () => {
expect(findConnectivityErrorAlert().exists()).toBe(false); expect(findConnectivityErrorAlert().exists()).toBe(false);
}); });
describe('with an upload legacy license link', () => {
beforeEach(() => {
createComponent({ stubs: { GlCard } });
});
it('shows a link when provided', () => {
expect(findUploadLink().text()).toBe('Upload a legacy license');
});
it('provides the correct path', () => {
expect(findUploadLink().attributes('href')).toBe(licenseUploadPath);
});
});
it('does not show a link when legacy license link is not provided', () => {
createComponent({
stubs: { GlCard },
provide: {
licenseUploadPath: '',
},
});
expect(findUploadLink().exists()).toBe(false);
});
describe('when the forms emits a connectivity error', () => { describe('when the forms emits a connectivity error', () => {
beforeEach(() => { beforeEach(() => {
createComponent({ stubs: { GlSprintf } }); createComponent({ stubs: { GlSprintf } });
......
...@@ -95,7 +95,8 @@ RSpec.describe LicenseHelper do ...@@ -95,7 +95,8 @@ RSpec.describe LicenseHelper do
expect(helper.cloud_license_view_data).to eq({ has_active_license: 'true', expect(helper.cloud_license_view_data).to eq({ has_active_license: 'true',
free_trial_path: 'new_trial_url', free_trial_path: 'new_trial_url',
buy_subscription_path: 'subscriptions_plans_url', buy_subscription_path: 'subscriptions_plans_url',
subscription_sync_path: sync_seat_link_admin_license_path }) subscription_sync_path: sync_seat_link_admin_license_path,
license_upload_path: new_admin_license_path })
end end
end end
...@@ -106,7 +107,8 @@ RSpec.describe LicenseHelper do ...@@ -106,7 +107,8 @@ RSpec.describe LicenseHelper do
expect(helper.cloud_license_view_data).to eq({ has_active_license: 'false', expect(helper.cloud_license_view_data).to eq({ has_active_license: 'false',
free_trial_path: 'new_trial_url', free_trial_path: 'new_trial_url',
buy_subscription_path: 'subscriptions_plans_url', buy_subscription_path: 'subscriptions_plans_url',
subscription_sync_path: sync_seat_link_admin_license_path }) subscription_sync_path: sync_seat_link_admin_license_path,
license_upload_path: new_admin_license_path })
end end
end end
end end
......
...@@ -31127,6 +31127,9 @@ msgstr "" ...@@ -31127,6 +31127,9 @@ msgstr ""
msgid "SuperSonics|Type" msgid "SuperSonics|Type"
msgstr "" msgstr ""
msgid "SuperSonics|Upload a legacy license"
msgstr ""
msgid "SuperSonics|Valid From" msgid "SuperSonics|Valid From"
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