1
0
Fork 0
mirror of synced 2024-07-06 15:00:49 +12:00

Added function to get correct plan display name (#12810)

* Changed minPlan BUSINESS to PREMIUM_PLUS

* Added new helper to display the correct string plan

* Changed ManageAccessModal to use the new helper

* Refactored to use plan title helper, removed title function

* Removed capitalised function from svelte template

* Fixed linting issues

* Ran yarn lint. Fixed linting issues.
This commit is contained in:
Conor Webb 2024-01-22 10:54:47 +00:00 committed by GitHub
parent 7241a8ae34
commit fa36701f0f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 18 additions and 21 deletions

View file

@ -13,6 +13,7 @@
Icon,
} from "@budibase/bbui"
import { capitalise } from "helpers"
import { getFormattedPlanName } from "helpers/planTitle"
import { get } from "svelte/store"
export let resourceId
@ -99,7 +100,9 @@
{#if requiresPlanToModify}
<span class="lock-tag">
<Tags>
<Tag icon="LockClosed">{capitalise(requiresPlanToModify)}</Tag>
<Tag icon="LockClosed"
>{getFormattedPlanName(requiresPlanToModify)}</Tag
>
</Tags>
</span>
{/if}

View file

@ -0,0 +1,11 @@
import { PlanType } from "@budibase/types"
export function getFormattedPlanName(userPlanType) {
let planName = "Free"
if (userPlanType === PlanType.PREMIUM_PLUS) {
planName = "Premium"
} else if (userPlanType === PlanType.ENTERPRISE_BASIC) {
planName = "Enterprise"
}
return `${planName} Plan`
}

View file

@ -15,7 +15,7 @@
import { DashCard, Usage } from "components/usage"
import { PlanModel } from "constants"
import { sdk } from "@budibase/shared-core"
import { PlanType } from "@budibase/types"
import { getFormattedPlanName } from "helpers/planTitle"
let staticUsage = []
let monthlyUsage = []
@ -100,23 +100,6 @@
cancelAt = license?.billing?.subscription?.cancelAt
}
const capitalise = string => {
if (string) {
return string.charAt(0).toUpperCase() + string.slice(1)
}
}
const planTitle = () => {
const planType = license?.plan.type
let planName = license?.plan.type
if (planType === PlanType.PREMIUM_PLUS) {
planName = "Premium"
} else if (planType === PlanType.ENTERPRISE_BASIC) {
planName = "Enterprise"
}
return `${capitalise(planName)} Plan`
}
const getDaysRemaining = timestamp => {
if (!timestamp) {
return
@ -227,7 +210,7 @@
<DashCard
description="YOUR CURRENT PLAN"
title={planTitle()}
title={getFormattedPlanName(license?.plan.type)}
{primaryActionText}
primaryAction={showButton ? goToAccountPortal : undefined}
{textRows}

View file

@ -61,7 +61,7 @@ export async function getInheritablePermissions(
export async function allowsExplicitPermissions(resourceId: string) {
if (isViewID(resourceId)) {
const allowed = await features.isViewPermissionEnabled()
const minPlan = !allowed ? PlanType.BUSINESS : undefined
const minPlan = !allowed ? PlanType.PREMIUM_PLUS : undefined
return {
allowed,