Help popout email support license validation check (#13133)

* Added helper function to check user plan type.

* Updated help menu email support license check.

* Removed stray output check

* Updated function name as per feedback.

* Reworked code to use the licensing store over the auth store.

* Removed unnecessary variable declaration and return instead.

* Updated function name to maintain consistency.
This commit is contained in:
Conor Webb 2024-02-26 11:45:47 +00:00 committed by GitHub
parent c1f4cb685c
commit af7b6a46a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 7 deletions

View File

@ -1,11 +1,11 @@
<script> <script>
import FontAwesomeIcon from "./FontAwesomeIcon.svelte" import FontAwesomeIcon from "./FontAwesomeIcon.svelte"
import { Popover, Heading, Body } from "@budibase/bbui" import { Popover, Heading, Body } from "@budibase/bbui"
import { licensing } from "stores/portal"
import { isEnabled, TENANT_FEATURE_FLAGS } from "helpers/featureFlags" import { isEnabled, TENANT_FEATURE_FLAGS } from "helpers/featureFlags"
import { licensing } from "stores/portal"
import { isPremiumOrAbove } from "helpers/planTitle"
$: isBusinessAndAbove = $: premiumOrAboveLicense = isPremiumOrAbove($licensing?.license.plan.type)
$licensing.isBusinessPlan || $licensing.isEnterprisePlan
let show let show
let hide let hide
@ -56,22 +56,25 @@
<div class="divider" /> <div class="divider" />
{#if isEnabled(TENANT_FEATURE_FLAGS.LICENSING)} {#if isEnabled(TENANT_FEATURE_FLAGS.LICENSING)}
<a <a
href={isBusinessAndAbove href={premiumOrAboveLicense
? "mailto:support@budibase.com" ? "mailto:support@budibase.com"
: "/builder/portal/account/usage"} : "/builder/portal/account/usage"}
> >
<div class="premiumLinkContent" class:disabled={!isBusinessAndAbove}> <div
class="premiumLinkContent"
class:disabled={!premiumOrAboveLicense}
>
<div class="icon"> <div class="icon">
<FontAwesomeIcon name="fa-solid fa-envelope" /> <FontAwesomeIcon name="fa-solid fa-envelope" />
</div> </div>
<Body size="S">Email support</Body> <Body size="S">Email support</Body>
</div> </div>
{#if !isBusinessAndAbove} {#if !premiumOrAboveLicense}
<div class="premiumBadge"> <div class="premiumBadge">
<div class="icon"> <div class="icon">
<FontAwesomeIcon name="fa-solid fa-lock" /> <FontAwesomeIcon name="fa-solid fa-lock" />
</div> </div>
<Body size="XS">Business</Body> <Body size="XS">Premium</Body>
</div> </div>
{/if} {/if}
</a> </a>

View File

@ -25,3 +25,7 @@ export function getFormattedPlanName(userPlanType) {
} }
return `${planName} Plan` return `${planName} Plan`
} }
export function isPremiumOrAbove(userPlanType) {
return ![PlanType.PRO, PlanType.TEAM, PlanType.FREE].includes(userPlanType)
}