From 977f81c412f50b80740f7e4c414dbd87fd2ee5c4 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 10 Nov 2023 10:49:55 +0100 Subject: [PATCH] Add comments --- .../DatasourceNavigator.svelte | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/builder/src/components/backend/DatasourceNavigator/DatasourceNavigator.svelte b/packages/builder/src/components/backend/DatasourceNavigator/DatasourceNavigator.svelte index 660710f0f1..542a9ca74f 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/DatasourceNavigator.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/DatasourceNavigator.svelte @@ -23,7 +23,7 @@ import { userSelectedResourceMap } from "builderStore" export let searchTerm - let dataSourcesVisibility = {} + let toggledDatasources = {} $: enrichedDataSources = enrichDatasources( $datasources, @@ -33,23 +33,25 @@ $queries, $views, $viewsV2, - dataSourcesVisibility, + toggledDatasources, searchTerm ) const showDatasourceOpen = ({ selected, containsSelected, - dataSourceVisibility, + dsToggledStatus, searchTerm, onlyOneSource, }) => { + // We want to display all the ds expanded while filtering ds if (searchTerm) { return true } - if (dataSourceVisibility !== undefined) { - return dataSourceVisibility + // If the toggle status has been a value + if (dsToggledStatus !== undefined) { + return dsToggledStatus } if (onlyOneSource) { @@ -67,7 +69,7 @@ queries, views, viewsV2, - dataSourcesVisibility, + toggledDatasources, searchTerm ) => { if (!datasources?.list?.length) { @@ -105,7 +107,7 @@ const open = showDatasourceOpen({ selected, containsSelected, - dataSourceVisibility: dataSourcesVisibility[datasource._id], + dsToggledStatus: toggledDatasources[datasource._id], searchTerm, onlyOneSource: onlySource, }) @@ -133,11 +135,11 @@ } function openNode(datasource) { - dataSourcesVisibility[datasource._id] = true + toggledDatasources[datasource._id] = true } function toggleNode(datasource) { - dataSourcesVisibility[datasource._id] = !datasource.open + toggledDatasources[datasource._id] = !datasource.open } const containsActiveEntity = (