breadcurmbs
This commit is contained in:
1 parent
806d7ae456
commit
2a3683c74a
3 files changed
+21
-8
No files matched your search
@@ -8,15 +8,28 @@ const isId = (segment: string): boolean => {
|
|||||||
return segment.length === 24 || /^[a-f0-9-]{36}$/.test(segment);
|
return segment.length === 24 || /^[a-f0-9-]{36}$/.test(segment);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const actionSegments = ["create", "configure"];
|
||||||
|
|
||||||
export const Breadcrumb = () => {
|
export const Breadcrumb = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
|
||||||
const segments = location.pathname.split("/").filter((x) => x);
|
const segments = location.pathname.split("/").filter((x) => x);
|
||||||
|
|
||||||
// Build simplified breadcrumb: "uptime" or "uptime / details"
|
// Build simplified breadcrumb: "uptime" or "uptime / details" or "uptime / create"
|
||||||
const basePage = segments[0] || "home";
|
const basePage = segments[0] || "home";
|
||||||
const hasDetailsPage = segments.length > 1 && isId(segments[1]);
|
|
||||||
|
const secondSegment = segments[1];
|
||||||
|
const isActionPage = secondSegment && actionSegments.includes(secondSegment); // create/config
|
||||||
|
const isDetailsPage = secondSegment && isId(secondSegment); // details
|
||||||
|
const hasSubPage = isActionPage || isDetailsPage;
|
||||||
|
|
||||||
|
const getSubPageLabel = (): string => {
|
||||||
|
if (isActionPage) {
|
||||||
|
return secondSegment.charAt(0).toUpperCase() + secondSegment.slice(1);
|
||||||
|
}
|
||||||
|
return "Details";
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MuiBreadcrumbs
|
<MuiBreadcrumbs
|
||||||
@@ -34,7 +47,7 @@ export const Breadcrumb = () => {
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{hasDetailsPage ? (
|
{hasSubPage ? (
|
||||||
<Link
|
<Link
|
||||||
to={`/${basePage}`}
|
to={`/${basePage}`}
|
||||||
style={{ textDecoration: "none" }}
|
style={{ textDecoration: "none" }}
|
||||||
@@ -62,7 +75,7 @@ export const Breadcrumb = () => {
|
|||||||
{basePage.charAt(0).toUpperCase() + basePage.slice(1)}
|
{basePage.charAt(0).toUpperCase() + basePage.slice(1)}
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
{hasDetailsPage && (
|
{hasSubPage && (
|
||||||
<Typography
|
<Typography
|
||||||
sx={{
|
sx={{
|
||||||
fontSize: "14px",
|
fontSize: "14px",
|
||||||
@@ -70,7 +83,7 @@ export const Breadcrumb = () => {
|
|||||||
color: theme.palette.primary.main,
|
color: theme.palette.primary.main,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Details
|
{getSubPageLabel()}
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
</MuiBreadcrumbs>
|
</MuiBreadcrumbs>
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export const NotificationsTable = ({
|
|||||||
id: 1,
|
id: 1,
|
||||||
label: t("pages.common.monitors.actions.configure"),
|
label: t("pages.common.monitors.actions.configure"),
|
||||||
action: () => {
|
action: () => {
|
||||||
navigate(`/notifications/${channel.id}`);
|
navigate(`/notifications/configure/${channel.id}`);
|
||||||
},
|
},
|
||||||
closeMenu: true,
|
closeMenu: true,
|
||||||
},
|
},
|
||||||
@@ -89,7 +89,7 @@ export const NotificationsTable = ({
|
|||||||
headers={headers}
|
headers={headers}
|
||||||
data={notifications}
|
data={notifications}
|
||||||
onRowClick={(row) => {
|
onRowClick={(row) => {
|
||||||
navigate(`/notifications/${row.id}`);
|
navigate(`/notifications/configure/${row.id}`);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ const Routes = () => {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<Route
|
<Route
|
||||||
path="notifications/:notificationId"
|
path="notifications/configure/:notificationId"
|
||||||
element={
|
element={
|
||||||
<>
|
<>
|
||||||
<ThemeProvider theme={v2theme}>
|
<ThemeProvider theme={v2theme}>
|
||||||
|
|||||||
Reference in new issue
Block a user