From 794018a6abbf95d3028ce1c7331eb184217b6ab6 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Sat, 24 Jan 2026 20:41:21 +0000 Subject: [PATCH] simplify breadcrumbs --- .../v2/design-elements/Breadcrumb.tsx | 125 ++++++------------ 1 file changed, 43 insertions(+), 82 deletions(-) diff --git a/client/src/Components/v2/design-elements/Breadcrumb.tsx b/client/src/Components/v2/design-elements/Breadcrumb.tsx index 4489f992d..492ed0ec9 100644 --- a/client/src/Components/v2/design-elements/Breadcrumb.tsx +++ b/client/src/Components/v2/design-elements/Breadcrumb.tsx @@ -2,25 +2,21 @@ import MuiBreadcrumbs from "@mui/material/Breadcrumbs"; import Typography from "@mui/material/Typography"; import { Link, useLocation } from "react-router-dom"; import { useTheme } from "@mui/material/styles"; -import { ChevronRight, Home } from "lucide-react"; -import { useTranslation } from "react-i18next"; +import { ChevronRight } from "lucide-react"; -export const Breadcrumb = ({ breadcrumbOverride }: { breadcrumbOverride?: string[] }) => { - const { t } = useTranslation(); +const isId = (segment: string): boolean => { + return segment.length === 24 || /^[a-f0-9-]{36}$/.test(segment); +}; + +export const Breadcrumb = () => { const theme = useTheme(); const location = useLocation(); - // Don't show breadcrumb on dashboard - if (location.pathname === "/" || location.pathname === "/uptime") { - return null; - } + const segments = location.pathname.split("/").filter((x) => x); - const pathnames = breadcrumbOverride || location.pathname.split("/").filter((x) => x); - - // Don't show if only one level (e.g., /uptime) - if (pathnames.length === 0) { - return null; - } + // Build simplified breadcrumb: "uptime" or "uptime / details" + const basePage = segments[0] || "home"; + const hasDetailsPage = segments.length > 1 && isId(segments[1]); return ( - - + {hasDetailsPage ? ( + + + {basePage.charAt(0).toUpperCase() + basePage.slice(1)} + + + ) : ( - Home + {basePage.charAt(0).toUpperCase() + basePage.slice(1)} - - {pathnames.map((value, index) => { - const last = index === pathnames.length - 1; - const to = `/${pathnames.slice(0, index + 1).join("/")}`; - - let displayName = ""; - - // Paths that are IDs should be detail pages - if (value.length === 24 || value.match(/^[a-f0-9-]{36}$/)) { - displayName = "Details"; - } else { - displayName = - t(`common.breadcrumbs.${value}`) || - value.charAt(0).toUpperCase() + value.slice(1); - } - - return last ? ( - - {displayName} - - ) : ( - - - {displayName} - - - ); - })} + )} + {hasDetailsPage && ( + + Details + + )} ); };