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:
parent
7241a8ae34
commit
fa36701f0f
|
@ -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}
|
||||||
|
|
|
@ -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`
|
||||||
|
}
|
|
@ -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}
|
||||||
|
|
|
@ -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,
|
||||||
|
|
Loading…
Reference in New Issue