From 77f87af87f3f169b0b90b9fa39b4c102991bb956 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 4 Oct 2023 09:36:42 +0100 Subject: [PATCH] Improve grid handling of invalid datasources and fix potential error when encoutering invalid datasources --- .../src/components/grid/layout/Grid.svelte | 16 ++++++++-------- .../src/components/grid/stores/rows.js | 2 ++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/frontend-core/src/components/grid/layout/Grid.svelte b/packages/frontend-core/src/components/grid/layout/Grid.svelte index 44e0a972f1..e2ecd0f968 100644 --- a/packages/frontend-core/src/components/grid/layout/Grid.svelte +++ b/packages/frontend-core/src/components/grid/layout/Grid.svelte @@ -141,7 +141,14 @@ {/if} - {#if $loaded} + {#if $error} +
+
There was a problem loading your grid
+
+ {$error} +
+
+ {:else if $loaded}
@@ -171,13 +178,6 @@
- {:else if $error} -
-
There was a problem loading your grid
-
- {$error} -
-
{/if} {#if $loading && !$error}
diff --git a/packages/frontend-core/src/components/grid/stores/rows.js b/packages/frontend-core/src/components/grid/stores/rows.js index 1eafb20756..e6251a5afa 100644 --- a/packages/frontend-core/src/components/grid/stores/rows.js +++ b/packages/frontend-core/src/components/grid/stores/rows.js @@ -94,12 +94,14 @@ export const createActions = context => { datasource.subscribe(async $datasource => { // Unsub from previous fetch if one exists unsubscribe?.() + unsubscribe = null fetch.set(null) instanceLoaded.set(false) loading.set(true) // Abandon if we don't have a valid datasource if (!datasource.actions.isDatasourceValid($datasource)) { + error.set("Datasource is invalid") return }