Centralised licensing types to frontend-core contants. Some minor refactoring
This commit is contained in:
parent
21c330f4fb
commit
67437c3db1
|
@ -7,8 +7,8 @@
|
|||
import { createPaginationStore } from "helpers/pagination"
|
||||
import { onMount } from "svelte"
|
||||
import dayjs from "dayjs"
|
||||
import { auth, admin } from "stores/portal"
|
||||
import { TENANT_FEATURE_FLAGS, isEnabled } from "helpers/featureFlags"
|
||||
import { auth, licensing, admin } from "stores/portal"
|
||||
import { Constants } from "@budibase/frontend-core"
|
||||
|
||||
const ERROR = "error",
|
||||
SUCCESS = "success",
|
||||
|
@ -16,7 +16,6 @@
|
|||
export let app
|
||||
|
||||
$: licensePlan = $auth.user?.license?.plan
|
||||
$: upgradeUrl = `${$admin.accountPortalUrl}/portal/upgrade`
|
||||
|
||||
let pageInfo = createPaginationStore()
|
||||
let runHistory = null
|
||||
|
@ -31,6 +30,8 @@
|
|||
$: fetchLogs(automationId, status, page, timeRange)
|
||||
|
||||
const timeOptions = [
|
||||
{ value: "90-d", label: "Past 90 days" },
|
||||
{ value: "30-d", label: "Past 30 days" },
|
||||
{ value: "1-w", label: "Past week" },
|
||||
{ value: "1-d", label: "Past day" },
|
||||
{ value: "1-h", label: "Past 1 hour" },
|
||||
|
@ -141,11 +142,12 @@
|
|||
bind:value={timeRange}
|
||||
options={timeOptions}
|
||||
isOptionEnabled={x => {
|
||||
if (
|
||||
isEnabled(TENANT_FEATURE_FLAGS.LICENSING) &&
|
||||
licensePlan?.type === "free"
|
||||
) {
|
||||
return "1-w" !== x.value
|
||||
if (licensePlan?.type === Constants.PlanType.FREE) {
|
||||
return ["1-w", "30-d", "90-d"].indexOf(x.value) < 0
|
||||
} else if (licensePlan?.type === Constants.PlanType.TEAM) {
|
||||
return ["90-d"].indexOf(x.value) < 0
|
||||
} else if (licensePlan?.type === Constants.PlanType.PRO) {
|
||||
return ["30-d", "90-d"].indexOf(x.value) < 0
|
||||
}
|
||||
return true
|
||||
}}
|
||||
|
@ -159,14 +161,10 @@
|
|||
options={statusOptions}
|
||||
/>
|
||||
</div>
|
||||
{#if isEnabled(TENANT_FEATURE_FLAGS.LICENSING) && licensePlan?.type === "free"}
|
||||
{#if (licensePlan?.type !== Constants.PlanType.ENTERPRISE && $auth.user.accountPortalAccess) || !$admin.cloud}
|
||||
<div class="pro-upgrade">
|
||||
<div class="pro-copy">Store up to 30 days of automations</div>
|
||||
<Button
|
||||
primary
|
||||
newStyles
|
||||
on:click={window.open(upgradeUrl, "_blank")}
|
||||
>
|
||||
<div class="pro-copy">Expand your automation log history</div>
|
||||
<Button primary newStyles on:click={$licensing.goToUpgradePage()}>
|
||||
Upgrade
|
||||
</Button>
|
||||
</div>
|
||||
|
|
|
@ -58,13 +58,6 @@ export const DefaultAppTheme = {
|
|||
navTextColor: "var(--spectrum-global-color-gray-800)",
|
||||
}
|
||||
|
||||
export const PlanType = {
|
||||
FREE: "free",
|
||||
PRO: "pro",
|
||||
BUSINESS: "business",
|
||||
ENTERPRISE: "enterprise",
|
||||
}
|
||||
|
||||
export const PluginSource = {
|
||||
URL: "URL",
|
||||
NPM: "NPM",
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
} from "@budibase/bbui"
|
||||
import { onMount } from "svelte"
|
||||
import { admin, auth, licensing } from "../../../../stores/portal"
|
||||
import { PlanType } from "../../../../constants"
|
||||
import { Constants } from "@budibase/frontend-core"
|
||||
import { DashCard, Usage } from "../../../../components/usage"
|
||||
|
||||
let staticUsage = []
|
||||
|
@ -125,7 +125,7 @@
|
|||
}
|
||||
|
||||
const goToAccountPortal = () => {
|
||||
if (license?.plan.type === PlanType.FREE) {
|
||||
if (license?.plan.type === Constants.PlanType.FREE) {
|
||||
window.location.href = upgradeUrl
|
||||
} else {
|
||||
window.location.href = manageUrl
|
||||
|
@ -133,7 +133,7 @@
|
|||
}
|
||||
|
||||
const setPrimaryActionText = () => {
|
||||
if (license?.plan.type === PlanType.FREE) {
|
||||
if (license?.plan.type === Constants.PlanType.FREE) {
|
||||
primaryActionText = "Upgrade"
|
||||
return
|
||||
}
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
export const PlanType = {
|
||||
FREE: "free",
|
||||
PRO: "pro",
|
||||
TEAM: "team",
|
||||
BUSINESS: "business",
|
||||
ENTERPRISE: "enterprise",
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
import { authStore } from "../stores/auth.js"
|
||||
import { get } from "svelte/store"
|
||||
import { PlanType } from "./constants"
|
||||
import { Constants } from "@budibase/frontend-core"
|
||||
|
||||
const getLicense = () => {
|
||||
const user = get(authStore)
|
||||
|
@ -12,7 +12,7 @@ const getLicense = () => {
|
|||
export const isFreePlan = () => {
|
||||
const license = getLicense()
|
||||
if (license) {
|
||||
return license.plan.type === PlanType.FREE
|
||||
return license.plan.type === Constants.PlanType.FREE
|
||||
} else {
|
||||
// safety net - no license means free plan
|
||||
return true
|
||||
|
|
|
@ -98,6 +98,7 @@ export const BuilderRoleDescriptions = [
|
|||
export const PlanType = {
|
||||
FREE: "free",
|
||||
TEAM: "team",
|
||||
PRO: "pro",
|
||||
BUSINESS: "business",
|
||||
ENTERPRISE: "enterprise",
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue