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