Feature flag upgrade page

This commit is contained in:
Rory Powell 2022-04-20 09:46:20 +01:00
parent 03c3ebbbbf
commit 46965bbb44
3 changed files with 29 additions and 5 deletions

View File

@ -0,0 +1,14 @@
import { auth } from "../stores/portal"
import { get } from "svelte/store"
export const FEATURE_FLAGS = {
LICENSING: "LICENSING",
}
export const isEnabled = featureFlag => {
const user = get(auth).user
if (user?.featureFlags?.includes(featureFlag)) {
return true
}
return false
}

View File

@ -20,6 +20,7 @@
import ChangePasswordModal from "components/settings/ChangePasswordModal.svelte" import ChangePasswordModal from "components/settings/ChangePasswordModal.svelte"
import UpdateAPIKeyModal from "components/settings/UpdateAPIKeyModal.svelte" import UpdateAPIKeyModal from "components/settings/UpdateAPIKeyModal.svelte"
import Logo from "assets/bb-emblem.svg" import Logo from "assets/bb-emblem.svg"
import { isEnabled, FEATURE_FLAGS } from "../../../helpers/featureFlags"
let loaded = false let loaded = false
let userInfoModal let userInfoModal
@ -54,15 +55,18 @@
if (!$adminStore.cloud) { if (!$adminStore.cloud) {
menu = menu.concat([ menu = menu.concat([
{ {
title: "Updates", title: "Update",
href: "/builder/portal/settings/update", href: "/builder/portal/settings/update",
}, },
{
title: "Upgrade",
href: "/builder/portal/settings/upgrade",
},
]) ])
} }
if (isEnabled(FEATURE_FLAGS.LICENSING)) {
menu = menu.concat({
title: "Upgrade",
href: "/builder/portal/settings/upgrade",
})
}
} else { } else {
menu = menu.concat([ menu = menu.concat([
{ {

View File

@ -15,6 +15,7 @@ const { encrypt } = require("@budibase/backend-core/encryption")
const { newid } = require("@budibase/backend-core/utils") const { newid } = require("@budibase/backend-core/utils")
const { getUser } = require("../../utilities") const { getUser } = require("../../utilities")
const { Cookies } = require("@budibase/backend-core/constants") const { Cookies } = require("@budibase/backend-core/constants")
const { featureFlags } = require("@budibase/backend-core")
function newApiKey() { function newApiKey() {
return encrypt(`${getTenantId()}${SEPARATOR}${newid()}`) return encrypt(`${getTenantId()}${SEPARATOR}${newid()}`)
@ -104,6 +105,11 @@ exports.getSelf = async ctx => {
// get the main body of the user // get the main body of the user
ctx.body = await getUser(userId) ctx.body = await getUser(userId)
// add the feature flags for this tenant
const tenantId = getTenantId()
ctx.body.featureFlags = featureFlags.getTenantFeatureFlags(tenantId)
addSessionAttributesToUser(ctx) addSessionAttributesToUser(ctx)
} }