From 66e593a6b310f57e88157ce3200c844e35bae9ce Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Thu, 12 Aug 2021 11:51:08 +0100 Subject: [PATCH] Add self-hosting upgrade button to builder pane --- .../components/upgrade/UpgradeModal.svelte | 23 +++++++++++++++++++ .../builder/app/[application]/_layout.svelte | 7 ++++-- packages/builder/src/stores/portal/admin.js | 14 ++++++----- .../src/api/controllers/system/flags.js | 1 + packages/worker/src/environment.js | 1 + 5 files changed, 38 insertions(+), 8 deletions(-) create mode 100644 packages/builder/src/components/upgrade/UpgradeModal.svelte diff --git a/packages/builder/src/components/upgrade/UpgradeModal.svelte b/packages/builder/src/components/upgrade/UpgradeModal.svelte new file mode 100644 index 0000000000..d87d361d59 --- /dev/null +++ b/packages/builder/src/components/upgrade/UpgradeModal.svelte @@ -0,0 +1,23 @@ + + +
+ +
+ + + Upgrade to Budibase self-hosting for free, and get SSO, unlimited apps, + and more - and it only takes 10 minutes! + + diff --git a/packages/builder/src/pages/builder/app/[application]/_layout.svelte b/packages/builder/src/pages/builder/app/[application]/_layout.svelte index 7b0d09844f..a7626370e0 100644 --- a/packages/builder/src/pages/builder/app/[application]/_layout.svelte +++ b/packages/builder/src/pages/builder/app/[application]/_layout.svelte @@ -7,14 +7,14 @@ import VersionModal from "components/deploy/VersionModal.svelte" import NPSFeedbackForm from "components/feedback/NPSFeedbackForm.svelte" import { get } from "builderStore/api" - import { auth } from "stores/portal" + import { auth, admin } from "stores/portal" import { isActive, goto, layout } from "@roxi/routify" import Logo from "assets/bb-emblem.svg" import { capitalise } from "helpers" + import UpgradeModal from "../../../../components/upgrade/UpgradeModal.svelte" // Get Package and set store export let application - let promise = getPackage() $: selected = capitalise( $layout.children.find(layout => $isActive(layout.path))?.title ?? "data" @@ -92,6 +92,9 @@
+ {#if $admin.sandbox} + + {/if} diff --git a/packages/builder/src/stores/portal/admin.js b/packages/builder/src/stores/portal/admin.js index 0699daf8dc..aac8204089 100644 --- a/packages/builder/src/stores/portal/admin.js +++ b/packages/builder/src/stores/portal/admin.js @@ -22,7 +22,7 @@ export function createAdminStore() { 0 ) - await multiTenancyEnabled() + await getFlags() admin.update(store => { store.loaded = true store.checklist = json @@ -38,20 +38,22 @@ export function createAdminStore() { } } - async function multiTenancyEnabled() { - let enabled = false + async function getFlags() { + let multiTenancyEnabled = false + let sandbox = false try { const response = await api.get(`/api/system/flags`) const json = await response.json() - enabled = json.multiTenancy + multiTenancyEnabled = json.multiTenancy + sandbox = json.sandbox } catch (err) { // just let it stay disabled } admin.update(store => { - store.multiTenancy = enabled + store.multiTenancy = multiTenancyEnabled + store.sandbox = sandbox return store }) - return enabled } function unload() { diff --git a/packages/worker/src/api/controllers/system/flags.js b/packages/worker/src/api/controllers/system/flags.js index fdfc49afad..a8aa73f8c4 100644 --- a/packages/worker/src/api/controllers/system/flags.js +++ b/packages/worker/src/api/controllers/system/flags.js @@ -3,5 +3,6 @@ const env = require("../../../environment") exports.fetch = async ctx => { ctx.body = { multiTenancy: !!env.MULTI_TENANCY, + sandbox: !!env.SANDBOX } } diff --git a/packages/worker/src/environment.js b/packages/worker/src/environment.js index c42bc087e8..07549331ea 100644 --- a/packages/worker/src/environment.js +++ b/packages/worker/src/environment.js @@ -32,6 +32,7 @@ module.exports = { REDIS_PASSWORD: process.env.REDIS_PASSWORD, INTERNAL_API_KEY: process.env.INTERNAL_API_KEY, MULTI_TENANCY: process.env.MULTI_TENANCY, + SANDBOX: process.env.SANDBOX, _set(key, value) { process.env[key] = value module.exports[key] = value