From cfe1a6d84d70188ed7bfea2010e18a944d837d4a Mon Sep 17 00:00:00 2001 From: popcorny Date: Tue, 5 Sep 2023 10:28:53 +0800 Subject: [PATCH] Fold all resources in the sidebar Signed-off-by: popcorny --- .../src/components/SideBar/SideBar.tsx | 7 +++++-- static_report/src/utils/dbt.ts | 18 +++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/static_report/src/components/SideBar/SideBar.tsx b/static_report/src/components/SideBar/SideBar.tsx index 0335544ce..5994ebfd1 100644 --- a/static_report/src/components/SideBar/SideBar.tsx +++ b/static_report/src/components/SideBar/SideBar.tsx @@ -42,9 +42,12 @@ export function SideBar({ singleOnly }: Comparable) { // make sure the tree is expanded for the current path useEffect(() => { - if (location !== '/ssr' && tabIndex < 0) { + if (location !== '/ssr') { expandTreeForPath(location); - setTabIndex(0); + + if (tabIndex < 0) { + setTabIndex(0); + } } }, [location, tabIndex, expandTreeForPath]); diff --git a/static_report/src/utils/dbt.ts b/static_report/src/utils/dbt.ts index 3bd0c7fe1..f8c88d537 100644 --- a/static_report/src/utils/dbt.ts +++ b/static_report/src/utils/dbt.ts @@ -286,7 +286,7 @@ export function buildSourceTree( type: 'folder', name: sourceName, items: [], - expanded: true, + expanded: false, }; } @@ -361,7 +361,7 @@ export function buildModelOrSeedTree( type: 'folder', name: dir, items: {}, - expanded: true, + expanded: false, }; } curDir = curDir[dir].items; @@ -424,7 +424,7 @@ export function buildMetricTree( type: 'folder', name: packageName, items: [], - expanded: true, + expanded: false, }; } @@ -497,26 +497,26 @@ export function buildProjectTree( name: 'Sources', type: 'folder', items: buildSourceTree(itemsNodeComparison), - expanded: true, + expanded: false, }; const seed: SidebarTreeItem = { name: 'Seeds', type: 'folder', items: buildModelOrSeedTree(itemsNodeComparison, 'seed'), - expanded: true, + expanded: false, }; const model: SidebarTreeItem = { name: 'Models', type: 'folder', items: buildModelOrSeedTree(itemsNodeComparison, 'model'), - expanded: true, + expanded: false, }; const table: SidebarTreeItem = { name: 'Tables', type: 'folder', path: `/tables`, items: buildLegacyTablesTree(itemsNodeComparison), - expanded: true, + expanded: false, }; const metric: SidebarTreeItem = { name: 'Metrics', @@ -590,7 +590,7 @@ export function buildDatabaseTree( type: 'database', name: db, items: [], - expanded: true, + expanded: false, }; items.push(itemDatabase); @@ -600,7 +600,7 @@ export function buildDatabaseTree( type: 'schema', name: schema, items: [], - expanded: true, + expanded: false, }; itemDatabase.items!.push(itemSchema);