Merge pull request #10922 from Budibase/fix/budi-7069
Fix public apps still displaying free footer when licensed
This commit is contained in:
commit
85afe3f1cb
|
@ -1,18 +1,30 @@
|
||||||
import { authStore } from "../stores/auth.js"
|
import { authStore } from "../stores/auth.js"
|
||||||
|
import { appStore } from "../stores/app.js"
|
||||||
import { get } from "svelte/store"
|
import { get } from "svelte/store"
|
||||||
import { Constants } from "@budibase/frontend-core"
|
import { Constants } from "@budibase/frontend-core"
|
||||||
|
|
||||||
const getLicense = () => {
|
const getUserLicense = () => {
|
||||||
const user = get(authStore)
|
const user = get(authStore)
|
||||||
if (user) {
|
if (user) {
|
||||||
return user.license
|
return user.license
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getAppLicenseType = () => {
|
||||||
|
const appDef = get(appStore)
|
||||||
|
if (appDef?.licenseType) {
|
||||||
|
return appDef.licenseType
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const isFreePlan = () => {
|
export const isFreePlan = () => {
|
||||||
const license = getLicense()
|
let licenseType = getAppLicenseType()
|
||||||
if (license) {
|
if (!licenseType) {
|
||||||
return license.plan.type === Constants.PlanType.FREE
|
const license = getUserLicense()
|
||||||
|
licenseType = license?.plan?.type
|
||||||
|
}
|
||||||
|
if (licenseType) {
|
||||||
|
return licenseType === Constants.PlanType.FREE
|
||||||
} else {
|
} else {
|
||||||
// safety net - no license means free plan
|
// safety net - no license means free plan
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -1,53 +1,54 @@
|
||||||
import env from "../../environment"
|
import env from "../../environment"
|
||||||
import {
|
import {
|
||||||
|
createAllSearchIndex,
|
||||||
createLinkView,
|
createLinkView,
|
||||||
createRoutingView,
|
createRoutingView,
|
||||||
createAllSearchIndex,
|
|
||||||
} from "../../db/views/staticViews"
|
} from "../../db/views/staticViews"
|
||||||
import { createApp, deleteApp } from "../../utilities/fileSystem"
|
|
||||||
import {
|
import {
|
||||||
|
backupClientLibrary,
|
||||||
|
createApp,
|
||||||
|
deleteApp,
|
||||||
|
revertClientLibrary,
|
||||||
|
updateClientLibrary,
|
||||||
|
} from "../../utilities/fileSystem"
|
||||||
|
import {
|
||||||
|
AppStatus,
|
||||||
|
DocumentType,
|
||||||
generateAppID,
|
generateAppID,
|
||||||
|
generateDevAppID,
|
||||||
getLayoutParams,
|
getLayoutParams,
|
||||||
getScreenParams,
|
getScreenParams,
|
||||||
generateDevAppID,
|
|
||||||
DocumentType,
|
|
||||||
AppStatus,
|
|
||||||
} from "../../db/utils"
|
} from "../../db/utils"
|
||||||
import {
|
import {
|
||||||
db as dbCore,
|
|
||||||
roles,
|
|
||||||
cache,
|
cache,
|
||||||
tenancy,
|
|
||||||
context,
|
context,
|
||||||
|
db as dbCore,
|
||||||
|
env as envCore,
|
||||||
|
ErrorCode,
|
||||||
events,
|
events,
|
||||||
migrations,
|
migrations,
|
||||||
objectStore,
|
objectStore,
|
||||||
ErrorCode,
|
roles,
|
||||||
env as envCore,
|
tenancy,
|
||||||
} from "@budibase/backend-core"
|
} from "@budibase/backend-core"
|
||||||
import { USERS_TABLE_SCHEMA } from "../../constants"
|
import { USERS_TABLE_SCHEMA } from "../../constants"
|
||||||
import {
|
import {
|
||||||
DEFAULT_BB_DATASOURCE_ID,
|
|
||||||
buildDefaultDocs,
|
buildDefaultDocs,
|
||||||
|
DEFAULT_BB_DATASOURCE_ID,
|
||||||
} from "../../db/defaultData/datasource_bb_default"
|
} from "../../db/defaultData/datasource_bb_default"
|
||||||
import { removeAppFromUserRoles } from "../../utilities/workerRequests"
|
import { removeAppFromUserRoles } from "../../utilities/workerRequests"
|
||||||
import { stringToReadStream, isQsTrue } from "../../utilities"
|
import { stringToReadStream } from "../../utilities"
|
||||||
import { getLocksById, doesUserHaveLock } from "../../utilities/redis"
|
import { doesUserHaveLock, getLocksById } from "../../utilities/redis"
|
||||||
import {
|
|
||||||
updateClientLibrary,
|
|
||||||
backupClientLibrary,
|
|
||||||
revertClientLibrary,
|
|
||||||
} from "../../utilities/fileSystem"
|
|
||||||
import { cleanupAutomations } from "../../automations/utils"
|
import { cleanupAutomations } from "../../automations/utils"
|
||||||
import { checkAppMetadata } from "../../automations/logging"
|
import { checkAppMetadata } from "../../automations/logging"
|
||||||
import { getUniqueRows } from "../../utilities/usageQuota/rows"
|
import { getUniqueRows } from "../../utilities/usageQuota/rows"
|
||||||
import { quotas, groups } from "@budibase/pro"
|
import { groups, licensing, quotas } from "@budibase/pro"
|
||||||
import {
|
import {
|
||||||
App,
|
App,
|
||||||
Layout,
|
Layout,
|
||||||
Screen,
|
|
||||||
MigrationType,
|
MigrationType,
|
||||||
Database,
|
PlanType,
|
||||||
|
Screen,
|
||||||
UserCtx,
|
UserCtx,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { BASE_LAYOUT_PROP_IDS } from "../../constants/layouts"
|
import { BASE_LAYOUT_PROP_IDS } from "../../constants/layouts"
|
||||||
|
@ -207,6 +208,7 @@ export async function fetchAppPackage(ctx: UserCtx) {
|
||||||
let application = await db.get(DocumentType.APP_METADATA)
|
let application = await db.get(DocumentType.APP_METADATA)
|
||||||
const layouts = await getLayouts()
|
const layouts = await getLayouts()
|
||||||
let screens = await getScreens()
|
let screens = await getScreens()
|
||||||
|
const license = await licensing.getLicense()
|
||||||
|
|
||||||
// Enrich plugin URLs
|
// Enrich plugin URLs
|
||||||
application.usedPlugins = objectStore.enrichPluginURLs(
|
application.usedPlugins = objectStore.enrichPluginURLs(
|
||||||
|
@ -227,6 +229,7 @@ export async function fetchAppPackage(ctx: UserCtx) {
|
||||||
|
|
||||||
ctx.body = {
|
ctx.body = {
|
||||||
application: { ...application, upgradableVersion: envCore.VERSION },
|
application: { ...application, upgradableVersion: envCore.VERSION },
|
||||||
|
licenseType: license?.plan.type || PlanType.FREE,
|
||||||
screens,
|
screens,
|
||||||
layouts,
|
layouts,
|
||||||
clientLibPath,
|
clientLibPath,
|
||||||
|
|
Loading…
Reference in New Issue