Skip to content

Beautiful Open-Source Form Builder

Hide self-hosted plan from hosted upgrade modal

Julien Nahumf537a604c970
diff --git a/client/components/pages/pricing/SubscriptionModal.vue b/client/components/pages/pricing/SubscriptionModal.vue
index e787ecd4c..2e33e5006 100644
--- a/client/components/pages/pricing/SubscriptionModal.vue
+++ b/client/components/pages/pricing/SubscriptionModal.vue
@@ -351,16 +351,19 @@ const isOpen = computed({
set: (value) => emit('close', value)
})
+const isSelfHosted = computed(() => useFeatureFlag('self_hosted'))
+const cloudPaidPlans = ['pro', 'business', 'enterprise']
+const selfHostedPaidPlans = ['self_hosted']
+const paidPlans = computed(() => isSelfHosted.value ? selfHostedPaidPlans : cloudPaidPlans)
+
const normalizedPlan = computed(() => {
if (isSelfHosted.value) return 'self_hosted'
if (!props.plan || props.plan === 'default') return 'pro'
- return props.plan
+ return cloudPaidPlans.includes(props.plan) ? props.plan : 'pro'
})
const showRequirementHints = computed(() => props.show_requirement_hints)
-const isSelfHosted = computed(() => useFeatureFlag('self_hosted'))
-const paidPlans = ['pro', 'business', 'enterprise', 'self_hosted']
const currentPlan = ref(normalizedPlan.value)
const isYearly = ref(props.yearly)
const loading = ref(false)
@@ -373,9 +376,9 @@ const isSubscribed = computed(() => userIsSubscribed.value)
const selectedPlanName = computed(() => getTierDisplayName(currentPlan.value))
-const requiredPlanKey = computed(() => paidPlans.find((plan) => plan === normalizedPlan.value) || 'pro')
+const requiredPlanKey = computed(() => paidPlans.value.find((plan) => plan === normalizedPlan.value) || paidPlans.value[0])
const planOptions = computed(() => {
- return paidPlans.map((planKey) => {
+ return paidPlans.value.map((planKey) => {
const details = PLAN_DETAILS[planKey]
const isRequired = planKey === requiredPlanKey.value
const meetsRequirement = tierMeetsRequirement(planKey, requiredPlanKey.value)
@@ -409,11 +412,8 @@ const planOptions = computed(() => {
})
const visiblePlanOptions = computed(() => {
- if (isSelfHosted.value) {
- return [...planOptions.value].filter((option) => option.key === 'self_hosted')
- }
return [...planOptions.value].sort((left, right) => {
- return paidPlans.indexOf(left.key) - paidPlans.indexOf(right.key)
+ return paidPlans.value.indexOf(left.key) - paidPlans.value.indexOf(right.key)
})
})
diff --git a/client/test/nuxt/subscription-modal-self-hosted.spec.ts b/client/test/nuxt/subscription-modal-self-hosted.spec.ts
index 1a6144375..c6a7ddd81 100644
--- a/client/test/nuxt/subscription-modal-self-hosted.spec.ts
+++ b/client/test/nuxt/subscription-modal-self-hosted.spec.ts
@@ -7,6 +7,7 @@ const mocks = vi.hoisted(() => ({
routerPush: vi.fn(),
alertError: vi.fn(),
stripeCheckout: vi.fn(),
+ isSelfHosted: true,
}))
vi.mock('#imports', async () => {
@@ -15,7 +16,7 @@ vi.mock('#imports', async () => {
return {
ref: vue.ref,
watch: vue.watch,
- useFeatureFlag: (key: string) => key === 'self_hosted',
+ useFeatureFlag: (key: string) => key === 'self_hosted' && mocks.isSelfHosted,
useRouter: () => ({ push: mocks.routerPush }),
useIsAuthenticated: () => ({ isAuthenticated: vue.ref(true) }),
useAuth: () => ({
@@ -78,7 +79,7 @@ vi.mock('~/composables/useBillingUpsell.js', async () => {
})
vi.mock('~/composables/useFeatureFlag.js', () => ({
- useFeatureFlag: (key: string) => key === 'self_hosted',
+ useFeatureFlag: (key: string) => key === 'self_hosted' && mocks.isSelfHosted,
}))
vi.mock('~/composables/useStripeCheckout.js', async () => {
@@ -99,10 +100,11 @@ describe('SubscriptionModal self-hosted checkout', () => {
let openMock: ReturnType<typeof vi.fn>
let originalOpen: typeof window.open
- const mountModal = () => mount(SubscriptionModal, {
+ const mountModal = (props = {}) => mount(SubscriptionModal, {
props: {
modelValue: true,
plan: 'self_hosted',
+ ...props,
},
global: {
stubs: {
@@ -141,6 +143,7 @@ describe('SubscriptionModal self-hosted checkout', () => {
mocks.routerPush.mockReset()
mocks.alertError.mockReset()
mocks.stripeCheckout.mockReset()
+ mocks.isSelfHosted = true
openMock = vi.fn()
originalOpen = window.open
window.open = openMock
@@ -186,4 +189,14 @@ describe('SubscriptionModal self-hosted checkout', () => {
expect(openMock).toHaveBeenCalledWith('https://checkout.stripe.test/session', '_blank')
})
+
+ it('does not render the self-hosted license plan on hosted upgrade modals', () => {
+ mocks.isSelfHosted = false
+
+ const wrapper = mountModal({ plan: 'pro' })
+
+ expect(wrapper.findAll('article')).toHaveLength(3)
+ expect(wrapper.text()).not.toContain('Self Hosted')
+ expect(wrapper.text()).not.toContain('Purchase license')
+ })
})