From 1299917e9435ada308a70aa99df6bcfdbcf2ad4e Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 17 Oct 2023 17:35:10 +0100 Subject: [PATCH] Quick fix for datasource deletion, due to the datasource defaulting to an empty object it appeared like a datasource had been set and the UI would attempt to render with this empty state. When not selected move off of the selected datasource page instead and handle the datasource not being selected. --- .../datasource/[datasourceId]/index.svelte | 99 ++++++++++--------- 1 file changed, 55 insertions(+), 44 deletions(-) diff --git a/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/index.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/index.svelte index 6ce9cf7921..1a887dd483 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/index.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/index.svelte @@ -12,16 +12,25 @@ import PromptQueryModal from "./_components/PromptQueryModal.svelte" import SettingsPanel from "./_components/panels/Settings.svelte" import { helpers } from "@budibase/shared-core" + import { goto } from "@roxi/routify" let selectedPanel = null let panelOptions = [] // datasources.selected can return null temporarily on datasource deletion - $: datasource = $datasources.selected || {} + $: datasource = $datasources.selected + $: { + if (!datasource) { + $goto("./datasource") + } + } $: getOptions(datasource) const getOptions = datasource => { + if (!datasource) { + return + } if (datasource.plus) { // Google Sheets' integration definition specifies `relationships: false` as it doesn't support relationships like other plus datasources panelOptions = @@ -49,51 +58,53 @@ -
- - -
- - {$datasources.selected?.name} -
-
- -
- - {#each panelOptions as panelOption} - (selectedPanel = panelOption)} +{#if datasource} +
+ + +
+ - {/each} - -
+ {$datasources.selected?.name} + +
+ +
+ + {#each panelOptions as panelOption} + (selectedPanel = panelOption)} + /> + {/each} + +
- {#if selectedPanel === null} - loading... - {:else if selectedPanel === "Tables"} - - {:else if selectedPanel === "Relationships"} - - {:else if selectedPanel === "Queries"} - - {:else if selectedPanel === "Headers"} - - {:else if selectedPanel === "Authentication"} - - {:else if selectedPanel === "Variables"} - - {:else if selectedPanel === "Settings"} - - {:else} - Something went wrong - {/if} - -
+ {#if selectedPanel === null} + loading... + {:else if selectedPanel === "Tables"} + + {:else if selectedPanel === "Relationships"} + + {:else if selectedPanel === "Queries"} + + {:else if selectedPanel === "Headers"} + + {:else if selectedPanel === "Authentication"} + + {:else if selectedPanel === "Variables"} + + {:else if selectedPanel === "Settings"} + + {:else} + Something went wrong + {/if} + + +{/if}