diff --git a/packages/builder/src/components/backend/DatasourceNavigator/DatasourceNavigator.svelte b/packages/builder/src/components/backend/DatasourceNavigator/DatasourceNavigator.svelte
index 19713595ce..6ba8e4042f 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}
{#each $queries.list.filter(query => query.datasourceId === datasource._id) as query}
+ import { datasources } from "stores/backend"
+
+ datasources.select("bb_internal")
+
+
+
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 => {
diff --git a/packages/server/src/api/controllers/application.js b/packages/server/src/api/controllers/application.js
index da0014c5f8..76675116c2 100644
--- a/packages/server/src/api/controllers/application.js
+++ b/packages/server/src/api/controllers/application.js
@@ -230,7 +230,12 @@ exports.create = async function (ctx) {
const response = await db.put(newApplication, { force: true })
newApplication._rev = response.rev
- await createEmptyAppPackage(ctx, newApplication)
+ // Only create the default home screens and layout if we aren't importing
+ // an app
+ if (useTemplate !== "true") {
+ await createEmptyAppPackage(ctx, newApplication)
+ }
+
/* istanbul ignore next */
if (!env.isTest()) {
await createApp(appId)