From f7dd6864bcdc3749c34128d8db96157c083dc91e Mon Sep 17 00:00:00 2001 From: Dean Date: Fri, 23 Sep 2022 14:45:44 +0100 Subject: [PATCH 1/2] Fix to ensure licensing flags display correctly --- .../portal/licensing/LicensingOverlays.svelte | 27 +++++++------------ .../builder/src/stores/portal/licensing.js | 2 +- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/packages/builder/src/components/portal/licensing/LicensingOverlays.svelte b/packages/builder/src/components/portal/licensing/LicensingOverlays.svelte index bcafd92a85..7c5c254069 100644 --- a/packages/builder/src/components/portal/licensing/LicensingOverlays.svelte +++ b/packages/builder/src/components/portal/licensing/LicensingOverlays.svelte @@ -8,7 +8,6 @@ import { ExpiringKeys } from "./constants" import { getBanners } from "./licensingBanners" import { banner } from "@budibase/bbui" - import { FEATURE_FLAGS, isEnabled } from "../../../helpers/featureFlags" const oneDayInSeconds = 86400 @@ -18,8 +17,8 @@ let paymentFailedModal let accountDowngradeModal let userLoaded = false - let loaded = false let licensingLoaded = false + let domLoaded = false let currentModalCfg = null const processModals = () => { @@ -82,12 +81,17 @@ } } + $: if (!userLoaded && $auth.user) { + userLoaded = true + } + $: if ( userLoaded && - licensingLoaded && - loaded && - isEnabled(FEATURE_FLAGS.LICENSING) + $licensing.usageMetrics && + domLoaded && + !licensingLoaded ) { + licensingLoaded = true queuedModals = processModals() queuedBanners = getBanners() showNextModal() @@ -95,18 +99,7 @@ } onMount(async () => { - auth.subscribe(state => { - if (state.user && !userLoaded) { - userLoaded = true - } - }) - - licensing.subscribe(state => { - if (state.usageMetrics && !licensingLoaded) { - licensingLoaded = true - } - }) - loaded = true + domLoaded = true }) diff --git a/packages/builder/src/stores/portal/licensing.js b/packages/builder/src/stores/portal/licensing.js index 680ae8a38c..9bf71a4d4e 100644 --- a/packages/builder/src/stores/portal/licensing.js +++ b/packages/builder/src/stores/portal/licensing.js @@ -17,7 +17,7 @@ export const createLicensingStore = () => { // the currently used quotas from the db quotaUsage: undefined, // derived quota metrics for percentages used - usageMetrics: {}, + usageMetrics: undefined, // quota reset quotaResetDaysRemaining: undefined, quotaResetDate: undefined, From ce683e3df1054cf6eee46137528d8db60418a4c7 Mon Sep 17 00:00:00 2001 From: Dean Date: Fri, 23 Sep 2022 19:29:56 +0100 Subject: [PATCH 2/2] Fix for create app buttons when usage is not being tracked --- packages/builder/src/pages/builder/portal/apps/create.svelte | 4 ++-- packages/builder/src/pages/builder/portal/apps/index.svelte | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/builder/src/pages/builder/portal/apps/create.svelte b/packages/builder/src/pages/builder/portal/apps/create.svelte index 2dda17875b..00b446b02a 100644 --- a/packages/builder/src/pages/builder/portal/apps/create.svelte +++ b/packages/builder/src/pages/builder/portal/apps/create.svelte @@ -45,7 +45,7 @@ }) const initiateAppCreation = () => { - if ($licensing.usageMetrics.apps >= 100) { + if ($licensing?.usageMetrics?.apps >= 100) { appLimitModal.show() } else { template = null @@ -60,7 +60,7 @@ } const initiateAppImport = () => { - if ($licensing.usageMetrics.apps >= 100) { + if ($licensing?.usageMetrics?.apps >= 100) { appLimitModal.show() } else { template = { fromFile: true } diff --git a/packages/builder/src/pages/builder/portal/apps/index.svelte b/packages/builder/src/pages/builder/portal/apps/index.svelte index e4cacada81..99721e980d 100644 --- a/packages/builder/src/pages/builder/portal/apps/index.svelte +++ b/packages/builder/src/pages/builder/portal/apps/index.svelte @@ -127,7 +127,7 @@ } const initiateAppCreation = async () => { - if ($licensing.usageMetrics.apps >= 100) { + if ($licensing?.usageMetrics?.apps >= 100) { appLimitModal.show() } else if ($apps?.length) { $goto("/builder/portal/apps/create")