Improve grid handling of invalid datasources and fix potential error when encoutering invalid datasources

This commit is contained in:
Andrew Kingston 2023-10-04 09:36:42 +01:00
parent c4a516ccb3
commit 77f87af87f
2 changed files with 10 additions and 8 deletions

View File

@ -141,7 +141,14 @@
</div>
</div>
{/if}
{#if $loaded}
{#if $error}
<div class="grid-error">
<div class="grid-error-title">There was a problem loading your grid</div>
<div class="grid-error-subtitle">
{$error}
</div>
</div>
{:else if $loaded}
<div class="grid-data-outer" use:clickOutside={ui.actions.blur}>
<div class="grid-data-inner">
<StickyColumn>
@ -171,13 +178,6 @@
</div>
</div>
</div>
{:else if $error}
<div class="grid-error">
<div class="grid-error-title">There was a problem loading your grid</div>
<div class="grid-error-subtitle">
{$error}
</div>
</div>
{/if}
{#if $loading && !$error}
<div in:fade|local={{ duration: 130 }} class="grid-loading">

View File

@ -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
}