Merge pull request #9504 from Budibase/feat/env-vars-fixes

Env vars fixes from testing
This commit is contained in:
Peter Clement 2023-02-01 15:55:21 +00:00 committed by GitHub
commit e4c39fe2e4
4 changed files with 38 additions and 11 deletions

View File

@ -22,6 +22,8 @@
let developmentValue let developmentValue
let useProductionValue = true let useProductionValue = true
const HasSpacesRegex = /[\\"\s]/
const deleteVariable = async name => { const deleteVariable = async name => {
try { try {
await environment.deleteVariable(name) await environment.deleteVariable(name)
@ -47,10 +49,16 @@
</script> </script>
<ModalContent <ModalContent
disabled={HasSpacesRegex.test(name)}
onConfirm={() => saveVariable()} onConfirm={() => saveVariable()}
title={!row ? "Add new environment variable" : "Edit environment variable"} title={!row ? "Add new environment variable" : "Edit environment variable"}
> >
<Input disabled={row} label="Name" bind:value={name} /> <Input
disabled={row}
label="Name"
bind:value={name}
error={HasSpacesRegex.test(name) && "Must not include spaces"}
/>
<div> <div>
<Heading size="XS">Production</Heading> <Heading size="XS">Production</Heading>
<Input <Input

View File

@ -1,6 +1,5 @@
<script> <script>
import { ModalContent, Toggle, Body, InlineAlert } from "@budibase/bbui" import { ModalContent, Toggle, Body, InlineAlert } from "@budibase/bbui"
import { licensing } from "stores/portal"
export let app export let app
export let published export let published
@ -17,11 +16,9 @@
</script> </script>
<ModalContent {title} {confirmText} onConfirm={exportApp}> <ModalContent {title} {confirmText} onConfirm={exportApp}>
{#if licensing.environmentVariablesEnabled} <InlineAlert
<InlineAlert header="Do not share your budibase application exports publicly as they may contain sensitive information such as database credentials or secret keys."
header="Do not share your budibase application exports publicly as they may contain sensitive information such as database credentials or secret keys." />
/>
{/if}
<Body <Body
>Apps can be exported with or without data that is within internal tables - >Apps can be exported with or without data that is within internal tables -
select this below.</Body select this below.</Body

View File

@ -11,15 +11,17 @@
Body, Body,
Icon, Icon,
Search, Search,
InlineAlert,
} from "@budibase/bbui" } from "@budibase/bbui"
import Spinner from "components/common/Spinner.svelte" import Spinner from "components/common/Spinner.svelte"
import CreateAppModal from "components/start/CreateAppModal.svelte" import CreateAppModal from "components/start/CreateAppModal.svelte"
import AppLimitModal from "components/portal/licensing/AppLimitModal.svelte" import AppLimitModal from "components/portal/licensing/AppLimitModal.svelte"
import ConfirmDialog from "components/common/ConfirmDialog.svelte"
import { store, automationStore } from "builderStore" import { store, automationStore } from "builderStore"
import { API } from "api" import { API } from "api"
import { onMount } from "svelte" import { onMount } from "svelte"
import { apps, auth, admin, licensing } from "stores/portal" import { apps, auth, admin, licensing, environment } from "stores/portal"
import { goto } from "@roxi/routify" import { goto } from "@roxi/routify"
import AppRow from "components/start/AppRow.svelte" import AppRow from "components/start/AppRow.svelte"
import { AppStatus } from "constants" import { AppStatus } from "constants"
@ -35,6 +37,7 @@
let creatingFromTemplate = false let creatingFromTemplate = false
let automationErrors let automationErrors
let accessFilterList = null let accessFilterList = null
let confirmDownloadDialog
$: welcomeHeader = `Welcome ${$auth?.user?.firstName || "back"}` $: welcomeHeader = `Welcome ${$auth?.user?.firstName || "back"}`
$: enrichedApps = enrichApps($apps, $auth.user, sortBy) $: enrichedApps = enrichApps($apps, $auth.user, sortBy)
@ -193,6 +196,7 @@
onMount(async () => { onMount(async () => {
try { try {
await environment.loadVariables()
// If the portal is loaded from an external URL with a template param // If the portal is loaded from an external URL with a template param
const initInfo = await auth.getInitInfo() const initInfo = await auth.getInitInfo()
if (initInfo?.init_template) { if (initInfo?.init_template) {
@ -275,7 +279,7 @@
<Icon <Icon
name="Download" name="Download"
hoverable hoverable
on:click={initiateAppsExport} on:click={confirmDownloadDialog.show}
/> />
{/if} {/if}
<Select <Select
@ -323,6 +327,18 @@
<AppLimitModal bind:this={appLimitModal} /> <AppLimitModal bind:this={appLimitModal} />
<ConfirmDialog
bind:this={confirmDownloadDialog}
okText="Continue"
onOk={initiateAppsExport}
warning={false}
title="Download all apps"
>
<InlineAlert
header="Do not share your budibase application exports publicly as they may contain sensitive information such as database credentials or secret keys."
/>
</ConfirmDialog>
<style> <style>
.title { .title {
display: flex; display: flex;

View File

@ -25,8 +25,14 @@
$: schema = buildSchema(noEncryptionKey) $: schema = buildSchema(noEncryptionKey)
onMount(async () => { onMount(async () => {
await environment.checkStatus() try {
await environment.loadVariables() await environment.checkStatus()
await environment.loadVariables()
} catch (error) {
notifications.error(
`Error loading environment variables: ${error.message}`
)
}
}) })
const buildSchema = noEncryptionKey => { const buildSchema = noEncryptionKey => {