Commit 7c613ed3 authored by Phil Hughes's avatar Phil Hughes

Merge branch 'ag-273028-fe' into 'master'

Display correct plan name on Subscription Activation Form

See merge request gitlab-org/gitlab!57138
parents 44e4af24 d6b25e28
<script> <script>
import { s__, sprintf } from '~/locale';
import CloudLicenseSubscriptionActivationForm from './subscription_activation_form.vue'; import CloudLicenseSubscriptionActivationForm from './subscription_activation_form.vue';
export default { export default {
...@@ -6,6 +7,10 @@ export default { ...@@ -6,6 +7,10 @@ export default {
components: { components: {
CloudLicenseSubscriptionActivationForm, CloudLicenseSubscriptionActivationForm,
}, },
i18n: {
mainTitle: s__(`CloudLicense|This instance is currently using the %{planName} plan.`),
},
inject: ['planName'],
props: { props: {
subscription: { subscription: {
required: false, required: false,
...@@ -18,14 +23,19 @@ export default { ...@@ -18,14 +23,19 @@ export default {
subscriptionData: this.subscription, subscriptionData: this.subscription,
}; };
}, },
computed: {
mainTitle() {
return sprintf(this.$options.i18n.mainTitle, {
planName: this.planName,
});
},
},
}; };
</script> </script>
<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"> <h3 class="gl-mb-7 gl-mt-6 gl-text-center">{{ mainTitle }}</h3>
{{ s__('CloudLicense|This instance is currently using the Core plan.') }}
</h3>
<cloud-license-subscription-activation-form v-if="!subscriptionData" /> <cloud-license-subscription-activation-form v-if="!subscriptionData" />
</div> </div>
</template> </template>
...@@ -12,9 +12,18 @@ const apolloProvider = new VueApollo({ ...@@ -12,9 +12,18 @@ const apolloProvider = new VueApollo({
export default () => { export default () => {
const el = document.getElementById('js-show-cloud-license-page'); const el = document.getElementById('js-show-cloud-license-page');
if (!el) {
return null;
}
const { planName } = el.dataset;
return new Vue({ return new Vue({
el, el,
apolloProvider, apolloProvider,
provide: {
planName,
},
render: (h) => h(CloudLicenseShowApp), render: (h) => h(CloudLicenseShowApp),
}); });
}; };
...@@ -50,7 +50,7 @@ module LicenseHelper ...@@ -50,7 +50,7 @@ module LicenseHelper
def cloud_license_view_data def cloud_license_view_data
{ {
current_plan_title: current_license_title plan_name: current_license_title
} }
end end
......
- page_title _('Cloud License') - page_title _('Cloud License')
#js-show-cloud-license-page #js-show-cloud-license-page{ data: cloud_license_view_data }
# frozen_string_literal: true
require "spec_helper"
RSpec.describe "Admin views Cloud License", :js do
let_it_be(:admin) { create(:admin) }
before do
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
stub_application_setting(cloud_license_enabled: true)
allow(License).to receive(:current).and_return(license)
end
License::EE_ALL_PLANS.each do |plan|
context "#{plan} license" do
let_it_be(:license) { build(:license, plan: plan) }
it 'displays the correct license name' do
visit(admin_cloud_license_path)
page.within(find('#content-body', match: :first)) do
expect(page).to have_content("This instance is currently using the #{plan.titleize} plan.")
end
end
end
end
context "when there is no license" do
let_it_be(:license) { nil }
before do
visit(admin_cloud_license_path)
end
it "displays the fallback license name" do
page.within(find('#content-body', match: :first)) do
expect(page).to have_content("This instance is currently using the Core plan.")
end
end
end
end
...@@ -15,6 +15,9 @@ describe('CloudLicenseApp', () => { ...@@ -15,6 +15,9 @@ describe('CloudLicenseApp', () => {
propsData: { propsData: {
...props, ...props,
}, },
provide: {
planName: 'Core',
},
}), }),
); );
}; };
...@@ -29,5 +32,9 @@ describe('CloudLicenseApp', () => { ...@@ -29,5 +32,9 @@ describe('CloudLicenseApp', () => {
it('presents a form', () => { it('presents a form', () => {
expect(findActivateSubscriptionForm().exists()).toBe(true); expect(findActivateSubscriptionForm().exists()).toBe(true);
}); });
it('presents a main title with the plan name', () => {
expect(wrapper.text()).toContain('Core plan');
});
}); });
}); });
...@@ -86,7 +86,7 @@ RSpec.describe LicenseHelper do ...@@ -86,7 +86,7 @@ RSpec.describe LicenseHelper do
license = double('License', plan: custom_plan) license = double('License', plan: custom_plan)
allow(License).to receive(:current).and_return(license) allow(License).to receive(:current).and_return(license)
expect(cloud_license_view_data).to eq({ current_plan_title: 'Custom Plan' }) expect(cloud_license_view_data).to eq({ plan_name: 'Custom Plan' })
end end
end end
...@@ -94,7 +94,7 @@ RSpec.describe LicenseHelper do ...@@ -94,7 +94,7 @@ RSpec.describe LicenseHelper do
it 'returns the data for the view' do it 'returns the data for the view' do
allow(License).to receive(:current).and_return(nil) allow(License).to receive(:current).and_return(nil)
expect(cloud_license_view_data).to eq({ current_plan_title: 'Core' }) expect(cloud_license_view_data).to eq({ plan_name: 'Core' })
end end
end end
end end
......
...@@ -47,7 +47,7 @@ RSpec.describe Admin::CloudLicensesController, :cloud_licenses do ...@@ -47,7 +47,7 @@ RSpec.describe Admin::CloudLicensesController, :cloud_licenses do
send_request send_request
expect(response).to render_template(:show) expect(response).to render_template(:show)
expect(response.body).to include('js-show-cloud-license-pag') expect(response.body).to include('js-show-cloud-license-page')
end end
end end
end end
......
...@@ -6440,7 +6440,7 @@ msgstr "" ...@@ -6440,7 +6440,7 @@ msgstr ""
msgid "CloudLicense|Paste your activation code below" msgid "CloudLicense|Paste your activation code below"
msgstr "" msgstr ""
msgid "CloudLicense|This instance is currently using the Core plan." msgid "CloudLicense|This instance is currently using the %{planName} plan."
msgstr "" msgstr ""
msgid "Cluster" msgid "Cluster"
......
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