Commit faae54e9 authored by Vitaly Slobodin's avatar Vitaly Slobodin Committed by James Lopez

Make customer portal URL configurable

This commit adds the ability to set up
the URL of the customer portal via
an environment variable so all
requests and URLs can be routed
to local instance of customer portal.
parent 7909b52f
...@@ -11,12 +11,17 @@ export default { ...@@ -11,12 +11,17 @@ export default {
planUpgradeHref: { planUpgradeHref: {
type: String, type: String,
required: false, required: false,
default: null, default: '',
}, },
namespaceId: { namespaceId: {
type: String, type: String,
required: false, required: false,
default: null, default: '',
},
customerPortalUrl: {
type: String,
required: false,
default: '',
}, },
namespaceName: { namespaceName: {
type: String, type: String,
...@@ -33,5 +38,9 @@ export default { ...@@ -33,5 +38,9 @@ export default {
</script> </script>
<template> <template>
<subscription-table :namespace-name="namespaceName" :plan-upgrade-href="planUpgradeHref" /> <subscription-table
:namespace-name="namespaceName"
:plan-upgrade-href="planUpgradeHref"
:customer-portal-url="customerPortalUrl"
/>
</template> </template>
...@@ -4,12 +4,7 @@ import { mapActions, mapState, mapGetters } from 'vuex'; ...@@ -4,12 +4,7 @@ import { mapActions, mapState, mapGetters } from 'vuex';
import { GlLoadingIcon } from '@gitlab/ui'; import { GlLoadingIcon } from '@gitlab/ui';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import SubscriptionTableRow from './subscription_table_row.vue'; import SubscriptionTableRow from './subscription_table_row.vue';
import { import { TABLE_TYPE_DEFAULT, TABLE_TYPE_FREE, TABLE_TYPE_TRIAL } from '../constants';
CUSTOMER_PORTAL_URL,
TABLE_TYPE_DEFAULT,
TABLE_TYPE_FREE,
TABLE_TYPE_TRIAL,
} from '../constants';
export default { export default {
name: 'SubscriptionTable', name: 'SubscriptionTable',
...@@ -22,10 +17,15 @@ export default { ...@@ -22,10 +17,15 @@ export default {
type: String, type: String,
required: true, required: true,
}, },
customerPortalUrl: {
type: String,
required: false,
default: '',
},
planUpgradeHref: { planUpgradeHref: {
type: String, type: String,
required: false, required: false,
default: null, default: '',
}, },
}, },
computed: { computed: {
...@@ -44,7 +44,8 @@ export default { ...@@ -44,7 +44,8 @@ export default {
return { return {
text: s__('SubscriptionTable|Upgrade'), text: s__('SubscriptionTable|Upgrade'),
href: !this.isFreePlan && this.planUpgradeHref ? this.planUpgradeHref : CUSTOMER_PORTAL_URL, href:
!this.isFreePlan && this.planUpgradeHref ? this.planUpgradeHref : this.customerPortalUrl,
}; };
}, },
manageButton() { manageButton() {
...@@ -54,7 +55,7 @@ export default { ...@@ -54,7 +55,7 @@ export default {
return { return {
text: s__('SubscriptionTable|Manage'), text: s__('SubscriptionTable|Manage'),
href: CUSTOMER_PORTAL_URL, href: this.customerPortalUrl,
}; };
}, },
buttons() { buttons() {
...@@ -78,7 +79,6 @@ export default { ...@@ -78,7 +79,6 @@ export default {
methods: { methods: {
...mapActions('subscription', ['fetchSubscription']), ...mapActions('subscription', ['fetchSubscription']),
}, },
customerPortalUrl: CUSTOMER_PORTAL_URL,
}; };
</script> </script>
...@@ -89,7 +89,7 @@ export default { ...@@ -89,7 +89,7 @@ export default {
class="card prepend-top-default subscription-table js-subscription-table" class="card prepend-top-default subscription-table js-subscription-table"
> >
<div class="js-subscription-header card-header"> <div class="js-subscription-header card-header">
<strong> {{ subscriptionHeader }} </strong> <strong>{{ subscriptionHeader }}</strong>
<div class="controls"> <div class="controls">
<a <a
v-for="(button, index) in buttons" v-for="(button, index) in buttons"
...@@ -99,9 +99,8 @@ export default { ...@@ -99,9 +99,8 @@ export default {
rel="noopener noreferrer" rel="noopener noreferrer"
class="btn btn-inverted-secondary" class="btn btn-inverted-secondary"
:class="{ 'ml-2': index !== 0 }" :class="{ 'ml-2': index !== 0 }"
>{{ button.text }}</a
> >
{{ button.text }}
</a>
</div> </div>
</div> </div>
<div class="card-body flex-grid d-flex flex-column flex-sm-row flex-md-row flex-lg-column"> <div class="card-body flex-grid d-flex flex-column flex-sm-row flex-md-row flex-lg-column">
......
export const CUSTOMER_PORTAL_URL = 'https://customers.gitlab.com/subscriptions';
export const TABLE_TYPE_DEFAULT = 'default'; export const TABLE_TYPE_DEFAULT = 'default';
export const TABLE_TYPE_FREE = 'free'; export const TABLE_TYPE_FREE = 'free';
export const TABLE_TYPE_TRIAL = 'trial'; export const TABLE_TYPE_TRIAL = 'trial';
...@@ -17,12 +17,13 @@ export default (containerId = 'js-billing-plans') => { ...@@ -17,12 +17,13 @@ export default (containerId = 'js-billing-plans') => {
}, },
data() { data() {
const { dataset } = this.$options.el; const { dataset } = this.$options.el;
const { namespaceId, namespaceName, planUpgradeHref } = dataset; const { namespaceId, namespaceName, planUpgradeHref, customerPortalUrl } = dataset;
return { return {
namespaceId, namespaceId,
namespaceName, namespaceName,
planUpgradeHref, planUpgradeHref,
customerPortalUrl,
}; };
}, },
render(createElement) { render(createElement) {
...@@ -31,6 +32,7 @@ export default (containerId = 'js-billing-plans') => { ...@@ -31,6 +32,7 @@ export default (containerId = 'js-billing-plans') => {
namespaceId: this.namespaceId, namespaceId: this.namespaceId,
namespaceName: this.namespaceName, namespaceName: this.namespaceName,
planUpgradeHref: this.planUpgradeHref, planUpgradeHref: this.planUpgradeHref,
customerPortalUrl: this.customerPortalUrl,
}, },
}); });
}, },
......
...@@ -31,7 +31,8 @@ module BillingPlansHelper ...@@ -31,7 +31,8 @@ module BillingPlansHelper
{ {
namespace_id: group.id, namespace_id: group.id,
namespace_name: group.name, namespace_name: group.name,
plan_upgrade_href: plan_upgrade_url(group, plan) plan_upgrade_href: plan_upgrade_url(group, plan),
customer_portal_url: "#{EE::SUBSCRIPTIONS_URL}/subscriptions"
} }
end end
......
# frozen_string_literal: true # frozen_string_literal: true
module EE module EE
SUBSCRIPTIONS_URL = 'https://customers.gitlab.com'.freeze SUBSCRIPTIONS_URL = ENV.fetch('CUSTOMER_PORTAL_URL', 'https://customers.gitlab.com').freeze
SUBSCRIPTIONS_PLANS_URL = "#{SUBSCRIPTIONS_URL}/plans".freeze SUBSCRIPTIONS_PLANS_URL = "#{SUBSCRIPTIONS_URL}/plans".freeze
SUBSCRIPTIONS_MORE_MINUTES_URL = "#{SUBSCRIPTIONS_URL}/buy_pipeline_minutes".freeze SUBSCRIPTIONS_MORE_MINUTES_URL = "#{SUBSCRIPTIONS_URL}/buy_pipeline_minutes".freeze
CUSTOMER_SUPPORT_URL = 'https://support.gitlab.com'.freeze CUSTOMER_SUPPORT_URL = 'https://support.gitlab.com'.freeze
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
exports[`SubscriptionApp component on creation matches the snapshot 1`] = ` exports[`SubscriptionApp component on creation matches the snapshot 1`] = `
<subscriptiontable-stub <subscriptiontable-stub
customerportalurl="https://customers.gitlab.com/subscriptions"
namespacename="bronze" namespacename="bronze"
planupgradehref="/url" planupgradehref="/url"
/> />
......
...@@ -11,6 +11,7 @@ describe('SubscriptionApp component', () => { ...@@ -11,6 +11,7 @@ describe('SubscriptionApp component', () => {
namespaceId: '42', namespaceId: '42',
namespaceName: 'bronze', namespaceName: 'bronze',
planUpgradeHref: '/url', planUpgradeHref: '/url',
customerPortalUrl: 'https://customers.gitlab.com/subscriptions',
}; };
const factory = (props = appProps) => { const factory = (props = appProps) => {
...@@ -57,6 +58,7 @@ describe('SubscriptionApp component', () => { ...@@ -57,6 +58,7 @@ describe('SubscriptionApp component', () => {
expectComponentWithProps(SubscriptionTable, { expectComponentWithProps(SubscriptionTable, {
namespaceName: appProps.namespaceName, namespaceName: appProps.namespaceName,
planUpgradeHref: appProps.planUpgradeHref, planUpgradeHref: appProps.planUpgradeHref,
customerPortalUrl: appProps.customerPortalUrl,
}); });
}); });
}); });
......
...@@ -8,6 +8,7 @@ import SubscriptionTableRow from 'ee/billings/components/subscription_table_row. ...@@ -8,6 +8,7 @@ import SubscriptionTableRow from 'ee/billings/components/subscription_table_row.
import mockDataSubscription from '../mock_data'; import mockDataSubscription from '../mock_data';
const TEST_NAMESPACE_NAME = 'GitLab.com'; const TEST_NAMESPACE_NAME = 'GitLab.com';
const CUSTOMER_PORTAL_URL = 'https://customers.gitlab.com/subscriptions';
describe('SubscriptionTable component', () => { describe('SubscriptionTable component', () => {
let store; let store;
...@@ -40,6 +41,7 @@ describe('SubscriptionTable component', () => { ...@@ -40,6 +41,7 @@ describe('SubscriptionTable component', () => {
propsData: { propsData: {
namespaceName: TEST_NAMESPACE_NAME, namespaceName: TEST_NAMESPACE_NAME,
planUpgradeHref: '/url/', planUpgradeHref: '/url/',
customerPortalUrl: CUSTOMER_PORTAL_URL,
}, },
}); });
...@@ -100,6 +102,7 @@ describe('SubscriptionTable component', () => { ...@@ -100,6 +102,7 @@ describe('SubscriptionTable component', () => {
factory({ factory({
propsData: { propsData: {
namespaceName: TEST_NAMESPACE_NAME, namespaceName: TEST_NAMESPACE_NAME,
customerPortalUrl: CUSTOMER_PORTAL_URL,
planUpgradeHref, planUpgradeHref,
}, },
}); });
......
...@@ -18,6 +18,8 @@ describe BillingPlansHelper do ...@@ -18,6 +18,8 @@ describe BillingPlansHelper do
end end
describe '#subscription_plan_data_attributes' do describe '#subscription_plan_data_attributes' do
let(:customer_portal_url) { "https://customers.gitlab.com/subscriptions" }
let(:group) { build(:group) } let(:group) { build(:group) }
let(:plan) do let(:plan) do
Hashie::Mash.new(id: 'external-paid-plan-hash-code') Hashie::Mash.new(id: 'external-paid-plan-hash-code')
...@@ -31,7 +33,8 @@ describe BillingPlansHelper do ...@@ -31,7 +33,8 @@ describe BillingPlansHelper do
expect(helper.subscription_plan_data_attributes(group, plan)) expect(helper.subscription_plan_data_attributes(group, plan))
.to eq(namespace_id: group.id, .to eq(namespace_id: group.id,
namespace_name: group.name, namespace_name: group.name,
plan_upgrade_href: upgrade_href) plan_upgrade_href: upgrade_href,
customer_portal_url: customer_portal_url)
end end
end end
...@@ -50,6 +53,7 @@ describe BillingPlansHelper do ...@@ -50,6 +53,7 @@ describe BillingPlansHelper do
expect(helper.subscription_plan_data_attributes(group, plan)) expect(helper.subscription_plan_data_attributes(group, plan))
.to eq(namespace_id: group.id, .to eq(namespace_id: group.id,
namespace_name: group.name, namespace_name: group.name,
customer_portal_url: customer_portal_url,
plan_upgrade_href: nil) plan_upgrade_href: nil)
end end
end end
......
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