From 612dd2994dcd408a0dd452cd3bc38445f8752eda Mon Sep 17 00:00:00 2001 From: Brett Kolodny Date: Fri, 14 Feb 2025 15:27:45 +0000 Subject: [PATCH 1/3] fix: show error notification when health endpoint returns an error --- site/src/pages/HealthPage/HealthLayout.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/site/src/pages/HealthPage/HealthLayout.tsx b/site/src/pages/HealthPage/HealthLayout.tsx index 2c566500d892b..4d6fd74bb8c5c 100644 --- a/site/src/pages/HealthPage/HealthLayout.tsx +++ b/site/src/pages/HealthPage/HealthLayout.tsx @@ -18,11 +18,16 @@ import { NavLink, Outlet } from "react-router-dom"; import { createDayString } from "utils/createDayString"; import { pageTitle } from "utils/page"; import { HealthIcon } from "./Content"; +import { ErrorAlert } from "components/Alert/ErrorAlert"; export const HealthLayout: FC = () => { const theme = useTheme(); const queryClient = useQueryClient(); - const { data: healthStatus } = useQuery({ + const { + data: healthStatus, + isLoading, + error, + } = useQuery({ ...health(), refetchInterval: 30_000, }); @@ -194,6 +199,10 @@ export const HealthLayout: FC = () => { + ) : !isLoading && error ? ( +
+ +
) : ( )} From e81688c8da935671c418fa67e5f64ac668988599 Mon Sep 17 00:00:00 2001 From: Brett Kolodny Date: Fri, 14 Feb 2025 15:28:11 +0000 Subject: [PATCH 2/3] chore: fmt --- site/src/pages/HealthPage/HealthLayout.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/src/pages/HealthPage/HealthLayout.tsx b/site/src/pages/HealthPage/HealthLayout.tsx index 4d6fd74bb8c5c..97f6adfdd246e 100644 --- a/site/src/pages/HealthPage/HealthLayout.tsx +++ b/site/src/pages/HealthPage/HealthLayout.tsx @@ -7,6 +7,7 @@ import IconButton from "@mui/material/IconButton"; import Tooltip from "@mui/material/Tooltip"; import { health, refreshHealth } from "api/queries/debug"; import type { HealthSeverity } from "api/typesGenerated"; +import { ErrorAlert } from "components/Alert/ErrorAlert"; import { Loader } from "components/Loader/Loader"; import { type ClassName, useClassName } from "hooks/useClassName"; import kebabCase from "lodash/fp/kebabCase"; @@ -18,7 +19,6 @@ import { NavLink, Outlet } from "react-router-dom"; import { createDayString } from "utils/createDayString"; import { pageTitle } from "utils/page"; import { HealthIcon } from "./Content"; -import { ErrorAlert } from "components/Alert/ErrorAlert"; export const HealthLayout: FC = () => { const theme = useTheme(); From b0d77cf917ae6084bb5ab24b09fc0b1b25fd0912 Mon Sep 17 00:00:00 2001 From: Brett Kolodny Date: Tue, 18 Feb 2025 18:59:28 +0000 Subject: [PATCH 3/3] fix: remove ternary --- site/src/pages/HealthPage/HealthLayout.tsx | 274 +++++++++++---------- 1 file changed, 140 insertions(+), 134 deletions(-) diff --git a/site/src/pages/HealthPage/HealthLayout.tsx b/site/src/pages/HealthPage/HealthLayout.tsx index 97f6adfdd246e..33ca8cbe31a17 100644 --- a/site/src/pages/HealthPage/HealthLayout.tsx +++ b/site/src/pages/HealthPage/HealthLayout.tsx @@ -47,165 +47,171 @@ export const HealthLayout: FC = () => { const link = useClassName(classNames.link, []); const activeLink = useClassName(classNames.activeLink, []); + if (isLoading || !healthStatus) { + return ( +
+ +
+ ); + } + + if (error) { + return ( +
+ +
+ ); + } + return ( <> {pageTitle("Health")} - {healthStatus ? ( - + +
-
-
-
- +
+
+ - - { - forceRefresh(); - }} - > - {isRefreshing ? ( - - ) : ( - - )} - - -
-
- {healthStatus.healthy ? "Healthy" : "Unhealthy"} -
-
- {healthStatus.healthy - ? 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"} -
+ + { + forceRefresh(); + }} + > + {isRefreshing ? ( + + ) : ( + + )} + +
- -
- Last check - - {createDayString(healthStatus.time)} - +
+ {healthStatus.healthy ? "Healthy" : "Unhealthy"}
- -
- Version - - {healthStatus.coder_version} - +
+ {healthStatus.healthy + ? 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"}
-
+ + -
+ )} + + ); + })} + +
-
- }> - - -
+
+ }> + +
- - ) : !isLoading && error ? ( -
-
- ) : ( - - )} + ); }; pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy