diff --git a/packages/builder/src/components/portal/overview/automation/HistoryTab.svelte b/packages/builder/src/components/portal/overview/automation/HistoryTab.svelte index 165949b7b0..bd32e423c9 100644 --- a/packages/builder/src/components/portal/overview/automation/HistoryTab.svelte +++ b/packages/builder/src/components/portal/overview/automation/HistoryTab.svelte @@ -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} /> - {#if isEnabled(TENANT_FEATURE_FLAGS.LICENSING) && licensePlan?.type === "free"} + {#if (licensePlan?.type !== Constants.PlanType.ENTERPRISE && $auth.user.accountPortalAccess) || !$admin.cloud}
-
Store up to 30 days of automations
-
diff --git a/packages/builder/src/constants/index.js b/packages/builder/src/constants/index.js index 49054ae247..151a0cdf8d 100644 --- a/packages/builder/src/constants/index.js +++ b/packages/builder/src/constants/index.js @@ -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", diff --git a/packages/builder/src/pages/builder/portal/settings/usage.svelte b/packages/builder/src/pages/builder/portal/settings/usage.svelte index 75ceccc0a3..7609a4742e 100644 --- a/packages/builder/src/pages/builder/portal/settings/usage.svelte +++ b/packages/builder/src/pages/builder/portal/settings/usage.svelte @@ -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 } diff --git a/packages/client/src/licensing/constants.js b/packages/client/src/licensing/constants.js deleted file mode 100644 index 57454bc37a..0000000000 --- a/packages/client/src/licensing/constants.js +++ /dev/null @@ -1,7 +0,0 @@ -export const PlanType = { - FREE: "free", - PRO: "pro", - TEAM: "team", - BUSINESS: "business", - ENTERPRISE: "enterprise", -} diff --git a/packages/client/src/licensing/utils.js b/packages/client/src/licensing/utils.js index efe1839ecb..effed6867f 100644 --- a/packages/client/src/licensing/utils.js +++ b/packages/client/src/licensing/utils.js @@ -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 diff --git a/packages/frontend-core/src/constants.js b/packages/frontend-core/src/constants.js index 633534dddb..af350ff333 100644 --- a/packages/frontend-core/src/constants.js +++ b/packages/frontend-core/src/constants.js @@ -98,6 +98,7 @@ export const BuilderRoleDescriptions = [ export const PlanType = { FREE: "free", TEAM: "team", + PRO: "pro", BUSINESS: "business", ENTERPRISE: "enterprise", }