1
0
Fork 0
mirror of synced 2024-05-17 02:42:53 +12:00
budibase/packages/client/src/stores/features.js
Gerard Burns d9033b2636
Un-revert Skeleton Loader PR (#13180)
* wip

* wip

* wip

* client versions init

* wip

* wip

* wip

* wip

* wip

* linting

* remove log

* comment client version script

* lint

* skeleton loader type fix

* fix types

* lint

* fix types again

* fix manifest not being served locally

* remove preinstalled old client version

* add constant for dev client version

* linting

* Dean PR Feedback

* linting

* pr feedback

* wip

* wip

* clientVersions empty array

* delete from git

* empty array again

* fix tests

* pr feedback

---------

Co-authored-by: Andrew Kingston <andrew@kingston.dev>
2024-03-25 16:39:42 +00:00

43 lines
1 KiB
JavaScript

import { derived } from "svelte/store"
import { appStore } from "./app"
import { authStore } from "./auth"
import { Constants } from "@budibase/frontend-core"
const createFeaturesStore = () => {
return derived([authStore, appStore], ([$authStore, $appStore]) => {
const getUserLicense = () => {
const user = $authStore
if (user) {
return user.license
}
}
const getAppLicenseType = () => {
const appDef = $appStore
if (appDef?.licenseType) {
return appDef.licenseType
}
}
const isFreePlan = () => {
let licenseType = getAppLicenseType()
if (!licenseType) {
const license = getUserLicense()
licenseType = license?.plan?.type
}
if (licenseType) {
return licenseType === Constants.PlanType.FREE
} else {
// safety net - no license means free plan
return true
}
}
return {
logoEnabled: isFreePlan(),
}
})
}
export const featuresStore = createFeaturesStore()