extract duplicate code, add slot components
This commit is contained in:
1 parent
212c1fec52
commit
4c04294f71
15 files changed
+397
-710
No files matched your search
@@ -8,35 +8,56 @@ import { useTranslation } from "react-i18next";
|
|||||||
import { useIsAdmin } from "@/Hooks/useIsAdmin";
|
import { useIsAdmin } from "@/Hooks/useIsAdmin";
|
||||||
import { useLocation, useParams } from "react-router-dom";
|
import { useLocation, useParams } from "react-router-dom";
|
||||||
import { useGet } from "@/Hooks/UseApi";
|
import { useGet } from "@/Hooks/UseApi";
|
||||||
import type { Monitor } from "@/Types/Monitor";
|
|
||||||
import { resolveStatusPageTheme } from "@/Types/StatusPage";
|
import { resolveStatusPageTheme } from "@/Types/StatusPage";
|
||||||
import {
|
import {
|
||||||
PUBLIC_STATUS_PAGE_PREFIX,
|
PUBLIC_STATUS_PAGE_PREFIX,
|
||||||
type StatusPage,
|
|
||||||
type StatusPageResponse,
|
type StatusPageResponse,
|
||||||
type StatusPageTheme,
|
type StatusPageTheme,
|
||||||
} from "@/Types/StatusPage";
|
} from "@/Types/StatusPage";
|
||||||
import { HeaderStatusPageControls } from "./Components/HeaderStatusPageControls";
|
import { HeaderStatusPageControls } from "@/Pages/StatusPage/Status/Components/HeaderStatusPageControls";
|
||||||
import { StatusPageThemeProvider } from "./themes/StatusPageThemeProvider";
|
import { StatusPageThemeProvider } from "@/Pages/StatusPage/Status/themes/StatusPageThemeProvider";
|
||||||
import { RefinedStatusPage } from "./themes/refined/RefinedStatusPage";
|
import {
|
||||||
import { ModernStatusPage } from "./themes/modern/ModernStatusPage";
|
BaseStatusPage,
|
||||||
import { BoldStatusPage } from "./themes/bold/BoldStatusPage";
|
type ThemeConfig,
|
||||||
import { EditorialStatusPage } from "./themes/editorial/EditorialStatusPage";
|
} from "@/Pages/StatusPage/Status/themes/shared/BaseStatusPage";
|
||||||
import { BrowserFrame } from "./themes/BrowserFrame";
|
import { BrowserFrame } from "@/Pages/StatusPage/Status/themes/BrowserFrame";
|
||||||
|
import { refinedStyles } from "@/Pages/StatusPage/Status/themes/refined/styles";
|
||||||
|
import { RefinedHeader } from "@/Pages/StatusPage/Status/themes/refined/RefinedHeader";
|
||||||
|
import { RefinedHero } from "@/Pages/StatusPage/Status/themes/refined/RefinedHero";
|
||||||
|
import { modernStyles } from "@/Pages/StatusPage/Status/themes/modern/styles";
|
||||||
|
import { ModernHeader } from "@/Pages/StatusPage/Status/themes/modern/ModernHeader";
|
||||||
|
import { ModernHero } from "@/Pages/StatusPage/Status/themes/modern/ModernHero";
|
||||||
|
import { boldStyles } from "@/Pages/StatusPage/Status/themes/bold/styles";
|
||||||
|
import { BoldHeader } from "@/Pages/StatusPage/Status/themes/bold/BoldHeader";
|
||||||
|
import { BoldHero } from "@/Pages/StatusPage/Status/themes/bold/BoldHero";
|
||||||
|
import { editorialStyles } from "@/Pages/StatusPage/Status/themes/editorial/styles";
|
||||||
|
import { EditorialHeader } from "@/Pages/StatusPage/Status/themes/editorial/EditorialHeader";
|
||||||
|
import { EditorialHero } from "@/Pages/StatusPage/Status/themes/editorial/EditorialHero";
|
||||||
|
|
||||||
type ThemedRendererProps = {
|
const THEME_CONFIGS: Record<StatusPageTheme, ThemeConfig<any>> = {
|
||||||
statusPage: StatusPage;
|
refined: {
|
||||||
monitors: (Monitor & { checks?: Monitor["recentChecks"] })[];
|
createStyles: refinedStyles,
|
||||||
};
|
HeaderSlot: RefinedHeader,
|
||||||
|
HeroSlot: RefinedHero,
|
||||||
const THEMED_RENDERERS: Record<
|
},
|
||||||
StatusPageTheme,
|
modern: {
|
||||||
React.ComponentType<ThemedRendererProps>
|
createStyles: modernStyles,
|
||||||
> = {
|
HeaderSlot: ModernHeader,
|
||||||
refined: RefinedStatusPage,
|
HeroSlot: ModernHero,
|
||||||
modern: ModernStatusPage,
|
overallStatusOptions: { iconSize: 20 },
|
||||||
bold: BoldStatusPage,
|
},
|
||||||
editorial: EditorialStatusPage,
|
bold: {
|
||||||
|
createStyles: boldStyles,
|
||||||
|
HeaderSlot: BoldHeader,
|
||||||
|
HeroSlot: BoldHero,
|
||||||
|
overallStatusOptions: { iconSize: 18 },
|
||||||
|
},
|
||||||
|
editorial: {
|
||||||
|
createStyles: editorialStyles,
|
||||||
|
HeaderSlot: EditorialHeader,
|
||||||
|
HeroSlot: EditorialHero,
|
||||||
|
overallStatusOptions: { allUpKey: "pages.statusPages.editorial.allUp" },
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const StatusPageView = () => {
|
const StatusPageView = () => {
|
||||||
@@ -90,11 +111,12 @@ const StatusPageView = () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const ThemedRenderer = THEMED_RENDERERS[resolveStatusPageTheme(statusPage.theme)];
|
const themeConfig = THEME_CONFIGS[resolveStatusPageTheme(statusPage.theme)];
|
||||||
const themedRenderer = (
|
const themedRenderer = (
|
||||||
<ThemedRenderer
|
<BaseStatusPage
|
||||||
statusPage={statusPage}
|
statusPage={statusPage}
|
||||||
monitors={monitors}
|
monitors={monitors}
|
||||||
|
config={themeConfig}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import Box from "@mui/material/Box";
|
||||||
|
import { monoFirstChar } from "@/Pages/StatusPage/Status/themes/shared/overallStatus";
|
||||||
|
import type { SlotProps } from "@/Pages/StatusPage/Status/themes/shared/BaseStatusPage";
|
||||||
|
import type { BoldStyles } from "@/Pages/StatusPage/Status/themes/bold/styles";
|
||||||
|
|
||||||
|
export const BoldHeader = ({ statusPage, logoSrc, styles }: SlotProps<BoldStyles>) => (
|
||||||
|
<Box sx={styles.brand}>
|
||||||
|
{logoSrc ? (
|
||||||
|
<Box
|
||||||
|
component="img"
|
||||||
|
src={logoSrc}
|
||||||
|
alt={statusPage.companyName}
|
||||||
|
sx={styles.logoImg}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<Box sx={styles.logoConic}>{monoFirstChar(statusPage.companyName)}</Box>
|
||||||
|
)}
|
||||||
|
{statusPage.companyName}
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import Box from "@mui/material/Box";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import type { SlotProps } from "@/Pages/StatusPage/Status/themes/shared/BaseStatusPage";
|
||||||
|
import type { BoldStyles } from "@/Pages/StatusPage/Status/themes/bold/styles";
|
||||||
|
|
||||||
|
export const BoldHero = ({ overall, monitorCount, styles }: SlotProps<BoldStyles>) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
return (
|
||||||
|
<Box sx={styles.hero}>
|
||||||
|
<Box
|
||||||
|
component="h1"
|
||||||
|
sx={styles.heroTitle}
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
component="span"
|
||||||
|
sx={styles.heroCheck(overall.tone)}
|
||||||
|
>
|
||||||
|
{overall.icon}
|
||||||
|
</Box>
|
||||||
|
{overall.message}
|
||||||
|
</Box>
|
||||||
|
<Box
|
||||||
|
component="p"
|
||||||
|
sx={styles.heroSub}
|
||||||
|
>
|
||||||
|
{t("pages.statusPages.statusBar.monitoringSummary", {
|
||||||
|
count: monitorCount,
|
||||||
|
})}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -1,207 +0,0 @@
|
|||||||
import { useMemo, useState } from "react";
|
|
||||||
import Box from "@mui/material/Box";
|
|
||||||
import Stack from "@mui/material/Stack";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import type { Monitor } from "@/Types/Monitor";
|
|
||||||
import type { StatusPage } from "@/Types/StatusPage";
|
|
||||||
import { getMonitorTypeLabel } from "@/Types/StatusPage";
|
|
||||||
import { ThemedHeatmap } from "../shared/ThemedHeatmap";
|
|
||||||
import { ThemedHistogram } from "../shared/ThemedHistogram";
|
|
||||||
import { ThemedInfrastructure } from "../shared/ThemedInfrastructure";
|
|
||||||
import {
|
|
||||||
monitorBadgeTone,
|
|
||||||
monoFirstChar,
|
|
||||||
resolveOverallStatus,
|
|
||||||
statusBadgeKey,
|
|
||||||
} from "../shared/overallStatus";
|
|
||||||
import { useStatusPageTheme } from "../StatusPageThemeProvider";
|
|
||||||
import { boldStyles } from "./styles";
|
|
||||||
|
|
||||||
type StatusPageMonitor = Monitor & { checks?: Monitor["recentChecks"] };
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
statusPage: StatusPage;
|
|
||||||
monitors: StatusPageMonitor[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export const BoldStatusPage = ({ statusPage, monitors }: Props) => {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
const { tokens, mode } = useStatusPageTheme();
|
|
||||||
const styles = useMemo(() => boldStyles(tokens, mode === "dark"), [tokens, mode]);
|
|
||||||
const [chartMode, setChartMode] = useState<"heatmap" | "histogram">("heatmap");
|
|
||||||
|
|
||||||
const overall = resolveOverallStatus(monitors, t, { iconSize: 18 });
|
|
||||||
const logoSrc = statusPage.logo?.data
|
|
||||||
? `data:${statusPage.logo.contentType};base64,${statusPage.logo.data}`
|
|
||||||
: null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Box sx={styles.page}>
|
|
||||||
<Box
|
|
||||||
component="header"
|
|
||||||
sx={styles.top}
|
|
||||||
>
|
|
||||||
<Box sx={styles.brand}>
|
|
||||||
{logoSrc ? (
|
|
||||||
<Box
|
|
||||||
component="img"
|
|
||||||
src={logoSrc}
|
|
||||||
alt={statusPage.companyName}
|
|
||||||
sx={styles.logoImg}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<Box sx={styles.logoConic}>{monoFirstChar(statusPage.companyName)}</Box>
|
|
||||||
)}
|
|
||||||
{statusPage.companyName}
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
<Box sx={styles.hero}>
|
|
||||||
<Box
|
|
||||||
component="h1"
|
|
||||||
sx={styles.heroTitle}
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
component="span"
|
|
||||||
sx={styles.heroCheck(overall.tone)}
|
|
||||||
>
|
|
||||||
{overall.icon}
|
|
||||||
</Box>
|
|
||||||
{overall.message}
|
|
||||||
</Box>
|
|
||||||
<Box
|
|
||||||
component="p"
|
|
||||||
sx={styles.heroSub}
|
|
||||||
>
|
|
||||||
{t("pages.statusPages.statusBar.monitoringSummary", {
|
|
||||||
count: monitors.length,
|
|
||||||
})}
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
{statusPage.showCharts && (
|
|
||||||
<Box sx={styles.chartSwitchWrap}>
|
|
||||||
<Box
|
|
||||||
sx={styles.chartSwitch}
|
|
||||||
role="radiogroup"
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
component="button"
|
|
||||||
type="button"
|
|
||||||
role="radio"
|
|
||||||
aria-checked={chartMode === "heatmap"}
|
|
||||||
onClick={() => setChartMode("heatmap")}
|
|
||||||
sx={styles.chartSwitchButton(chartMode === "heatmap")}
|
|
||||||
>
|
|
||||||
{t("pages.statusPages.monitorsList.chartTypeHeatmap")}
|
|
||||||
</Box>
|
|
||||||
<Box
|
|
||||||
component="button"
|
|
||||||
type="button"
|
|
||||||
role="radio"
|
|
||||||
aria-checked={chartMode === "histogram"}
|
|
||||||
onClick={() => setChartMode("histogram")}
|
|
||||||
sx={styles.chartSwitchButton(chartMode === "histogram")}
|
|
||||||
>
|
|
||||||
{t("pages.statusPages.monitorsList.chartTypeHistogram")}
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Stack
|
|
||||||
component="ul"
|
|
||||||
sx={styles.monitorList}
|
|
||||||
>
|
|
||||||
{monitors.map((monitor) => {
|
|
||||||
const isHardware = monitor.type === "hardware";
|
|
||||||
const showInfra = isHardware && statusPage.showInfrastructure !== false;
|
|
||||||
const showChart = !isHardware && statusPage.showCharts !== false;
|
|
||||||
const badgeTone = monitorBadgeTone(monitor.status);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Box
|
|
||||||
component="li"
|
|
||||||
key={monitor.id}
|
|
||||||
sx={styles.card}
|
|
||||||
>
|
|
||||||
<Box sx={styles.cardRow}>
|
|
||||||
<Box sx={styles.cardLeft}>
|
|
||||||
<Box sx={styles.monitorName}>{monitor.name}</Box>
|
|
||||||
<Box sx={styles.monitorMeta}>
|
|
||||||
<Box
|
|
||||||
component="span"
|
|
||||||
sx={isHardware ? styles.pillHardware : styles.pill}
|
|
||||||
>
|
|
||||||
{getMonitorTypeLabel(monitor.type, t)}
|
|
||||||
</Box>
|
|
||||||
{monitor.url && (
|
|
||||||
<Box
|
|
||||||
component="span"
|
|
||||||
sx={styles.monitorUrl}
|
|
||||||
title={monitor.url}
|
|
||||||
>
|
|
||||||
{monitor.url}
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
<Box
|
|
||||||
component="span"
|
|
||||||
sx={styles.badge(badgeTone)}
|
|
||||||
>
|
|
||||||
{t(statusBadgeKey[monitor.status])}
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
{showInfra && (
|
|
||||||
<ThemedInfrastructure
|
|
||||||
monitor={monitor}
|
|
||||||
sxApi={{
|
|
||||||
containerSx: styles.infra,
|
|
||||||
emptySx: styles.infraEmpty,
|
|
||||||
gaugeSx: styles.gauge,
|
|
||||||
gaugeLabelSx: styles.gaugeLabel,
|
|
||||||
gaugeValueSx: styles.gaugeValue,
|
|
||||||
gaugeBarSx: styles.gaugeBar,
|
|
||||||
gaugeFillSx: styles.gaugeFill,
|
|
||||||
gaugeSubSx: styles.gaugeSub,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{showChart &&
|
|
||||||
(chartMode === "heatmap" ? (
|
|
||||||
<ThemedHeatmap
|
|
||||||
checks={monitor.recentChecks ?? []}
|
|
||||||
containerSx={styles.heatmap}
|
|
||||||
cellSx={styles.heatmapCell}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<ThemedHistogram
|
|
||||||
checks={monitor.recentChecks ?? []}
|
|
||||||
containerSx={styles.histogram}
|
|
||||||
barSx={styles.bar}
|
|
||||||
statsSx={styles.chartStats}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</Stack>
|
|
||||||
|
|
||||||
<Box
|
|
||||||
component="footer"
|
|
||||||
sx={styles.footer}
|
|
||||||
>
|
|
||||||
{t("pages.statusPages.footer.poweredBy")}{" "}
|
|
||||||
<a
|
|
||||||
href="https://checkmate.so"
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
>
|
|
||||||
Checkmate
|
|
||||||
</a>
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import Box from "@mui/material/Box";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import type { SlotProps } from "@/Pages/StatusPage/Status/themes/shared/BaseStatusPage";
|
||||||
|
import type { EditorialStyles } from "@/Pages/StatusPage/Status/themes/editorial/styles";
|
||||||
|
|
||||||
|
export const EditorialHeader = ({
|
||||||
|
statusPage,
|
||||||
|
logoSrc,
|
||||||
|
styles,
|
||||||
|
}: SlotProps<EditorialStyles>) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
return (
|
||||||
|
<Box sx={styles.brandWrap}>
|
||||||
|
{logoSrc && (
|
||||||
|
<Box
|
||||||
|
component="img"
|
||||||
|
src={logoSrc}
|
||||||
|
alt={statusPage.companyName}
|
||||||
|
sx={styles.logoImg}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<Box
|
||||||
|
component="h2"
|
||||||
|
sx={styles.brandEyebrow}
|
||||||
|
>
|
||||||
|
{statusPage.companyName}
|
||||||
|
</Box>
|
||||||
|
<Box
|
||||||
|
component="h1"
|
||||||
|
sx={styles.brandTitle}
|
||||||
|
>
|
||||||
|
{t("pages.statusPages.editorial.reportTitle")}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import { useMemo } from "react";
|
||||||
|
import Box from "@mui/material/Box";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import type { SlotProps } from "@/Pages/StatusPage/Status/themes/shared/BaseStatusPage";
|
||||||
|
import type { EditorialStyles } from "@/Pages/StatusPage/Status/themes/editorial/styles";
|
||||||
|
|
||||||
|
export const EditorialHero = ({
|
||||||
|
overall,
|
||||||
|
monitorCount,
|
||||||
|
styles,
|
||||||
|
}: SlotProps<EditorialStyles>) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const todayLabel = useMemo(
|
||||||
|
() =>
|
||||||
|
new Date().toLocaleDateString(undefined, {
|
||||||
|
year: "numeric",
|
||||||
|
month: "long",
|
||||||
|
day: "numeric",
|
||||||
|
}),
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Box
|
||||||
|
component="p"
|
||||||
|
sx={styles.statusLine}
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
component="span"
|
||||||
|
sx={styles.statusDot(overall.tone)}
|
||||||
|
/>
|
||||||
|
{overall.message}
|
||||||
|
</Box>
|
||||||
|
<Box
|
||||||
|
component="p"
|
||||||
|
sx={styles.dateline}
|
||||||
|
>
|
||||||
|
{todayLabel} ·{" "}
|
||||||
|
{t("pages.statusPages.statusBar.monitoringSummary", {
|
||||||
|
count: monitorCount,
|
||||||
|
})}
|
||||||
|
</Box>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -1,224 +0,0 @@
|
|||||||
import { useMemo, useState } from "react";
|
|
||||||
import Box from "@mui/material/Box";
|
|
||||||
import Stack from "@mui/material/Stack";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import type { Monitor } from "@/Types/Monitor";
|
|
||||||
import type { StatusPage } from "@/Types/StatusPage";
|
|
||||||
import { getMonitorTypeLabel } from "@/Types/StatusPage";
|
|
||||||
import { ThemedHeatmap } from "../shared/ThemedHeatmap";
|
|
||||||
import { ThemedHistogram } from "../shared/ThemedHistogram";
|
|
||||||
import { ThemedInfrastructure } from "../shared/ThemedInfrastructure";
|
|
||||||
import {
|
|
||||||
monitorBadgeTone,
|
|
||||||
resolveOverallStatus,
|
|
||||||
statusBadgeKey,
|
|
||||||
} from "../shared/overallStatus";
|
|
||||||
import { useStatusPageTheme } from "../StatusPageThemeProvider";
|
|
||||||
import { editorialStyles } from "./styles";
|
|
||||||
|
|
||||||
type StatusPageMonitor = Monitor & { checks?: Monitor["recentChecks"] };
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
statusPage: StatusPage;
|
|
||||||
monitors: StatusPageMonitor[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export const EditorialStatusPage = ({ statusPage, monitors }: Props) => {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
const { tokens } = useStatusPageTheme();
|
|
||||||
const styles = useMemo(() => editorialStyles(tokens), [tokens]);
|
|
||||||
const [chartMode, setChartMode] = useState<"heatmap" | "histogram">("heatmap");
|
|
||||||
|
|
||||||
const todayLabel = useMemo(
|
|
||||||
() =>
|
|
||||||
new Date().toLocaleDateString(undefined, {
|
|
||||||
year: "numeric",
|
|
||||||
month: "long",
|
|
||||||
day: "numeric",
|
|
||||||
}),
|
|
||||||
[]
|
|
||||||
);
|
|
||||||
|
|
||||||
const overall = resolveOverallStatus(monitors, t, {
|
|
||||||
allUpKey: "pages.statusPages.editorial.allUp",
|
|
||||||
});
|
|
||||||
const logoSrc = statusPage.logo?.data
|
|
||||||
? `data:${statusPage.logo.contentType};base64,${statusPage.logo.data}`
|
|
||||||
: null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Box sx={styles.page}>
|
|
||||||
<Box
|
|
||||||
component="header"
|
|
||||||
sx={styles.top}
|
|
||||||
>
|
|
||||||
<Box sx={styles.brandWrap}>
|
|
||||||
{logoSrc && (
|
|
||||||
<Box
|
|
||||||
component="img"
|
|
||||||
src={logoSrc}
|
|
||||||
alt={statusPage.companyName}
|
|
||||||
sx={styles.logoImg}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<Box
|
|
||||||
component="h2"
|
|
||||||
sx={styles.brandEyebrow}
|
|
||||||
>
|
|
||||||
{statusPage.companyName}
|
|
||||||
</Box>
|
|
||||||
<Box
|
|
||||||
component="h1"
|
|
||||||
sx={styles.brandTitle}
|
|
||||||
>
|
|
||||||
{t("pages.statusPages.editorial.reportTitle")}
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
<Box
|
|
||||||
component="p"
|
|
||||||
sx={styles.statusLine}
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
component="span"
|
|
||||||
sx={styles.statusDot(overall.tone)}
|
|
||||||
/>
|
|
||||||
{overall.message}
|
|
||||||
</Box>
|
|
||||||
<Box
|
|
||||||
component="p"
|
|
||||||
sx={styles.dateline}
|
|
||||||
>
|
|
||||||
{todayLabel} ·{" "}
|
|
||||||
{t("pages.statusPages.statusBar.monitoringSummary", {
|
|
||||||
count: monitors.length,
|
|
||||||
})}
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
{statusPage.showCharts && (
|
|
||||||
<Box sx={styles.chartSwitchWrap}>
|
|
||||||
<Box
|
|
||||||
sx={styles.chartSwitch}
|
|
||||||
role="radiogroup"
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
component="button"
|
|
||||||
type="button"
|
|
||||||
role="radio"
|
|
||||||
aria-checked={chartMode === "heatmap"}
|
|
||||||
onClick={() => setChartMode("heatmap")}
|
|
||||||
sx={styles.chartSwitchButton(chartMode === "heatmap")}
|
|
||||||
>
|
|
||||||
{t("pages.statusPages.monitorsList.chartTypeHeatmap")}
|
|
||||||
</Box>
|
|
||||||
<Box
|
|
||||||
component="button"
|
|
||||||
type="button"
|
|
||||||
role="radio"
|
|
||||||
aria-checked={chartMode === "histogram"}
|
|
||||||
onClick={() => setChartMode("histogram")}
|
|
||||||
sx={styles.chartSwitchButton(chartMode === "histogram")}
|
|
||||||
>
|
|
||||||
{t("pages.statusPages.monitorsList.chartTypeHistogram")}
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Stack
|
|
||||||
component="ul"
|
|
||||||
sx={styles.monitorList}
|
|
||||||
>
|
|
||||||
{monitors.map((monitor) => {
|
|
||||||
const isHardware = monitor.type === "hardware";
|
|
||||||
const showInfra = isHardware && statusPage.showInfrastructure !== false;
|
|
||||||
const showChart = !isHardware && statusPage.showCharts !== false;
|
|
||||||
const badgeTone = monitorBadgeTone(monitor.status);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Box
|
|
||||||
component="li"
|
|
||||||
key={monitor.id}
|
|
||||||
sx={styles.card}
|
|
||||||
>
|
|
||||||
<Box sx={styles.cardRow}>
|
|
||||||
<Box sx={styles.cardLeft}>
|
|
||||||
<Box sx={styles.monitorName}>{monitor.name}</Box>
|
|
||||||
<Box sx={styles.monitorMeta}>
|
|
||||||
<Box
|
|
||||||
component="span"
|
|
||||||
sx={isHardware ? styles.pillHardware : styles.pill}
|
|
||||||
>
|
|
||||||
{getMonitorTypeLabel(monitor.type, t)}
|
|
||||||
</Box>
|
|
||||||
{monitor.url && (
|
|
||||||
<Box
|
|
||||||
component="span"
|
|
||||||
sx={styles.monitorUrl}
|
|
||||||
title={monitor.url}
|
|
||||||
>
|
|
||||||
{monitor.url}
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
<Box
|
|
||||||
component="span"
|
|
||||||
sx={styles.badge(badgeTone)}
|
|
||||||
>
|
|
||||||
{t(statusBadgeKey[monitor.status])}
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
{showInfra && (
|
|
||||||
<ThemedInfrastructure
|
|
||||||
monitor={monitor}
|
|
||||||
sxApi={{
|
|
||||||
containerSx: styles.infra,
|
|
||||||
emptySx: styles.infraEmpty,
|
|
||||||
gaugeSx: styles.gauge,
|
|
||||||
gaugeLabelSx: styles.gaugeLabel,
|
|
||||||
gaugeValueSx: styles.gaugeValue,
|
|
||||||
gaugeBarSx: styles.gaugeBar,
|
|
||||||
gaugeFillSx: styles.gaugeFill,
|
|
||||||
gaugeSubSx: styles.gaugeSub,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{showChart &&
|
|
||||||
(chartMode === "heatmap" ? (
|
|
||||||
<ThemedHeatmap
|
|
||||||
checks={monitor.recentChecks ?? []}
|
|
||||||
containerSx={styles.heatmap}
|
|
||||||
cellSx={styles.heatmapCell}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<ThemedHistogram
|
|
||||||
checks={monitor.recentChecks ?? []}
|
|
||||||
containerSx={styles.histogram}
|
|
||||||
barSx={styles.bar}
|
|
||||||
statsSx={styles.chartStats}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</Stack>
|
|
||||||
|
|
||||||
<Box
|
|
||||||
component="footer"
|
|
||||||
sx={styles.footer}
|
|
||||||
>
|
|
||||||
{t("pages.statusPages.footer.poweredBy")}{" "}
|
|
||||||
<a
|
|
||||||
href="https://checkmate.so"
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
>
|
|
||||||
Checkmate
|
|
||||||
</a>
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -51,7 +51,10 @@ export interface EditorialStyles {
|
|||||||
footer: SxProps<Theme>;
|
footer: SxProps<Theme>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const editorialStyles = (tokens: StatusPageThemeTokens): EditorialStyles => {
|
export const editorialStyles = (
|
||||||
|
tokens: StatusPageThemeTokens,
|
||||||
|
_isDark: boolean
|
||||||
|
): EditorialStyles => {
|
||||||
const heatCellBg: Record<EditorialHeatCell, string> = {
|
const heatCellBg: Record<EditorialHeatCell, string> = {
|
||||||
fast: tokens.up,
|
fast: tokens.up,
|
||||||
med: `color-mix(in srgb, ${tokens.up} 60%, ${tokens.bg})`,
|
med: `color-mix(in srgb, ${tokens.up} 60%, ${tokens.bg})`,
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import Box from "@mui/material/Box";
|
||||||
|
import { monoFirstChar } from "@/Pages/StatusPage/Status/themes/shared/overallStatus";
|
||||||
|
import type { SlotProps } from "@/Pages/StatusPage/Status/themes/shared/BaseStatusPage";
|
||||||
|
import type { ModernStyles } from "@/Pages/StatusPage/Status/themes/modern/styles";
|
||||||
|
|
||||||
|
export const ModernHeader = ({
|
||||||
|
statusPage,
|
||||||
|
logoSrc,
|
||||||
|
styles,
|
||||||
|
}: SlotProps<ModernStyles>) => (
|
||||||
|
<Box sx={styles.brand}>
|
||||||
|
{logoSrc ? (
|
||||||
|
<Box
|
||||||
|
component="img"
|
||||||
|
src={logoSrc}
|
||||||
|
alt={statusPage.companyName}
|
||||||
|
sx={styles.logoImg}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<Box sx={styles.logoGrad}>{monoFirstChar(statusPage.companyName)}</Box>
|
||||||
|
)}
|
||||||
|
{statusPage.companyName}
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import Box from "@mui/material/Box";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import type { SlotProps } from "@/Pages/StatusPage/Status/themes/shared/BaseStatusPage";
|
||||||
|
import type { ModernStyles } from "@/Pages/StatusPage/Status/themes/modern/styles";
|
||||||
|
|
||||||
|
export const ModernHero = ({
|
||||||
|
overall,
|
||||||
|
monitorCount,
|
||||||
|
styles,
|
||||||
|
}: SlotProps<ModernStyles>) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
return (
|
||||||
|
<Box sx={styles.hero}>
|
||||||
|
<Box sx={styles.pulse(overall.tone)} />
|
||||||
|
<Box sx={styles.statusCopy}>
|
||||||
|
<Box
|
||||||
|
component="h1"
|
||||||
|
sx={styles.heroTitle}
|
||||||
|
>
|
||||||
|
{overall.message}
|
||||||
|
</Box>
|
||||||
|
<Box
|
||||||
|
component="p"
|
||||||
|
sx={styles.heroSub}
|
||||||
|
>
|
||||||
|
{t("pages.statusPages.statusBar.monitoringSummary", {
|
||||||
|
count: monitorCount,
|
||||||
|
})}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
<Box sx={styles.heroIcon(overall.tone)}>{overall.icon}</Box>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import Box from "@mui/material/Box";
|
||||||
|
import { monoFirstChar } from "@/Pages/StatusPage/Status/themes/shared/overallStatus";
|
||||||
|
import type { SlotProps } from "@/Pages/StatusPage/Status/themes/shared/BaseStatusPage";
|
||||||
|
import type { RefinedStyles } from "@/Pages/StatusPage/Status/themes/refined/styles";
|
||||||
|
|
||||||
|
export const RefinedHeader = ({
|
||||||
|
statusPage,
|
||||||
|
logoSrc,
|
||||||
|
styles,
|
||||||
|
}: SlotProps<RefinedStyles>) => (
|
||||||
|
<Box sx={styles.brand}>
|
||||||
|
{logoSrc ? (
|
||||||
|
<Box
|
||||||
|
component="img"
|
||||||
|
src={logoSrc}
|
||||||
|
alt={statusPage.companyName}
|
||||||
|
sx={styles.logoImg}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<Box sx={styles.logoMono}>{monoFirstChar(statusPage.companyName)}</Box>
|
||||||
|
)}
|
||||||
|
<Box
|
||||||
|
component="span"
|
||||||
|
sx={styles.company}
|
||||||
|
>
|
||||||
|
{statusPage.companyName}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import Box from "@mui/material/Box";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import type { SlotProps } from "@/Pages/StatusPage/Status/themes/shared/BaseStatusPage";
|
||||||
|
import type { RefinedStyles } from "@/Pages/StatusPage/Status/themes/refined/styles";
|
||||||
|
|
||||||
|
export const RefinedHero = ({
|
||||||
|
overall,
|
||||||
|
monitorCount,
|
||||||
|
styles,
|
||||||
|
}: SlotProps<RefinedStyles>) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
return (
|
||||||
|
<Box sx={styles.hero}>
|
||||||
|
<Box sx={styles.statusDot(overall.tone)} />
|
||||||
|
<Box sx={styles.statusCopy}>
|
||||||
|
<Box
|
||||||
|
component="h1"
|
||||||
|
sx={styles.heroTitle}
|
||||||
|
>
|
||||||
|
{overall.message}
|
||||||
|
</Box>
|
||||||
|
<Box
|
||||||
|
component="p"
|
||||||
|
sx={styles.heroSub}
|
||||||
|
>
|
||||||
|
{t("pages.statusPages.statusBar.monitoringSummary", {
|
||||||
|
count: monitorCount,
|
||||||
|
})}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
<Box sx={styles.heroIcon(overall.tone)}>{overall.icon}</Box>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -1,210 +0,0 @@
|
|||||||
import { useMemo, useState } from "react";
|
|
||||||
import Box from "@mui/material/Box";
|
|
||||||
import Stack from "@mui/material/Stack";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import type { Monitor } from "@/Types/Monitor";
|
|
||||||
import type { StatusPage } from "@/Types/StatusPage";
|
|
||||||
import { getMonitorTypeLabel } from "@/Types/StatusPage";
|
|
||||||
import { ThemedHeatmap } from "../shared/ThemedHeatmap";
|
|
||||||
import { ThemedHistogram } from "../shared/ThemedHistogram";
|
|
||||||
import { ThemedInfrastructure } from "../shared/ThemedInfrastructure";
|
|
||||||
import {
|
|
||||||
monitorBadgeTone,
|
|
||||||
monoFirstChar,
|
|
||||||
resolveOverallStatus,
|
|
||||||
statusBadgeKey,
|
|
||||||
} from "../shared/overallStatus";
|
|
||||||
import { useStatusPageTheme } from "../StatusPageThemeProvider";
|
|
||||||
import { refinedStyles } from "./styles";
|
|
||||||
|
|
||||||
type StatusPageMonitor = Monitor & { checks?: Monitor["recentChecks"] };
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
statusPage: StatusPage;
|
|
||||||
monitors: StatusPageMonitor[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export const RefinedStatusPage = ({ statusPage, monitors }: Props) => {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
const { tokens } = useStatusPageTheme();
|
|
||||||
const styles = useMemo(() => refinedStyles(tokens), [tokens]);
|
|
||||||
const [chartMode, setChartMode] = useState<"heatmap" | "histogram">("heatmap");
|
|
||||||
|
|
||||||
const overall = resolveOverallStatus(monitors, t);
|
|
||||||
const logoSrc = statusPage.logo?.data
|
|
||||||
? `data:${statusPage.logo.contentType};base64,${statusPage.logo.data}`
|
|
||||||
: null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Box sx={styles.page}>
|
|
||||||
<Box
|
|
||||||
component="header"
|
|
||||||
sx={styles.top}
|
|
||||||
>
|
|
||||||
<Box sx={styles.brand}>
|
|
||||||
{logoSrc ? (
|
|
||||||
<Box
|
|
||||||
component="img"
|
|
||||||
src={logoSrc}
|
|
||||||
alt={statusPage.companyName}
|
|
||||||
sx={styles.logoImg}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<Box sx={styles.logoMono}>{monoFirstChar(statusPage.companyName)}</Box>
|
|
||||||
)}
|
|
||||||
<Box
|
|
||||||
component="span"
|
|
||||||
sx={styles.company}
|
|
||||||
>
|
|
||||||
{statusPage.companyName}
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
<Box sx={styles.hero}>
|
|
||||||
<Box sx={styles.statusDot(overall.tone)} />
|
|
||||||
<Box sx={styles.statusCopy}>
|
|
||||||
<Box
|
|
||||||
component="h1"
|
|
||||||
sx={styles.heroTitle}
|
|
||||||
>
|
|
||||||
{overall.message}
|
|
||||||
</Box>
|
|
||||||
<Box
|
|
||||||
component="p"
|
|
||||||
sx={styles.heroSub}
|
|
||||||
>
|
|
||||||
{t("pages.statusPages.statusBar.monitoringSummary", {
|
|
||||||
count: monitors.length,
|
|
||||||
})}
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
<Box sx={styles.heroIcon(overall.tone)}>{overall.icon}</Box>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
{statusPage.showCharts && (
|
|
||||||
<Box sx={styles.chartSwitchWrap}>
|
|
||||||
<Box
|
|
||||||
sx={styles.chartSwitch}
|
|
||||||
role="radiogroup"
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
component="button"
|
|
||||||
type="button"
|
|
||||||
role="radio"
|
|
||||||
aria-checked={chartMode === "heatmap"}
|
|
||||||
onClick={() => setChartMode("heatmap")}
|
|
||||||
sx={styles.chartSwitchButton(chartMode === "heatmap")}
|
|
||||||
>
|
|
||||||
{t("pages.statusPages.monitorsList.chartTypeHeatmap")}
|
|
||||||
</Box>
|
|
||||||
<Box
|
|
||||||
component="button"
|
|
||||||
type="button"
|
|
||||||
role="radio"
|
|
||||||
aria-checked={chartMode === "histogram"}
|
|
||||||
onClick={() => setChartMode("histogram")}
|
|
||||||
sx={styles.chartSwitchButton(chartMode === "histogram")}
|
|
||||||
>
|
|
||||||
{t("pages.statusPages.monitorsList.chartTypeHistogram")}
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Stack
|
|
||||||
component="ul"
|
|
||||||
sx={styles.monitorList}
|
|
||||||
>
|
|
||||||
{monitors.map((monitor) => {
|
|
||||||
const isHardware = monitor.type === "hardware";
|
|
||||||
const showInfra = isHardware && statusPage.showInfrastructure !== false;
|
|
||||||
const showChart = !isHardware && statusPage.showCharts !== false;
|
|
||||||
const badgeTone = monitorBadgeTone(monitor.status);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Box
|
|
||||||
component="li"
|
|
||||||
key={monitor.id}
|
|
||||||
sx={styles.card}
|
|
||||||
>
|
|
||||||
<Box sx={styles.cardRow}>
|
|
||||||
<Box sx={styles.cardLeft}>
|
|
||||||
<Box sx={styles.monitorName}>{monitor.name}</Box>
|
|
||||||
<Box sx={styles.monitorMeta}>
|
|
||||||
<Box
|
|
||||||
component="span"
|
|
||||||
sx={isHardware ? styles.pillHardware : styles.pill}
|
|
||||||
>
|
|
||||||
{getMonitorTypeLabel(monitor.type, t)}
|
|
||||||
</Box>
|
|
||||||
{monitor.url && (
|
|
||||||
<Box
|
|
||||||
component="span"
|
|
||||||
sx={styles.monitorUrl}
|
|
||||||
title={monitor.url}
|
|
||||||
>
|
|
||||||
{monitor.url}
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
<Box
|
|
||||||
component="span"
|
|
||||||
sx={styles.badge(badgeTone)}
|
|
||||||
>
|
|
||||||
{t(statusBadgeKey[monitor.status])}
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
{showInfra && (
|
|
||||||
<ThemedInfrastructure
|
|
||||||
monitor={monitor}
|
|
||||||
sxApi={{
|
|
||||||
containerSx: styles.infra,
|
|
||||||
emptySx: styles.infraEmpty,
|
|
||||||
gaugeSx: styles.gauge,
|
|
||||||
gaugeLabelSx: styles.gaugeLabel,
|
|
||||||
gaugeValueSx: styles.gaugeValue,
|
|
||||||
gaugeBarSx: styles.gaugeBar,
|
|
||||||
gaugeFillSx: styles.gaugeFill,
|
|
||||||
gaugeSubSx: styles.gaugeSub,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{showChart &&
|
|
||||||
(chartMode === "heatmap" ? (
|
|
||||||
<ThemedHeatmap
|
|
||||||
checks={monitor.recentChecks ?? []}
|
|
||||||
containerSx={styles.heatmap}
|
|
||||||
cellSx={styles.heatmapCell}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<ThemedHistogram
|
|
||||||
checks={monitor.recentChecks ?? []}
|
|
||||||
containerSx={styles.histogram}
|
|
||||||
barSx={styles.bar}
|
|
||||||
statsSx={styles.chartStats}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</Stack>
|
|
||||||
|
|
||||||
<Box
|
|
||||||
component="footer"
|
|
||||||
sx={styles.footer}
|
|
||||||
>
|
|
||||||
{t("pages.statusPages.footer.poweredBy")}{" "}
|
|
||||||
<a
|
|
||||||
href="https://checkmate.so"
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
>
|
|
||||||
Checkmate
|
|
||||||
</a>
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -63,7 +63,10 @@ const pillBase = {
|
|||||||
fontWeight: 600,
|
fontWeight: 600,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const refinedStyles = (tokens: StatusPageThemeTokens): RefinedStyles => {
|
export const refinedStyles = (
|
||||||
|
tokens: StatusPageThemeTokens,
|
||||||
|
_isDark: boolean
|
||||||
|
): RefinedStyles => {
|
||||||
const heatCellBg: Record<RefinedHeatCell, string> = {
|
const heatCellBg: Record<RefinedHeatCell, string> = {
|
||||||
fast: tokens.up,
|
fast: tokens.up,
|
||||||
med: `color-mix(in srgb, ${tokens.up} 60%, #ffffff 40%)`,
|
med: `color-mix(in srgb, ${tokens.up} 60%, #ffffff 40%)`,
|
||||||
|
|||||||
+88
-43
@@ -2,80 +2,125 @@ import { useMemo, useState } from "react";
|
|||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
import Stack from "@mui/material/Stack";
|
import Stack from "@mui/material/Stack";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import type { SxProps, Theme } from "@mui/material/styles";
|
||||||
import type { Monitor } from "@/Types/Monitor";
|
import type { Monitor } from "@/Types/Monitor";
|
||||||
import type { StatusPage } from "@/Types/StatusPage";
|
import type { StatusPage } from "@/Types/StatusPage";
|
||||||
import { getMonitorTypeLabel } from "@/Types/StatusPage";
|
import { getMonitorTypeLabel } from "@/Types/StatusPage";
|
||||||
import { ThemedHeatmap } from "../shared/ThemedHeatmap";
|
import type { StatusPageThemeTokens } from "@/Pages/StatusPage/Status/themes/tokens";
|
||||||
import { ThemedHistogram } from "../shared/ThemedHistogram";
|
|
||||||
import { ThemedInfrastructure } from "../shared/ThemedInfrastructure";
|
|
||||||
import {
|
import {
|
||||||
|
ThemedHeatmap,
|
||||||
|
type HeatCellKind,
|
||||||
|
} from "@/Pages/StatusPage/Status/themes/shared/ThemedHeatmap";
|
||||||
|
import {
|
||||||
|
ThemedHistogram,
|
||||||
|
type BarKind,
|
||||||
|
} from "@/Pages/StatusPage/Status/themes/shared/ThemedHistogram";
|
||||||
|
import {
|
||||||
|
ThemedInfrastructure,
|
||||||
|
type GaugeFillLevel,
|
||||||
|
} from "@/Pages/StatusPage/Status/themes/shared/ThemedInfrastructure";
|
||||||
|
import {
|
||||||
|
type OverallStatus,
|
||||||
|
type OverallTone,
|
||||||
monitorBadgeTone,
|
monitorBadgeTone,
|
||||||
monoFirstChar,
|
|
||||||
resolveOverallStatus,
|
resolveOverallStatus,
|
||||||
statusBadgeKey,
|
statusBadgeKey,
|
||||||
} from "../shared/overallStatus";
|
} from "@/Pages/StatusPage/Status/themes/shared/overallStatus";
|
||||||
import { useStatusPageTheme } from "../StatusPageThemeProvider";
|
import { useStatusPageTheme } from "@/Pages/StatusPage/Status/themes/StatusPageThemeProvider";
|
||||||
import { modernStyles } from "./styles";
|
|
||||||
|
|
||||||
type StatusPageMonitor = Monitor & { checks?: Monitor["recentChecks"] };
|
type StatusPageMonitor = Monitor & { checks?: Monitor["recentChecks"] };
|
||||||
|
|
||||||
|
export interface BaseStyles {
|
||||||
|
page: SxProps<Theme>;
|
||||||
|
top: SxProps<Theme>;
|
||||||
|
chartSwitchWrap: SxProps<Theme>;
|
||||||
|
chartSwitch: SxProps<Theme>;
|
||||||
|
chartSwitchButton: (active: boolean) => SxProps<Theme>;
|
||||||
|
monitorList: SxProps<Theme>;
|
||||||
|
card: SxProps<Theme>;
|
||||||
|
cardRow: SxProps<Theme>;
|
||||||
|
cardLeft: SxProps<Theme>;
|
||||||
|
monitorName: SxProps<Theme>;
|
||||||
|
monitorMeta: SxProps<Theme>;
|
||||||
|
pill: SxProps<Theme>;
|
||||||
|
pillHardware: SxProps<Theme>;
|
||||||
|
monitorUrl: SxProps<Theme>;
|
||||||
|
badge: (tone: OverallTone) => SxProps<Theme>;
|
||||||
|
heatmap: SxProps<Theme>;
|
||||||
|
heatmapCell: (kind: HeatCellKind) => SxProps<Theme>;
|
||||||
|
histogram: SxProps<Theme>;
|
||||||
|
bar: (kind: BarKind, heightPct: number) => SxProps<Theme>;
|
||||||
|
chartStats: SxProps<Theme>;
|
||||||
|
infra: SxProps<Theme>;
|
||||||
|
infraEmpty: SxProps<Theme>;
|
||||||
|
gauge: SxProps<Theme>;
|
||||||
|
gaugeLabel: SxProps<Theme>;
|
||||||
|
gaugeValue: SxProps<Theme>;
|
||||||
|
gaugeBar: SxProps<Theme>;
|
||||||
|
gaugeFill: (level: GaugeFillLevel, widthPct: number) => SxProps<Theme>;
|
||||||
|
gaugeSub: SxProps<Theme>;
|
||||||
|
footer: SxProps<Theme>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SlotProps<S extends BaseStyles = BaseStyles> {
|
||||||
|
statusPage: StatusPage;
|
||||||
|
logoSrc: string | null;
|
||||||
|
overall: OverallStatus;
|
||||||
|
monitorCount: number;
|
||||||
|
styles: S;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ThemeConfig<S extends BaseStyles = BaseStyles> {
|
||||||
|
createStyles: (tokens: StatusPageThemeTokens, isDark: boolean) => S;
|
||||||
|
HeaderSlot: React.ComponentType<SlotProps<S>>;
|
||||||
|
HeroSlot: React.ComponentType<SlotProps<S>>;
|
||||||
|
overallStatusOptions?: { iconSize?: number; allUpKey?: string };
|
||||||
|
}
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
statusPage: StatusPage;
|
statusPage: StatusPage;
|
||||||
monitors: StatusPageMonitor[];
|
monitors: StatusPageMonitor[];
|
||||||
|
config: ThemeConfig<any>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ModernStatusPage = ({ statusPage, monitors }: Props) => {
|
export const BaseStatusPage = ({ statusPage, monitors, config }: Props) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { tokens, mode } = useStatusPageTheme();
|
const { tokens, mode } = useStatusPageTheme();
|
||||||
const styles = useMemo(() => modernStyles(tokens, mode === "dark"), [tokens, mode]);
|
const styles = useMemo(
|
||||||
|
() => config.createStyles(tokens, mode === "dark"),
|
||||||
|
[config, tokens, mode]
|
||||||
|
);
|
||||||
const [chartMode, setChartMode] = useState<"heatmap" | "histogram">("heatmap");
|
const [chartMode, setChartMode] = useState<"heatmap" | "histogram">("heatmap");
|
||||||
|
|
||||||
const overall = resolveOverallStatus(monitors, t, { iconSize: 20 });
|
const overall = resolveOverallStatus(monitors, t, config.overallStatusOptions);
|
||||||
const logoSrc = statusPage.logo?.data
|
const logoSrc = statusPage.logo?.data
|
||||||
? `data:${statusPage.logo.contentType};base64,${statusPage.logo.data}`
|
? `data:${statusPage.logo.contentType};base64,${statusPage.logo.data}`
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
|
const { HeaderSlot, HeroSlot } = config;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={styles.page}>
|
<Box sx={styles.page}>
|
||||||
<Box
|
<Box
|
||||||
component="header"
|
component="header"
|
||||||
sx={styles.top}
|
sx={styles.top}
|
||||||
>
|
>
|
||||||
<Box sx={styles.brand}>
|
<HeaderSlot
|
||||||
{logoSrc ? (
|
statusPage={statusPage}
|
||||||
<Box
|
logoSrc={logoSrc}
|
||||||
component="img"
|
overall={overall}
|
||||||
src={logoSrc}
|
monitorCount={monitors.length}
|
||||||
alt={statusPage.companyName}
|
styles={styles}
|
||||||
sx={styles.logoImg}
|
/>
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<Box sx={styles.logoGrad}>{monoFirstChar(statusPage.companyName)}</Box>
|
|
||||||
)}
|
|
||||||
{statusPage.companyName}
|
|
||||||
</Box>
|
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Box sx={styles.hero}>
|
<HeroSlot
|
||||||
<Box sx={styles.pulse(overall.tone)} />
|
statusPage={statusPage}
|
||||||
<Box sx={styles.statusCopy}>
|
logoSrc={logoSrc}
|
||||||
<Box
|
overall={overall}
|
||||||
component="h1"
|
monitorCount={monitors.length}
|
||||||
sx={styles.heroTitle}
|
styles={styles}
|
||||||
>
|
/>
|
||||||
{overall.message}
|
|
||||||
</Box>
|
|
||||||
<Box
|
|
||||||
component="p"
|
|
||||||
sx={styles.heroSub}
|
|
||||||
>
|
|
||||||
{t("pages.statusPages.statusBar.monitoringSummary", {
|
|
||||||
count: monitors.length,
|
|
||||||
})}
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
<Box sx={styles.heroIcon(overall.tone)}>{overall.icon}</Box>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
{statusPage.showCharts && (
|
{statusPage.showCharts && (
|
||||||
<Box sx={styles.chartSwitchWrap}>
|
<Box sx={styles.chartSwitchWrap}>
|
||||||
Reference in new issue
Block a user