From 0bd35be8614268711dc3aebb04ee35d11f5a73d0 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 9 Jun 2023 11:57:17 +0100 Subject: [PATCH] Navigate when the modal is closed and the datasource was created --- .../modals/GoogleDatasourceConfigModal.svelte | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/builder/src/components/backend/DatasourceNavigator/modals/GoogleDatasourceConfigModal.svelte b/packages/builder/src/components/backend/DatasourceNavigator/modals/GoogleDatasourceConfigModal.svelte index 83806153c9..819d1e7d2d 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/modals/GoogleDatasourceConfigModal.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/modals/GoogleDatasourceConfigModal.svelte @@ -10,7 +10,7 @@ import { IntegrationNames, IntegrationTypes } from "constants/backend" import GoogleButton from "../_components/GoogleButton.svelte" import { organisation } from "stores/portal" - import { onMount } from "svelte" + import { onMount, onDestroy } from "svelte" import { validateDatasourceConfig, getDatasourceInfo, @@ -34,6 +34,7 @@ onMount(async () => { await organisation.init() }) + const integrationName = IntegrationNames[IntegrationTypes.GOOGLE_SHEETS] export const GoogleDatasouceConfigStep = { @@ -82,7 +83,6 @@ } if (!integration.features[DatasourceFeature.FETCH_TABLE_NAMES]) { - $goto(`./datasource/${datasource._id}`) notifications.success(`Datasource created successfully.`) return } @@ -115,18 +115,22 @@ }) } - $goto(`./datasource/${datasource._id}`) + return } catch (err) { notifications.error(err?.message ?? "Error fetching the sheets") // prevent the modal from closing return false } }, - onCancel: async () => { - $goto(`./datasource/${datasource._id}`) - }, }, } + + // This will handle the user closing the modal pressing outside the modal + onDestroy(async () => { + if (step === GoogleDatasouceConfigStep.SET_SHEETS) { + await $goto(`./datasource/${datasource._id}`) + } + }) {#if step === GoogleDatasouceConfigStep.AUTH}