1
0
Fork 0
mirror of synced 2024-06-28 02:50:50 +12:00

Merge pull request #7945 from Budibase/fix/licensing-overlay-flags

Fix to ensure licensing flags display correctly
This commit is contained in:
Rory Powell 2022-09-24 14:06:25 +01:00 committed by GitHub
commit 2e5c670f75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 21 deletions

View file

@ -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
})
</script>

View file

@ -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 }

View file

@ -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")

View file

@ -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,