@@ -12,22 +12,16 @@ import Tooltip from "@mui/material/Tooltip";
1212import CircularProgress from "@mui/material/CircularProgress" ;
1313import { NavLink , Outlet } from "react-router-dom" ;
1414import { css } from "@emotion/css" ;
15- import { kebabCase } from "lodash/fp" ;
15+ import kebabCase from "lodash/fp/kebabCase " ;
1616import { Suspense } from "react" ;
1717import { HealthIcon } from "./Content" ;
1818import { HealthSeverity } from "api/typesGenerated" ;
1919import NotificationsOffOutlined from "@mui/icons-material/NotificationsOffOutlined" ;
20-
21- const sections = {
22- derp :"DERP" ,
23- access_url :"Access URL" ,
24- websocket :"Websocket" ,
25- database :"Database" ,
26- workspace_proxy :"Workspace Proxy" ,
27- } as const ;
20+ import { useDashboard } from "components/Dashboard/DashboardProvider" ;
2821
2922export function HealthLayout ( ) {
3023const theme = useTheme ( ) ;
24+ const dashboard = useDashboard ( ) ;
3125const queryClient = useQueryClient ( ) ;
3226const { data :healthStatus } = useQuery ( {
3327 ...health ( ) ,
@@ -36,6 +30,16 @@ export function HealthLayout() {
3630const { mutate :forceRefresh , isLoading :isRefreshing } = useMutation (
3731refreshHealth ( queryClient ) ,
3832) ;
33+ const sections = {
34+ derp :"DERP" ,
35+ access_url :"Access URL" ,
36+ websocket :"Websocket" ,
37+ database :"Database" ,
38+ workspace_proxy :dashboard . experiments . includes ( "moons" )
39+ ?"Workspace Proxy"
40+ :undefined ,
41+ } as const ;
42+ const visibleSections = filterVisibleSections ( sections ) ;
3943
4044return (
4145< >
@@ -106,13 +110,13 @@ export function HealthLayout() {
106110} }
107111>
108112{ healthStatus . healthy
109- ?Object . keys ( sections ) . some (
110- ( key ) =>
111- healthStatus [ key as keyof typeof sections ]
112- . warnings !== null &&
113- healthStatus [ key as keyof typeof sections ] . warnings
114- . length > 0 ,
115- )
113+ ?Object . keys ( visibleSections ) . some ( ( key ) => {
114+ const section =
115+ healthStatus [ key as keyof typeof visibleSections ] ;
116+ return (
117+ section . warnings && section . warnings . length > 0
118+ ) ;
119+ } )
116120 ?"All systems operational, but performance might be degraded"
117121 :"All systems operational"
118122 :"Some issues have been detected" }
@@ -145,12 +149,13 @@ export function HealthLayout() {
145149</ div >
146150
147151< nav css = { { display :"flex" , flexDirection :"column" , gap :1 } } >
148- { Object . keys ( sections )
152+ { Object . keys ( visibleSections )
149153. sort ( )
150154. map ( ( key ) => {
151- const label = sections [ key as keyof typeof sections ] ;
155+ const label =
156+ visibleSections [ key as keyof typeof visibleSections ] ;
152157const healthSection =
153- healthStatus [ key as keyof typeof sections ] ;
158+ healthStatus [ key as keyof typeof visibleSections ] ;
154159
155160return (
156161< NavLink
@@ -218,3 +223,21 @@ export function HealthLayout() {
218223</ >
219224) ;
220225}
226+
227+ const filterVisibleSections = < T extends object > ( sections :T ) => {
228+ return Object . keys ( sections ) . reduce (
229+ ( visible , sectionName ) => {
230+ const sectionValue = sections [ sectionName as keyof typeof sections ] ;
231+
232+ if ( ! sectionValue ) {
233+ return visible ;
234+ }
235+
236+ return {
237+ ...visible ,
238+ [ sectionName ] :sectionValue ,
239+ } ;
240+ } ,
241+ { } as Partial < typeof sections > ,
242+ ) ;
243+ } ;