From 342a57b387cefd672803ad6a631092ad5a3a054a Mon Sep 17 00:00:00 2001 From: BrunoQuaresma Date: Fri, 8 Dec 2023 13:31:47 +0000 Subject: [PATCH 1/2] fix(site): do not show ws proxy on menu if it is not enabled --- site/src/pages/HealthPage/HealthLayout.tsx | 43 +++++++++++++--------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/site/src/pages/HealthPage/HealthLayout.tsx b/site/src/pages/HealthPage/HealthLayout.tsx index 7944ac122c983..5fc94df521164 100644 --- a/site/src/pages/HealthPage/HealthLayout.tsx +++ b/site/src/pages/HealthPage/HealthLayout.tsx @@ -17,17 +17,11 @@ import { Suspense } from "react"; import { HealthIcon } from "./Content"; import { HealthSeverity } from "api/typesGenerated"; import NotificationsOffOutlined from "@mui/icons-material/NotificationsOffOutlined"; - -const sections = { - derp: "DERP", - access_url: "Access URL", - websocket: "Websocket", - database: "Database", - workspace_proxy: "Workspace Proxy", -} as const; +import { useDashboard } from "components/Dashboard/DashboardProvider"; export function HealthLayout() { const theme = useTheme(); + const dashboard = useDashboard(); const queryClient = useQueryClient(); const { data: healthStatus } = useQuery({ ...health(), @@ -36,6 +30,18 @@ export function HealthLayout() { const { mutate: forceRefresh, isLoading: isRefreshing } = useMutation( refreshHealth(queryClient), ); + const sections = { + derp: "DERP", + access_url: "Access URL", + websocket: "Websocket", + database: "Database", + workspace_proxy: dashboard.experiments.includes("moons") + ? "Workspace Proxy" + : undefined, + } as const; + const visibleSections = Object.keys(sections).filter( + (key) => sections[key as keyof typeof sections], + ) as Partial; return ( <> @@ -106,13 +112,13 @@ export function HealthLayout() { }} > {healthStatus.healthy - ? Object.keys(sections).some( - (key) => - healthStatus[key as keyof typeof sections] - .warnings !== null && - healthStatus[key as keyof typeof sections].warnings - .length > 0, - ) + ? Object.keys(visibleSections).some((key) => { + const section = + healthStatus[key as keyof typeof visibleSections]; + return ( + section.warnings && section.warnings.length > 0 + ); + }) ? "All systems operational, but performance might be degraded" : "All systems operational" : "Some issues have been detected"} @@ -145,12 +151,13 @@ export function HealthLayout() {