diff --git a/packages/builder/src/pages/builder/portal/settings/environment/index.svelte b/packages/builder/src/pages/builder/portal/settings/environment/index.svelte index bb9df4a946..f31f5dba69 100644 --- a/packages/builder/src/pages/builder/portal/settings/environment/index.svelte +++ b/packages/builder/src/pages/builder/portal/settings/environment/index.svelte @@ -9,6 +9,7 @@ Table, Tags, Tag, + InlineAlert, } from "@budibase/bbui" import { environment, licensing, auth, admin } from "stores/portal" import { onMount } from "svelte" @@ -30,7 +31,10 @@ const customRenderers = [{ column: "edit", component: EditVariableColumn }] + $: encryptionKeyAvailable = $environment.status?.encryptionKeyAvailable + onMount(async () => { + await environment.checkStatus() await environment.loadVariables() }) @@ -55,11 +59,18 @@ > {#if $licensing.environmentVariablesEnabled} + {#if encryptionKeyAvailable === false} + + {/if} Add Variable {:else} - + diff --git a/packages/builder/src/stores/portal/environment.js b/packages/builder/src/stores/portal/environment.js index fa06242cf5..dbf42a37e1 100644 --- a/packages/builder/src/stores/portal/environment.js +++ b/packages/builder/src/stores/portal/environment.js @@ -2,25 +2,46 @@ import { writable } from "svelte/store" import { API } from "api" export function createEnvironmentStore() { - const { subscribe, set, update } = writable([]) + const { subscribe, update } = writable({ + variables: [], + status: {}, + }) + + async function checkStatus() { + const status = await API.checkEnvironmentVariableStatus() + console.log(status) + update(store => { + store.status = status + return store + }) + } async function loadVariables() { - let envVars = [] - envVars = await API.fetchEnvironmentVariables() + const envVars = await API.fetchEnvironmentVariables() const mappedVars = envVars.variables.map(name => ({ name })) - set(mappedVars) + update(store => { + store.variables = mappedVars + return store + }) } async function createVariable(data) { - console.log(data) await API.createEnvironmentVariable(data) let mappedVar = { name: data.name } - update(envVars => [mappedVar, ...envVars]) + update(store => { + store.variables = [mappedVar, ...store.variables] + return store + }) } async function deleteVariable(varName) { await API.deleteEnvironmentVariable(varName) - update(envVars => envVars.filter(envVar => envVar.name !== varName)) + update(store => { + store.variables = store.variables.filter( + envVar => envVar.name !== varName + ) + return store + }) } async function updateVariable(data) { @@ -29,6 +50,7 @@ export function createEnvironmentStore() { return { subscribe, + checkStatus, loadVariables, createVariable, deleteVariable, diff --git a/packages/frontend-core/src/api/environmentVariables.js b/packages/frontend-core/src/api/environmentVariables.js index d96848707b..badd93ad69 100644 --- a/packages/frontend-core/src/api/environmentVariables.js +++ b/packages/frontend-core/src/api/environmentVariables.js @@ -1,4 +1,10 @@ export const buildEnvironmentVariableEndpoints = API => ({ + checkEnvironmentVariableStatus: async () => { + return await API.get({ + url: `/api/env/variables/status`, + }) + }, + /** * Fetches a list of environment variables */ diff --git a/packages/types/src/api/web/app/backup.ts b/packages/types/src/api/web/app/backup.ts index f16f8416ae..c9a8d07f5e 100644 --- a/packages/types/src/api/web/app/backup.ts +++ b/packages/types/src/api/web/app/backup.ts @@ -12,6 +12,11 @@ export interface CreateAppBackupRequest { name: string } +export interface CreateAppBackupResponse { + backupId: string + message: string +} + export interface UpdateAppBackupRequest { name: string } diff --git a/packages/types/src/api/web/global/environmentVariables.ts b/packages/types/src/api/web/global/environmentVariables.ts index 9c39f1c239..6f339eb821 100644 --- a/packages/types/src/api/web/global/environmentVariables.ts +++ b/packages/types/src/api/web/global/environmentVariables.ts @@ -1,3 +1,7 @@ +export interface StatusEnvironmentVariableResponse { + encryptionKeyAvailable: boolean +} + export interface CreateEnvironmentVariableRequest { name: string production: string