From 2eac4ff604966ce5b8be87c253c14723dc1f941b Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Mon, 30 Jan 2023 16:40:16 +0000 Subject: [PATCH] fix async handling for variable creation --- .../IntegrationConfigForm.svelte | 13 +++++++++---- .../rest/auth/RestAuthenticationModal.svelte | 13 +++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/IntegrationConfigForm.svelte b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/IntegrationConfigForm.svelte index 166e9474c6..92bc04e2b3 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/IntegrationConfigForm.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/IntegrationConfigForm.svelte @@ -9,6 +9,7 @@ Modal, EnvDropdown, Accordion, + notifications, } from "@budibase/bbui" import KeyValueBuilder from "components/integration/KeyValueBuilder.svelte" import { capitalise } from "helpers" @@ -79,10 +80,14 @@ .map(([key]) => key) } - function save(data) { - environment.createVariable(data) - config[selectedKey] = `{{ env.${data.name} }}` - createVariableModal.hide() + async function save(data) { + try { + await environment.createVariable(data) + config[selectedKey] = `{{ env.${data.name} }}` + createVariableModal.hide() + } catch (err) { + notifications.error(`Failed to create variable: ${err.message}`) + } } function showModal(configKey) { diff --git a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/rest/auth/RestAuthenticationModal.svelte b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/rest/auth/RestAuthenticationModal.svelte index f4dab4bb61..80c5a18ade 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/rest/auth/RestAuthenticationModal.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/rest/auth/RestAuthenticationModal.svelte @@ -8,6 +8,7 @@ Input, EnvDropdown, Modal, + notifications, } from "@budibase/bbui" import { AUTH_TYPE_LABELS, AUTH_TYPES } from "./authTypes" import BindableCombobox from "components/common/bindings/BindableCombobox.svelte" @@ -171,10 +172,14 @@ } } - const save = data => { - environment.createVariable(data) - form.basic[formFieldkey] = `{{ env.${data.name} }}` - createVariableModal.hide() + const save = async data => { + try { + await environment.createVariable(data) + form.basic[formFieldkey] = `{{ env.${data.name} }}` + createVariableModal.hide() + } catch (err) { + notifications.error(`Failed to create variable: ${err.message}`) + } } const onFieldChange = () => {