diff --git a/packages/bbui/src/Form/Core/EnvDropdown.svelte b/packages/bbui/src/Form/Core/EnvDropdown.svelte index 178603ee5d..c7a500372f 100644 --- a/packages/bbui/src/Form/Core/EnvDropdown.svelte +++ b/packages/bbui/src/Form/Core/EnvDropdown.svelte @@ -3,6 +3,9 @@ import { createEventDispatcher, onMount } from "svelte" import clickOutside from "../../Actions/click_outside" import Divider from "../../Divider/Divider.svelte" + import Tag from "../../Tags/Tag.svelte" + import Tags from "../../Tags/Tags.svelte" + export let value = null export let placeholder = null export let type = "text" @@ -24,6 +27,12 @@ let iconFocused = false let open = false + //eslint-disable-next-line + const STRIP_NAME_REGEX = /(?<=\.)(.*?)(?=\ })/g + + // Strips the name out of the value which is {{ env.Variable }} resulting in an array like ["Variable"] + $: tags = String(value)?.match(STRIP_NAME_REGEX) || [] + const updateValue = newValue => { if (readonly) { return @@ -57,15 +66,6 @@ updateValue(event.target.value) } - const updateValueOnEnter = event => { - if (readonly) { - return - } - if (event.key === "Enter") { - updateValue(event.target.value) - } - } - const handleOutsideClick = event => { if (open) { event.stopPropagation() @@ -78,6 +78,8 @@ const handleVarSelect = variable => { open = false + focus = false + iconFocused = false updateValue(`{{ env.${variable} }}`) } @@ -102,6 +104,17 @@ > + +
+
+ {#each tags as tag} + updateValue("")}> + {tag} + + {/each} +
+
+
diff --git a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/IntegrationConfigForm.svelte b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/IntegrationConfigForm.svelte index 1a261008c2..3ea75ffac3 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/IntegrationConfigForm.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/IntegrationConfigForm.svelte @@ -14,7 +14,7 @@ import { IntegrationTypes } from "constants/backend" import { createValidationStore } from "helpers/validation/yup" import { createEventDispatcher, onMount } from "svelte" - import { environment, licensing } from "stores/portal" + import { environment, licensing, auth } from "stores/portal" import CreateEditVariableModal from "components/portal/environment/CreateEditVariableModal.svelte" export let datasource @@ -22,6 +22,8 @@ export let creating let createVariableModal + let selectedKey + const validation = createValidationStore() const dispatch = createEventDispatcher() @@ -69,10 +71,13 @@ function save(data) { environment.createVariable(data) + config[selectedKey] = `{{ env.${data.name} }}` createVariableModal.hide() } - function showModal() { + function showModal(configKey) { + selectedKey = configKey + console.log(selectedKey) createVariableModal.show() } @@ -83,7 +88,13 @@ onMount(async () => { await environment.loadVariables() + + if ($auth.user) { + await licensing.init() + } }) + + $: console.log(config)
@@ -128,7 +139,7 @@
showModal(configKey)} variables={$environment.variables} on:change bind:value={config[configKey]} diff --git a/packages/builder/src/components/portal/environment/CreateEditVariableModal.svelte b/packages/builder/src/components/portal/environment/CreateEditVariableModal.svelte index 44fdbd0182..70029eb3c5 100644 --- a/packages/builder/src/components/portal/environment/CreateEditVariableModal.svelte +++ b/packages/builder/src/components/portal/environment/CreateEditVariableModal.svelte @@ -32,15 +32,23 @@ notifications.error(err.message) } } + + const saveVariable = () => { + try { + save({ + name, + production: productionValue, + development: developmentValue, + }) + notifications.success("Environment variable saved") + } catch (err) { + notifications.error("Error saving environment variable") + } + } - save({ - name, - production: productionValue, - development: developmentValue, - })} + onConfirm={() => saveVariable()} title={!row ? "Add new environment variable" : "Edit environment variable"} >