diff --git a/packages/builder/src/components/backend/DatasourceNavigator/DatasourceNavigator.svelte b/packages/builder/src/components/backend/DatasourceNavigator/DatasourceNavigator.svelte index 42ea30dbb0..84c737eb67 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/DatasourceNavigator.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/DatasourceNavigator.svelte @@ -9,7 +9,10 @@ import TableNavigator from "components/backend/TableNavigator/TableNavigator.svelte" import ICONS from "./icons" + let openDataSources = [] + function selectDatasource(datasource) { + toggleNode(datasource) datasources.select(datasource._id) $goto(`./datasource/${datasource._id}`) } @@ -19,6 +22,15 @@ $goto(`./datasource/${query.datasourceId}/${query._id}`) } + function toggleNode(datasource) { + const isOpen = openDataSources.includes(datasource._id) + if (isOpen) { + openDataSources = openDataSources.filter(id => datasource._id !== id) + } else { + openDataSources = [...openDataSources, datasource._id] + } + } + onMount(() => { datasources.fetch() queries.fetch() @@ -31,8 +43,11 @@ 0} text={datasource.name} + opened={openDataSources.includes(datasource._id)} selected={$datasources.selected === datasource._id} + withArrow={true} on:click={() => selectDatasource(datasource)} + on:iconClick={() => toggleNode(datasource)} >
- + {#if openDataSources.includes(datasource._id)} + + {/if} {#each $queries.list.filter(query => query.datasourceId === datasource._id) as query} onClickQuery(query)} > diff --git a/packages/builder/src/components/common/NavItem.svelte b/packages/builder/src/components/common/NavItem.svelte index 977369299d..ec7994be84 100644 --- a/packages/builder/src/components/common/NavItem.svelte +++ b/packages/builder/src/components/common/NavItem.svelte @@ -1,5 +1,6 @@
{#if withArrow} -
+
{/if}