1
0
Fork 0
mirror of synced 2024-10-05 12:34:50 +13: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, Icon,
} from "@budibase/bbui" } from "@budibase/bbui"
import { capitalise } from "helpers" import { capitalise } from "helpers"
import { getFormattedPlanName } from "helpers/planTitle"
import { get } from "svelte/store" import { get } from "svelte/store"
export let resourceId export let resourceId
@ -99,7 +100,9 @@
{#if requiresPlanToModify} {#if requiresPlanToModify}
<span class="lock-tag"> <span class="lock-tag">
<Tags> <Tags>
<Tag icon="LockClosed">{capitalise(requiresPlanToModify)}</Tag> <Tag icon="LockClosed"
>{getFormattedPlanName(requiresPlanToModify)}</Tag
>
</Tags> </Tags>
</span> </span>
{/if} {/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 { DashCard, Usage } from "components/usage"
import { PlanModel } from "constants" import { PlanModel } from "constants"
import { sdk } from "@budibase/shared-core" import { sdk } from "@budibase/shared-core"
import { PlanType } from "@budibase/types" import { getFormattedPlanName } from "helpers/planTitle"
let staticUsage = [] let staticUsage = []
let monthlyUsage = [] let monthlyUsage = []
@ -100,23 +100,6 @@
cancelAt = license?.billing?.subscription?.cancelAt 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 => { const getDaysRemaining = timestamp => {
if (!timestamp) { if (!timestamp) {
return return
@ -227,7 +210,7 @@
<DashCard <DashCard
description="YOUR CURRENT PLAN" description="YOUR CURRENT PLAN"
title={planTitle()} title={getFormattedPlanName(license?.plan.type)}
{primaryActionText} {primaryActionText}
primaryAction={showButton ? goToAccountPortal : undefined} primaryAction={showButton ? goToAccountPortal : undefined}
{textRows} {textRows}

View file

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