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 {
connectivityErrorAlert,
connectivityIssue,
howToActivateSubscription,
uploadLegacyLicense,
} from '../constants';
import SubscriptionActivationForm from './subscription_activation_form.vue';
......@@ -22,11 +23,7 @@ export default {
connectivityIssueSubtitle: connectivityErrorAlert.subtitle,
connectivityIssueHelpText: connectivityErrorAlert.helpText,
howToActivateSubscription,
},
links: {
adminLicenseUrl,
subscriptionActivationHelpLink,
troubleshootingHelpLink,
uploadLegacyLicense,
},
components: {
GlAlert,
......@@ -35,6 +32,12 @@ export default {
GlSprintf,
SubscriptionActivationForm,
},
inject: ['licenseUploadPath'],
links: {
adminLicenseUrl,
subscriptionActivationHelpLink,
troubleshootingHelpLink,
},
data() {
return {
error: null,
......@@ -98,5 +101,13 @@ export default {
class="gl-p-5"
@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>
</template>
......@@ -37,6 +37,7 @@ export const detailsLabels = {
startsAt: s__('SuperSonics|Started'),
};
export const uploadLegacyLicense = s__('SuperSonics|Upload a legacy license');
export const billableUsersTitle = s__('CloudLicense|Billable users');
export const maximumUsersTitle = s__('CloudLicense|Maximum users');
export const usersInSubscriptionTitle = s__('CloudLicense|Users in subscription');
......
......@@ -23,7 +23,13 @@ export default () => {
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', {
anchor: 'activate-gitlab-ee-with-a-license',
});
......@@ -32,9 +38,10 @@ export default () => {
el,
apolloProvider,
provide: {
freeTrialPath,
buySubscriptionPath,
connectivityHelpURL,
freeTrialPath,
licenseUploadPath,
subscriptionSyncPath,
},
render: (h) =>
......
......@@ -57,7 +57,8 @@ module LicenseHelper
has_active_license: (has_active_license? ? 'true' : 'false'),
free_trial_path: new_trial_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
......
......@@ -59,5 +59,13 @@ RSpec.describe 'Admin views Cloud License', :js do
expect(page).to have_content('You do not have an active subscription')
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
import { GlAlert, GlLink, GlSprintf } from '@gitlab/ui';
import { GlAlert, GlCard, GlLink, GlSprintf } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import SubscriptionActivationCard, {
subscriptionActivationHelpLink,
......@@ -13,15 +13,21 @@ import { extendedWrapper } from 'helpers/vue_test_utils_helper';
describe('CloudLicenseApp', () => {
let wrapper;
const licenseUploadPath = 'license/upload';
const findConnectivityErrorAlert = () => wrapper.findComponent(GlAlert);
const findSubscriptionActivationForm = () => wrapper.findComponent(SubscriptionActivationForm);
const findUploadLink = () => wrapper.findByTestId('upload-license-link');
const createComponent = ({ props = {}, stubs = {} } = {}) => {
const createComponent = ({ props = {}, stubs = {}, provide = {} } = {}) => {
wrapper = extendedWrapper(
shallowMount(SubscriptionActivationCard, {
propsData: {
...props,
},
provide: {
licenseUploadPath,
...provide,
},
stubs,
}),
);
......@@ -43,6 +49,31 @@ describe('CloudLicenseApp', () => {
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', () => {
beforeEach(() => {
createComponent({ stubs: { GlSprintf } });
......
......@@ -95,7 +95,8 @@ RSpec.describe LicenseHelper do
expect(helper.cloud_license_view_data).to eq({ has_active_license: 'true',
free_trial_path: 'new_trial_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
......@@ -106,7 +107,8 @@ RSpec.describe LicenseHelper do
expect(helper.cloud_license_view_data).to eq({ has_active_license: 'false',
free_trial_path: 'new_trial_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
......
......@@ -31127,6 +31127,9 @@ msgstr ""
msgid "SuperSonics|Type"
msgstr ""
msgid "SuperSonics|Upload a legacy license"
msgstr ""
msgid "SuperSonics|Valid From"
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