diff --git a/packages/builder/src/components/backend/DatasourceNavigator/DatasourceNavigator.svelte b/packages/builder/src/components/backend/DatasourceNavigator/DatasourceNavigator.svelte
index 84c737eb67..193e778300 100644
--- a/packages/builder/src/components/backend/DatasourceNavigator/DatasourceNavigator.svelte
+++ b/packages/builder/src/components/backend/DatasourceNavigator/DatasourceNavigator.svelte
@@ -1,8 +1,9 @@
{#if $database?._id}
- {#each $datasources.list as datasource, idx}
+ {#each enrichedDataSources as datasource, idx}
0}
text={datasource.name}
- opened={openDataSources.includes(datasource._id)}
- selected={$datasources.selected === datasource._id}
+ opened={datasource.open}
+ selected={datasource.selected}
withArrow={true}
on:click={() => selectDatasource(datasource)}
on:iconClick={() => toggleNode(datasource)}
@@ -61,7 +81,7 @@
{/if}
- {#if openDataSources.includes(datasource._id)}
+ {#if datasource.open}
{/if}
diff --git a/packages/builder/src/pages/builder/app/[application]/data/datasource/bb_internal/_layout.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/bb_internal/_layout.svelte
index e69de29bb2..ed271aae34 100644
--- a/packages/builder/src/pages/builder/app/[application]/data/datasource/bb_internal/_layout.svelte
+++ b/packages/builder/src/pages/builder/app/[application]/data/datasource/bb_internal/_layout.svelte
@@ -0,0 +1,7 @@
+
+
+
diff --git a/packages/builder/src/stores/backend/datasources.js b/packages/builder/src/stores/backend/datasources.js
index 5c6ed3f2cb..5e42315948 100644
--- a/packages/builder/src/stores/backend/datasources.js
+++ b/packages/builder/src/stores/backend/datasources.js
@@ -1,4 +1,4 @@
-import { writable } from "svelte/store"
+import { writable, get } from "svelte/store"
import { queries, tables, views } from "./"
import api from "../../builderStore/api"
@@ -8,7 +8,8 @@ export const INITIAL_DATASOURCE_VALUES = {
}
export function createDatasourcesStore() {
- const { subscribe, update, set } = writable(INITIAL_DATASOURCE_VALUES)
+ const store = writable(INITIAL_DATASOURCE_VALUES)
+ const { subscribe, update, set } = store
return {
subscribe,
@@ -21,7 +22,15 @@ export function createDatasourcesStore() {
fetch: async () => {
const response = await api.get(`/api/datasources`)
const json = await response.json()
- update(state => ({ ...state, list: json, selected: null }))
+
+ // Clear selected if it no longer exists, otherwise keep it
+ const selected = get(store).selected
+ let nextSelected = null
+ if (selected && json.find(source => source._id === selected)) {
+ nextSelected = selected
+ }
+
+ update(state => ({ ...state, list: json, selected: nextSelected }))
return json
},
select: async datasourceId => {