Adding a warning for missing ENCRYPTION_KEY variable to the portal.
This commit is contained in:
parent
3659768c42
commit
3b219dc4ef
|
@ -9,6 +9,7 @@
|
||||||
Table,
|
Table,
|
||||||
Tags,
|
Tags,
|
||||||
Tag,
|
Tag,
|
||||||
|
InlineAlert,
|
||||||
} from "@budibase/bbui"
|
} from "@budibase/bbui"
|
||||||
import { environment, licensing, auth, admin } from "stores/portal"
|
import { environment, licensing, auth, admin } from "stores/portal"
|
||||||
import { onMount } from "svelte"
|
import { onMount } from "svelte"
|
||||||
|
@ -30,7 +31,10 @@
|
||||||
|
|
||||||
const customRenderers = [{ column: "edit", component: EditVariableColumn }]
|
const customRenderers = [{ column: "edit", component: EditVariableColumn }]
|
||||||
|
|
||||||
|
$: encryptionKeyAvailable = $environment.status?.encryptionKeyAvailable
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
|
await environment.checkStatus()
|
||||||
await environment.loadVariables()
|
await environment.loadVariables()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -55,11 +59,18 @@
|
||||||
>
|
>
|
||||||
</Layout>
|
</Layout>
|
||||||
{#if $licensing.environmentVariablesEnabled}
|
{#if $licensing.environmentVariablesEnabled}
|
||||||
|
{#if encryptionKeyAvailable === false}
|
||||||
|
<InlineAlert
|
||||||
|
message="Your Budibase installation does not have a key for encryption, please update your app service's environment variables to contain an 'ENCRYPTION_KEY' value."
|
||||||
|
header="No encryption key found"
|
||||||
|
type="error"
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
<Divider size="S" />
|
<Divider size="S" />
|
||||||
<Layout noPadding>
|
<Layout noPadding>
|
||||||
<Table
|
<Table
|
||||||
{schema}
|
{schema}
|
||||||
data={$environment}
|
data={$environment.variables}
|
||||||
allowEditColumns={false}
|
allowEditColumns={false}
|
||||||
allowEditRows={false}
|
allowEditRows={false}
|
||||||
allowSelectRows={false}
|
allowSelectRows={false}
|
||||||
|
@ -70,7 +81,7 @@
|
||||||
<Button on:click={modal.show} cta>Add Variable</Button>
|
<Button on:click={modal.show} cta>Add Variable</Button>
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<div>
|
<div class="buttons">
|
||||||
<Button
|
<Button
|
||||||
primary
|
primary
|
||||||
disabled={!$auth.accountPortalAccess && $admin.cloud}
|
disabled={!$auth.accountPortalAccess && $admin.cloud}
|
||||||
|
@ -103,4 +114,10 @@
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
gap: var(--spacing-m);
|
gap: var(--spacing-m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.buttons {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
gap: var(--spacing-m);
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -2,25 +2,46 @@ import { writable } from "svelte/store"
|
||||||
import { API } from "api"
|
import { API } from "api"
|
||||||
|
|
||||||
export function createEnvironmentStore() {
|
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() {
|
async function loadVariables() {
|
||||||
let envVars = []
|
const envVars = await API.fetchEnvironmentVariables()
|
||||||
envVars = await API.fetchEnvironmentVariables()
|
|
||||||
const mappedVars = envVars.variables.map(name => ({ name }))
|
const mappedVars = envVars.variables.map(name => ({ name }))
|
||||||
set(mappedVars)
|
update(store => {
|
||||||
|
store.variables = mappedVars
|
||||||
|
return store
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createVariable(data) {
|
async function createVariable(data) {
|
||||||
console.log(data)
|
|
||||||
await API.createEnvironmentVariable(data)
|
await API.createEnvironmentVariable(data)
|
||||||
let mappedVar = { name: data.name }
|
let mappedVar = { name: data.name }
|
||||||
update(envVars => [mappedVar, ...envVars])
|
update(store => {
|
||||||
|
store.variables = [mappedVar, ...store.variables]
|
||||||
|
return store
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteVariable(varName) {
|
async function deleteVariable(varName) {
|
||||||
await API.deleteEnvironmentVariable(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) {
|
async function updateVariable(data) {
|
||||||
|
@ -29,6 +50,7 @@ export function createEnvironmentStore() {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
subscribe,
|
subscribe,
|
||||||
|
checkStatus,
|
||||||
loadVariables,
|
loadVariables,
|
||||||
createVariable,
|
createVariable,
|
||||||
deleteVariable,
|
deleteVariable,
|
||||||
|
|
|
@ -1,4 +1,10 @@
|
||||||
export const buildEnvironmentVariableEndpoints = API => ({
|
export const buildEnvironmentVariableEndpoints = API => ({
|
||||||
|
checkEnvironmentVariableStatus: async () => {
|
||||||
|
return await API.get({
|
||||||
|
url: `/api/env/variables/status`,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches a list of environment variables
|
* Fetches a list of environment variables
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -12,6 +12,11 @@ export interface CreateAppBackupRequest {
|
||||||
name: string
|
name: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface CreateAppBackupResponse {
|
||||||
|
backupId: string
|
||||||
|
message: string
|
||||||
|
}
|
||||||
|
|
||||||
export interface UpdateAppBackupRequest {
|
export interface UpdateAppBackupRequest {
|
||||||
name: string
|
name: string
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
export interface StatusEnvironmentVariableResponse {
|
||||||
|
encryptionKeyAvailable: boolean
|
||||||
|
}
|
||||||
|
|
||||||
export interface CreateEnvironmentVariableRequest {
|
export interface CreateEnvironmentVariableRequest {
|
||||||
name: string
|
name: string
|
||||||
production: string
|
production: string
|
||||||
|
|
Loading…
Reference in New Issue