From 00cef3a047b1f0621a3ab0e44a285e6b1b5b1347 Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Thu, 15 Sep 2022 13:22:17 +0100 Subject: [PATCH] Don't show budibase logo on free plan in self hosted installations --- .../client/src/components/app/Layout.svelte | 11 +++++-- packages/client/src/sdk.js | 2 ++ packages/client/src/stores/environment.js | 31 +++++++++++++++++++ packages/client/src/stores/index.js | 1 + packages/client/src/stores/initialise.js | 2 ++ 5 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 packages/client/src/stores/environment.js diff --git a/packages/client/src/components/app/Layout.svelte b/packages/client/src/components/app/Layout.svelte index eb77e7a550..7897782b3e 100644 --- a/packages/client/src/components/app/Layout.svelte +++ b/packages/client/src/components/app/Layout.svelte @@ -9,7 +9,14 @@ import licensing from "../../licensing" const sdk = getContext("sdk") - const { routeStore, styleable, linkable, builderStore, currentRole } = sdk + const { + routeStore, + styleable, + linkable, + builderStore, + currentRole, + environmentStore, + } = sdk const component = getContext("component") const context = getContext("context") @@ -228,7 +235,7 @@ {/if} - {#if !$builderStore.inBuilder && licensing.logoEnabled()} + {#if !$builderStore.inBuilder && licensing.logoEnabled() && $environmentStore.cloud} {/if} diff --git a/packages/client/src/sdk.js b/packages/client/src/sdk.js index 13190e0a4f..aa778388f6 100644 --- a/packages/client/src/sdk.js +++ b/packages/client/src/sdk.js @@ -9,6 +9,7 @@ import { rowSelectionStore, componentStore, currentRole, + environmentStore, } from "stores" import { styleable } from "utils/styleable" import { linkable } from "utils/linkable" @@ -27,6 +28,7 @@ export default { builderStore, uploadStore, componentStore, + environmentStore, currentRole, styleable, linkable, diff --git a/packages/client/src/stores/environment.js b/packages/client/src/stores/environment.js new file mode 100644 index 0000000000..ebeb67c622 --- /dev/null +++ b/packages/client/src/stores/environment.js @@ -0,0 +1,31 @@ +import { API } from "api" +import { writable } from "svelte/store" + +const initialState = { + cloud: false, +} + +const createEnvironmentStore = () => { + const store = writable(initialState) + + const actions = { + fetchEnvironment: async () => { + try { + const environment = await API.getEnvironment() + store.set({ + ...initialState, + ...environment, + }) + } catch (error) { + store.set(initialState) + } + }, + } + + return { + subscribe: store.subscribe, + actions, + } +} + +export const environmentStore = createEnvironmentStore() diff --git a/packages/client/src/stores/index.js b/packages/client/src/stores/index.js index e28fbaee42..378d3febd2 100644 --- a/packages/client/src/stores/index.js +++ b/packages/client/src/stores/index.js @@ -17,6 +17,7 @@ export { devToolsStore } from "./devTools" export { componentStore } from "./components" export { uploadStore } from "./uploads.js" export { rowSelectionStore } from "./rowSelection.js" +export { environmentStore } from "./environment" // Context stores are layered and duplicated, so it is not a singleton export { createContextStore } from "./context" diff --git a/packages/client/src/stores/initialise.js b/packages/client/src/stores/initialise.js index 1900e62ce1..4ad85dfd40 100644 --- a/packages/client/src/stores/initialise.js +++ b/packages/client/src/stores/initialise.js @@ -1,7 +1,9 @@ import { routeStore } from "./routes" import { appStore } from "./app" +import { environmentStore } from "./environment" export async function initialise() { await routeStore.actions.fetchRoutes() await appStore.actions.fetchAppDefinition() + await environmentStore.actions.fetchEnvironment() }