From 66e593a6b310f57e88157ce3200c844e35bae9ce Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Thu, 12 Aug 2021 11:51:08 +0100 Subject: [PATCH 1/5] 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 From adecf1897ab4bbf0b4a42e02c4186f8e1820b873 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Thu, 12 Aug 2021 12:09:53 +0100 Subject: [PATCH 2/5] Add link to account portal --- .../src/components/upgrade/UpgradeModal.svelte | 11 ++++++++++- packages/worker/src/api/controllers/system/flags.js | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/builder/src/components/upgrade/UpgradeModal.svelte b/packages/builder/src/components/upgrade/UpgradeModal.svelte index d87d361d59..783eb84064 100644 --- a/packages/builder/src/components/upgrade/UpgradeModal.svelte +++ b/packages/builder/src/components/upgrade/UpgradeModal.svelte @@ -2,6 +2,10 @@ import { Modal, ModalContent, Button } from "@budibase/bbui" let upgradeModal + + const onConfirm = () => { + window.open("https://accounts.budibase.com/install", "_blank") + }
@@ -14,7 +18,12 @@ >
- + Upgrade to Budibase self-hosting for free, and get SSO, unlimited apps, and more - and it only takes 10 minutes! { ctx.body = { multiTenancy: !!env.MULTI_TENANCY, - sandbox: !!env.SANDBOX + sandbox: !!env.SANDBOX, } } From 6cf5a86f8c8ac02cc509c8c2f54c35c0aa2b3d05 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Thu, 12 Aug 2021 14:20:23 +0100 Subject: [PATCH 3/5] Add default config to admin store --- packages/builder/src/stores/portal/admin.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/builder/src/stores/portal/admin.js b/packages/builder/src/stores/portal/admin.js index aac8204089..4d0530f7ae 100644 --- a/packages/builder/src/stores/portal/admin.js +++ b/packages/builder/src/stores/portal/admin.js @@ -3,9 +3,16 @@ import api from "builderStore/api" import { auth } from "stores/portal" export function createAdminStore() { - const admin = writable({ + + const DEFAULT_CONFIG = { loaded: false, - }) + multiTenancy: false, + sandbox: false, + onboardingProgress: 0, + checklist: {"apps":0,"smtp":false,"adminUser":false,"sso":false} + } + + const admin = writable(DEFAULT_CONFIG) async function init() { try { From 247920743658b60b953f0ace2d3924cc6cfea407 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Thu, 12 Aug 2021 14:20:46 +0100 Subject: [PATCH 4/5] Change self host button text --- packages/builder/src/components/upgrade/UpgradeModal.svelte | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/builder/src/components/upgrade/UpgradeModal.svelte b/packages/builder/src/components/upgrade/UpgradeModal.svelte index 783eb84064..f73dcf335f 100644 --- a/packages/builder/src/components/upgrade/UpgradeModal.svelte +++ b/packages/builder/src/components/upgrade/UpgradeModal.svelte @@ -14,7 +14,7 @@ quiet primary size="M" - icon="DownloadFromCloud">Upgrade to self-hostedSelf-host Budibase
@@ -26,7 +26,7 @@ > Upgrade to Budibase self-hosting for free, and get SSO, unlimited apps, - and more - and it only takes 10 minutes! From a4649c5bc965b83ff2ba1eb656c4cded3d477c00 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Thu, 12 Aug 2021 14:27:05 +0100 Subject: [PATCH 5/5] linting --- packages/builder/src/stores/portal/admin.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/builder/src/stores/portal/admin.js b/packages/builder/src/stores/portal/admin.js index 4d0530f7ae..25688ac70c 100644 --- a/packages/builder/src/stores/portal/admin.js +++ b/packages/builder/src/stores/portal/admin.js @@ -3,15 +3,14 @@ import api from "builderStore/api" import { auth } from "stores/portal" export function createAdminStore() { - const DEFAULT_CONFIG = { loaded: false, multiTenancy: false, sandbox: false, onboardingProgress: 0, - checklist: {"apps":0,"smtp":false,"adminUser":false,"sso":false} + checklist: { apps: 0, smtp: false, adminUser: false, sso: false }, } - + const admin = writable(DEFAULT_CONFIG) async function init() {