Disabling edit/add options for environment variables when encryption key is not found.

This commit is contained in:
mike12345567 2023-01-18 17:49:18 +00:00
parent 3b219dc4ef
commit a6a42f4d2e
1 changed files with 23 additions and 15 deletions

View File

@ -18,26 +18,32 @@
let modal let modal
const schema = {
name: {
width: "2fr",
},
edit: {
width: "auto",
borderLeft: true,
displayName: "",
},
}
const customRenderers = [{ column: "edit", component: EditVariableColumn }] const customRenderers = [{ column: "edit", component: EditVariableColumn }]
$: encryptionKeyAvailable = $environment.status?.encryptionKeyAvailable $: noEncryptionKey = $environment.status?.encryptionKeyAvailable === false
$: schema = buildSchema(noEncryptionKey)
onMount(async () => { onMount(async () => {
await environment.checkStatus() await environment.checkStatus()
await environment.loadVariables() await environment.loadVariables()
}) })
const buildSchema = noEncryptionKey => {
const schema = {
name: {
width: "2fr",
},
}
if (!noEncryptionKey) {
schema.edit = {
width: "auto",
borderLeft: true,
displayName: "",
}
}
return schema
}
const save = data => { const save = data => {
environment.createVariable(data) environment.createVariable(data)
modal.hide() modal.hide()
@ -58,8 +64,8 @@
>Add and manage environment variables for development and production</Body >Add and manage environment variables for development and production</Body
> >
</Layout> </Layout>
{#if $licensing.environmentVariablesEnabled} {#if !$licensing.environmentVariablesEnabled}
{#if encryptionKeyAvailable === false} {#if noEncryptionKey}
<InlineAlert <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." 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" header="No encryption key found"
@ -78,7 +84,9 @@
/> />
</Layout> </Layout>
<div> <div>
<Button on:click={modal.show} cta>Add Variable</Button> <Button on:click={modal.show} cta disabled={noEncryptionKey}
>Add Variable</Button
>
</div> </div>
{:else} {:else}
<div class="buttons"> <div class="buttons">