Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 25 additions & 18 deletions site/src/pages/HealthPage/HealthLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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<typeof sections>;

return (
<>
Expand Down Expand Up @@ -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"}
Expand Down Expand Up @@ -145,12 +151,13 @@ export function HealthLayout() {
</div>

<nav css={{ display: "flex", flexDirection: "column", gap: 1 }}>
{Object.keys(sections)
{Object.keys(visibleSections)
.sort()
.map((key) => {
const label = sections[key as keyof typeof sections];
const label =
visibleSections[key as keyof typeof visibleSections];
const healthSection =
healthStatus[key as keyof typeof sections];
healthStatus[key as keyof typeof visibleSections];

return (
<NavLink
Expand Down