From ed9b12f558b59a1160e93696f9e3f77a4d8a21ce Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 21 Mar 2025 10:47:43 +0100 Subject: [PATCH 01/26] Type EnvDropdown --- .../bbui/src/Form/Core/EnvDropdown.svelte | 34 +++++++++---------- packages/bbui/src/Form/EnvDropdown.svelte | 17 ++++------ 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/packages/bbui/src/Form/Core/EnvDropdown.svelte b/packages/bbui/src/Form/Core/EnvDropdown.svelte index ed5878d6b2..9873cfd08e 100644 --- a/packages/bbui/src/Form/Core/EnvDropdown.svelte +++ b/packages/bbui/src/Form/Core/EnvDropdown.svelte @@ -1,25 +1,25 @@ - + + modal.show()} + {handleUpgradePanel} +/> + + + + From 3b047b166c9d8af6baf93e91e53a9a31205c8d0c Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 24 Mar 2025 12:04:07 +0100 Subject: [PATCH 11/26] Reuse EnvVariableInput in String --- .../ConfigEditor/fields/String.svelte | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/packages/builder/src/components/backend/Datasources/ConfigEditor/fields/String.svelte b/packages/builder/src/components/backend/Datasources/ConfigEditor/fields/String.svelte index a526dec42c..48d10798b2 100644 --- a/packages/builder/src/components/backend/Datasources/ConfigEditor/fields/String.svelte +++ b/packages/builder/src/components/backend/Datasources/ConfigEditor/fields/String.svelte @@ -1,33 +1,23 @@
-
From 9966175abd55b8f2b9cdf64da16c9c35f9d81c49 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 24 Mar 2025 12:12:26 +0100 Subject: [PATCH 12/26] Type RestAuthenticaionModal --- .../common/bindings/BindableCombobox.svelte | 4 ++-- .../RestAuthenticationModal.svelte | 24 +++++++++---------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/packages/builder/src/components/common/bindings/BindableCombobox.svelte b/packages/builder/src/components/common/bindings/BindableCombobox.svelte index b3b7511ccd..467b9d68ad 100644 --- a/packages/builder/src/components/common/bindings/BindableCombobox.svelte +++ b/packages/builder/src/components/common/bindings/BindableCombobox.svelte @@ -9,10 +9,10 @@ export let value = "" export let bindings = [] - export let placeholder + export let placeholder = undefined export let label export let disabled = false - export let options + export let options = undefined export let appendBindingsAsOptions = true export let error diff --git a/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication/RestAuthenticationModal.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication/RestAuthenticationModal.svelte index 9b562182b7..05ae8bc07e 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication/RestAuthenticationModal.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication/RestAuthenticationModal.svelte @@ -1,4 +1,4 @@ - +{value} import { onMount } from "svelte" - import { - ModalContent, - Layout, - Select, - Body, - Input, - EnvDropdown, - Modal, - notifications, - } from "@budibase/bbui" + import { ModalContent, Layout, Select, Body, Input } from "@budibase/bbui" import { AUTH_TYPE_LABELS, AUTH_TYPES } from "./authTypes" import { BindableCombobox } from "@/components/common/bindings" import { getAuthBindings, getEnvironmentBindings } from "@/dataBinding" import { environment, licensing, auth } from "@/stores/portal" - import CreateEditVariableModal from "@/components/portal/environment/CreateEditVariableModal.svelte" + import EnvVariableInput from "@/components/portal/environment/EnvVariableInput.svelte" + + interface FormData { + name?: string + type?: string + basic: { + username?: string + password?: string + } + bearer: { + token?: string + } + } export let configs export let currentConfig @@ -49,9 +52,6 @@ let hasErrors = false let hasChanged = false - let createVariableModal: Modal - let formFieldkey: string - onMount(async () => { try { await environment.loadVariables() @@ -179,16 +179,6 @@ } } - const save = async (data: any) => { - try { - await environment.createVariable(data) - form.basic[formFieldkey] = `{{ env.${data.name} }}` - createVariableModal.hide() - } catch (err: any) { - notifications.error(`Failed to create variable: ${err.message}`) - } - } - const onFieldChange = () => { checkErrors() checkChanged() @@ -197,16 +187,6 @@ const onConfirmInternal = () => { onConfirm(constructConfig()) } - - async function handleUpgradePanel() { - await environment.upgradePanelOpened() - $licensing.goToUpgradePage() - } - - function showModal(key: any) { - formFieldkey = key - createVariableModal.show() - } {#if form.type === AUTH_TYPES.BASIC} - (blurred.basic.username = true)} - error={blurred.basic.username ? errors.basic.username : null} - showModal={() => showModal("configKey")} - variables={$environment.variables} - environmentVariablesEnabled={$licensing.environmentVariablesEnabled} - {handleUpgradePanel} + error={blurred.basic.username ? errors.basic.username : undefined} /> - (blurred.basic.password = true)} - error={blurred.basic.password ? errors.basic.password : null} - showModal={() => showModal("configKey")} - variables={$environment.variables} - environmentVariablesEnabled={$licensing.environmentVariablesEnabled} - {handleUpgradePanel} + error={blurred.basic.password ? errors.basic.password : undefined} /> {/if} {#if form.type === AUTH_TYPES.BEARER} @@ -291,7 +264,3 @@ {/if} - - - - From 62d9ad6b6662807b3c31fbccbffd3cd9a51ef27e Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 24 Mar 2025 12:30:24 +0100 Subject: [PATCH 15/26] Fix binding --- .../src/components/portal/environment/EnvVariableInput.svelte | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/builder/src/components/portal/environment/EnvVariableInput.svelte b/packages/builder/src/components/portal/environment/EnvVariableInput.svelte index a8cc3a01d2..2c659ff4aa 100644 --- a/packages/builder/src/components/portal/environment/EnvVariableInput.svelte +++ b/packages/builder/src/components/portal/environment/EnvVariableInput.svelte @@ -33,13 +33,12 @@ } -{value} Date: Mon, 24 Mar 2025 12:34:50 +0100 Subject: [PATCH 16/26] Type config input --- .../ConfigEditor/ConfigInput.svelte | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/packages/builder/src/components/backend/Datasources/ConfigEditor/ConfigInput.svelte b/packages/builder/src/components/backend/Datasources/ConfigEditor/ConfigInput.svelte index 569f77d5ce..7021141f6f 100644 --- a/packages/builder/src/components/backend/Datasources/ConfigEditor/ConfigInput.svelte +++ b/packages/builder/src/components/backend/Datasources/ConfigEditor/ConfigInput.svelte @@ -1,4 +1,4 @@ - showModal(nameStore.updateValue)} on:blur={nameStore.markActive} on:change={e => nameStore.updateValue(e.detail)} /> @@ -94,15 +66,9 @@ {name} {config} {placeholder} - showModal={() => - showModal(newValue => configStore.updateFieldValue(key, newValue))} on:blur={() => configStore.markFieldActive(key)} on:change={e => configStore.updateFieldValue(key, e.detail)} /> {/if} {/each} - - - - From 2b2b6951f279cb945b41403043ff132a667714ff Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 24 Mar 2025 12:45:08 +0100 Subject: [PATCH 18/26] Fix type --- packages/bbui/src/Menu/Item.svelte | 2 +- packages/bbui/src/types/actionMenu.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/bbui/src/Menu/Item.svelte b/packages/bbui/src/Menu/Item.svelte index d07939d894..bee00e5225 100644 --- a/packages/bbui/src/Menu/Item.svelte +++ b/packages/bbui/src/Menu/Item.svelte @@ -3,7 +3,7 @@ import Icon from "../Icon/Icon.svelte" const dispatch = createEventDispatcher() - const actionMenu = getContext("actionMenu") as { hideAll: () => void } + const actionMenu = getContext("actionMenu") export let icon: string | undefined = undefined export let disabled: boolean | undefined = undefined diff --git a/packages/bbui/src/types/actionMenu.ts b/packages/bbui/src/types/actionMenu.ts index 872a9f7c75..a21ec83d66 100644 --- a/packages/bbui/src/types/actionMenu.ts +++ b/packages/bbui/src/types/actionMenu.ts @@ -1,3 +1,4 @@ export interface ActionMenu { hide: () => void + hideAll: () => void } From 3b0084aac00c76e05136769109586c98577d32b9 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 24 Mar 2025 13:08:04 +0100 Subject: [PATCH 19/26] Fix types --- packages/bbui/src/Form/Core/EnvDropdown.svelte | 2 +- packages/bbui/src/Form/EnvDropdown.svelte | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/bbui/src/Form/Core/EnvDropdown.svelte b/packages/bbui/src/Form/Core/EnvDropdown.svelte index 853120defd..45a986f23f 100644 --- a/packages/bbui/src/Form/Core/EnvDropdown.svelte +++ b/packages/bbui/src/Form/Core/EnvDropdown.svelte @@ -3,7 +3,7 @@ import { createEventDispatcher, onMount } from "svelte" import clickOutside from "../../Actions/click_outside" import Divider from "../../Divider/Divider.svelte" - import type { EnvDropdownType } from "@/types" + import type { EnvDropdownType } from "../../types" export let value: string | number | undefined = undefined export let placeholder: string | undefined = undefined diff --git a/packages/bbui/src/Form/EnvDropdown.svelte b/packages/bbui/src/Form/EnvDropdown.svelte index f24d32353e..c86802aaa8 100644 --- a/packages/bbui/src/Form/EnvDropdown.svelte +++ b/packages/bbui/src/Form/EnvDropdown.svelte @@ -2,7 +2,7 @@ import Field from "./Field.svelte" import EnvDropdown from "./Core/EnvDropdown.svelte" import { createEventDispatcher } from "svelte" - import type { EnvDropdownType } from "@/types" + import type { EnvDropdownType } from "../types" export let value: string | undefined = undefined export let label: string | undefined = undefined From 6bbbebb5ae4138ca36534559755cfe33f946bb33 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 24 Mar 2025 13:39:22 +0100 Subject: [PATCH 20/26] Fix build --- .../src/components/portal/environment/EnvVariableInput.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/builder/src/components/portal/environment/EnvVariableInput.svelte b/packages/builder/src/components/portal/environment/EnvVariableInput.svelte index 2c659ff4aa..39531b1f9c 100644 --- a/packages/builder/src/components/portal/environment/EnvVariableInput.svelte +++ b/packages/builder/src/components/portal/environment/EnvVariableInput.svelte @@ -38,7 +38,7 @@ on:blur bind:value {label} - type={type === "port" ? "string" : type} + type={type === "port" ? "text" : type} {error} {placeholder} variables={$environment.variables} From be12e7cbbd47f5a5178364a0b659a0ed9297ef80 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 24 Mar 2025 17:21:52 +0100 Subject: [PATCH 21/26] Load variables from envVariableInput --- .../automation/SetupPanel/AutomationBlockSetup.svelte | 11 +---------- .../src/components/integration/RestQueryViewer.svelte | 9 +-------- .../portal/environment/EnvVariableInput.svelte | 10 ++++++++++ .../Authentication/RestAuthenticationModal.svelte | 11 +---------- .../src/pages/builder/portal/apps/index.svelte | 2 -- 5 files changed, 13 insertions(+), 30 deletions(-) diff --git a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte index 194add5975..5c6db6fb89 100644 --- a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte +++ b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte @@ -23,7 +23,6 @@ import CreateWebhookModal from "@/components/automation/Shared/CreateWebhookModal.svelte" import { automationStore, tables, evaluationContext } from "@/stores/builder" - import { environment } from "@/stores/portal" import WebhookDisplay from "../Shared/WebhookDisplay.svelte" import { BindingSidePanel, @@ -58,7 +57,7 @@ } from "@budibase/frontend-core" import { getSchemaForDatasourcePlus } from "@/dataBinding" import { TriggerStepID, ActionStepID } from "@/constants/backend/automations" - import { onMount, createEventDispatcher } from "svelte" + import { createEventDispatcher } from "svelte" import { writable } from "svelte/store" import { cloneDeep } from "lodash/fp" import { @@ -772,14 +771,6 @@ } return params } - - onMount(async () => { - try { - await environment.loadVariables() - } catch (error) { - console.error(error) - } - })
diff --git a/packages/builder/src/components/integration/RestQueryViewer.svelte b/packages/builder/src/components/integration/RestQueryViewer.svelte index d23b8c9577..86cbee1732 100644 --- a/packages/builder/src/components/integration/RestQueryViewer.svelte +++ b/packages/builder/src/components/integration/RestQueryViewer.svelte @@ -1,7 +1,7 @@ { - try { - await environment.loadVariables() - if ($auth.user) { - await licensing.init() - } - } catch (err) { - console.error(err) - } - if (currentConfig) { deconstructConfig() } diff --git a/packages/builder/src/pages/builder/portal/apps/index.svelte b/packages/builder/src/pages/builder/portal/apps/index.svelte index bcd59cd948..91e84dd650 100644 --- a/packages/builder/src/pages/builder/portal/apps/index.svelte +++ b/packages/builder/src/pages/builder/portal/apps/index.svelte @@ -24,7 +24,6 @@ auth, admin, licensing, - environment, enrichedApps, sortBy, } from "@/stores/portal" @@ -162,7 +161,6 @@ onMount(async () => { try { - await environment.loadVariables() // If the portal is loaded from an external URL with a template param const initInfo = await auth.getInitInfo() if (initInfo?.init_template) { From 77b2d44966231b880b6476e09c8638394a55b893 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 25 Mar 2025 11:53:05 +0100 Subject: [PATCH 22/26] Undo unnecessary config --- packages/bbui/tsconfig.json | 3 +-- packages/bbui/vite.config.js | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/bbui/tsconfig.json b/packages/bbui/tsconfig.json index a7e4001c75..af898e27a1 100644 --- a/packages/bbui/tsconfig.json +++ b/packages/bbui/tsconfig.json @@ -11,8 +11,7 @@ "../*/src/index.js", "../*", "../../node_modules/@budibase/*" - ], - "@/*": ["./src/*"] + ] } }, "include": ["./src/**/*"], diff --git a/packages/bbui/vite.config.js b/packages/bbui/vite.config.js index 337c3ad6e9..bccca20e43 100644 --- a/packages/bbui/vite.config.js +++ b/packages/bbui/vite.config.js @@ -23,7 +23,6 @@ export default defineConfig(({ mode }) => { alias: { "@budibase/shared-core": path.resolve(__dirname, "../shared-core/src"), "@budibase/types": path.resolve(__dirname, "../types/src"), - "@": path.resolve(__dirname, "src"), }, }, } From 5a993b42706fee43bd0c3840899240cb89daa4b3 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 25 Mar 2025 12:27:00 +0100 Subject: [PATCH 23/26] Update value on creation --- .../src/components/portal/environment/EnvVariableInput.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/builder/src/components/portal/environment/EnvVariableInput.svelte b/packages/builder/src/components/portal/environment/EnvVariableInput.svelte index 1ca05c62ba..5f07dcd88f 100644 --- a/packages/builder/src/components/portal/environment/EnvVariableInput.svelte +++ b/packages/builder/src/components/portal/environment/EnvVariableInput.svelte @@ -26,7 +26,7 @@ async function saveVariable(data: CreateEnvironmentVariableRequest) { try { await environment.createVariable(data) - // configValueSetterCallback(`{{ env.${data.name} }}`) + value = `{{ env.${data.name} }}` modal.hide() } catch (err: any) { notifications.error(`Failed to create variable: ${err.message}`) From 9a09837722f535ed83c9e3c14b574916df8fc127 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 25 Mar 2025 13:26:53 +0100 Subject: [PATCH 24/26] Avoid duplicated errors --- .../portal/environment/EnvVariableInput.svelte | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/builder/src/components/portal/environment/EnvVariableInput.svelte b/packages/builder/src/components/portal/environment/EnvVariableInput.svelte index 5f07dcd88f..59d334345f 100644 --- a/packages/builder/src/components/portal/environment/EnvVariableInput.svelte +++ b/packages/builder/src/components/portal/environment/EnvVariableInput.svelte @@ -24,13 +24,9 @@ } async function saveVariable(data: CreateEnvironmentVariableRequest) { - try { - await environment.createVariable(data) - value = `{{ env.${data.name} }}` - modal.hide() - } catch (err: any) { - notifications.error(`Failed to create variable: ${err.message}`) - } + await environment.createVariable(data) + value = `{{ env.${data.name} }}` + modal.hide() } onMount(async () => { From 3e59fcdbbb0594fc77934306ea6cf84e1eb6014c Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 25 Mar 2025 14:18:48 +0100 Subject: [PATCH 25/26] Load environment on automations --- .../automation/SetupPanel/AutomationBlockSetup.svelte | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte index 5c6db6fb89..194add5975 100644 --- a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte +++ b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte @@ -23,6 +23,7 @@ import CreateWebhookModal from "@/components/automation/Shared/CreateWebhookModal.svelte" import { automationStore, tables, evaluationContext } from "@/stores/builder" + import { environment } from "@/stores/portal" import WebhookDisplay from "../Shared/WebhookDisplay.svelte" import { BindingSidePanel, @@ -57,7 +58,7 @@ } from "@budibase/frontend-core" import { getSchemaForDatasourcePlus } from "@/dataBinding" import { TriggerStepID, ActionStepID } from "@/constants/backend/automations" - import { createEventDispatcher } from "svelte" + import { onMount, createEventDispatcher } from "svelte" import { writable } from "svelte/store" import { cloneDeep } from "lodash/fp" import { @@ -771,6 +772,14 @@ } return params } + + onMount(async () => { + try { + await environment.loadVariables() + } catch (error) { + console.error(error) + } + })
From 52cc191ab29529750e93eb10f5b04fef4dbf3cbf Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 25 Mar 2025 14:23:41 +0100 Subject: [PATCH 26/26] Load variables on mount --- .../RestAuthenticationModal.svelte | 19 +++++++++++++++++-- .../_components/panels/Variables/index.svelte | 13 +++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication/RestAuthenticationModal.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication/RestAuthenticationModal.svelte index d68dc82aa7..fa14c31809 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication/RestAuthenticationModal.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication/RestAuthenticationModal.svelte @@ -1,10 +1,17 @@ - import { Heading, Layout } from "@budibase/bbui" + import { Heading, Layout, notifications } from "@budibase/bbui" import KeyValueBuilder from "@/components/integration/KeyValueBuilder.svelte" import ViewDynamicVariables from "./ViewDynamicVariables.svelte" import { getEnvironmentBindings } from "@/dataBinding" - import { licensing } from "@/stores/portal" + import { environment, licensing } from "@/stores/portal" import { queries } from "@/stores/builder" import { cloneDeep } from "lodash/fp" import SaveDatasourceButton from "../SaveDatasourceButton.svelte" import Panel from "../Panel.svelte" import Tooltip from "../Tooltip.svelte" + import { onMount } from "svelte" export let datasource @@ -27,6 +28,14 @@ updatedDatasource.config.staticVariables = newStaticVariables } + + onMount(async () => { + try { + await environment.loadVariables() + } catch (error) { + notifications.error(`Error getting environment variables - ${error}`) + } + })