From cc933d4467ef7765fcd9bb4fc0267be1a6d8ee8a Mon Sep 17 00:00:00 2001 From: Ethan Ho Date: Tue, 1 Oct 2024 18:06:11 -0700 Subject: [PATCH 1/3] project sidebar takes in model access parameter and always shows overview --- .../components/FancyPage/useProjectSidebar.ts | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/weave-js/src/components/FancyPage/useProjectSidebar.ts b/weave-js/src/components/FancyPage/useProjectSidebar.ts index cdd5aa1e246c..0a452298c615 100644 --- a/weave-js/src/components/FancyPage/useProjectSidebar.ts +++ b/weave-js/src/components/FancyPage/useProjectSidebar.ts @@ -9,15 +9,24 @@ export const useProjectSidebar = ( viewingRestricted: boolean, hasModelsData: boolean, hasWeaveData: boolean, - hasTraceBackend: boolean = true + hasTraceBackend: boolean = true, + hasModelsAccess: boolean = true ): FancyPageSidebarItem[] => { // Should show models sidebar items if we have models data or if we don't have a trace backend - const showModelsSidebarItems = hasModelsData || !hasTraceBackend; + var showModelsSidebarItems = hasModelsData || !hasTraceBackend; // Should show weave sidebar items if we have weave data and we have a trace backend - const showWeaveSidebarItems = hasWeaveData && hasTraceBackend; + var showWeaveSidebarItems = hasWeaveData && hasTraceBackend; - const isModelsOnly = showModelsSidebarItems && !showWeaveSidebarItems; - const isWeaveOnly = !showModelsSidebarItems && showWeaveSidebarItems; + var isModelsOnly = showModelsSidebarItems && !showWeaveSidebarItems; + var isWeaveOnly = !showModelsSidebarItems && showWeaveSidebarItems; + + if (!hasModelsAccess) { + showModelsSidebarItems = false; + isModelsOnly = false; + + showWeaveSidebarItems = true; + isWeaveOnly = true; + } const isNoSidebarItems = !showModelsSidebarItems && !showWeaveSidebarItems; const isBothSidebarItems = showModelsSidebarItems && showWeaveSidebarItems; @@ -35,7 +44,7 @@ export const useProjectSidebar = ( type: 'button' as const, name: 'Overview', slug: 'overview', - isShown: !isWeaveOnly, + isShown: true, isDisabled: false, iconName: IconNames.Info, }, From eac8cf802ab1cdbbe51d3aa3e7b7f7e99f5adc0d Mon Sep 17 00:00:00 2001 From: Ethan Ho Date: Tue, 1 Oct 2024 18:12:36 -0700 Subject: [PATCH 2/3] use let --- weave-js/src/components/FancyPage/useProjectSidebar.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/weave-js/src/components/FancyPage/useProjectSidebar.ts b/weave-js/src/components/FancyPage/useProjectSidebar.ts index 0a452298c615..fa49f50619e2 100644 --- a/weave-js/src/components/FancyPage/useProjectSidebar.ts +++ b/weave-js/src/components/FancyPage/useProjectSidebar.ts @@ -13,12 +13,12 @@ export const useProjectSidebar = ( hasModelsAccess: boolean = true ): FancyPageSidebarItem[] => { // Should show models sidebar items if we have models data or if we don't have a trace backend - var showModelsSidebarItems = hasModelsData || !hasTraceBackend; + let showModelsSidebarItems = hasModelsData || !hasTraceBackend; // Should show weave sidebar items if we have weave data and we have a trace backend - var showWeaveSidebarItems = hasWeaveData && hasTraceBackend; + let showWeaveSidebarItems = hasWeaveData && hasTraceBackend; - var isModelsOnly = showModelsSidebarItems && !showWeaveSidebarItems; - var isWeaveOnly = !showModelsSidebarItems && showWeaveSidebarItems; + let isModelsOnly = showModelsSidebarItems && !showWeaveSidebarItems; + let isWeaveOnly = !showModelsSidebarItems && showWeaveSidebarItems; if (!hasModelsAccess) { showModelsSidebarItems = false; From 91d00f801fd2ffe827a4e3d4a4b66d2ea5310dce Mon Sep 17 00:00:00 2001 From: Ethan Ho Date: Wed, 2 Oct 2024 10:52:46 -0700 Subject: [PATCH 3/3] don't always show overview tab --- weave-js/src/components/FancyPage/useProjectSidebar.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weave-js/src/components/FancyPage/useProjectSidebar.ts b/weave-js/src/components/FancyPage/useProjectSidebar.ts index fa49f50619e2..6fcc50703f95 100644 --- a/weave-js/src/components/FancyPage/useProjectSidebar.ts +++ b/weave-js/src/components/FancyPage/useProjectSidebar.ts @@ -44,7 +44,7 @@ export const useProjectSidebar = ( type: 'button' as const, name: 'Overview', slug: 'overview', - isShown: true, + isShown: !isWeaveOnly, isDisabled: false, iconName: IconNames.Info, },