refactor(status-page): drop legacy single-design renderer and CSS overrides
The 4 themed renderers (refined, modern, bold, editorial) cover every StatusPageTheme value and the model defaults to "refined", so the legacy fallback path in Status/index.tsx was unreachable in practice. Removing it lets us delete: - theme-overrides.css (the only remaining CSS file in StatusPage) - StatusBar / MonitorsList / InfrastructureMetrics (only the legacy fallback consumed them) - The .sp-* className hooks that wired CSS rules into the components Pure sx via the per-theme styles.ts recipes is now the single source of truth for every status page surface. Net diff is -801 / +42. Status/index.tsx now resolves a renderer from the theme map (falling back to the default theme) and keeps the public-route and admin-preview branches it already had.
This commit is contained in:
1 parent
ab9e722caa
commit
ed3645c3d0
7 files changed
+42
-843
No files matched your search
@@ -37,7 +37,6 @@ export const HeaderStatusPageControls = ({
|
|||||||
>
|
>
|
||||||
<Typography
|
<Typography
|
||||||
variant="h1"
|
variant="h1"
|
||||||
className="sp-heading"
|
|
||||||
overflow="hidden"
|
overflow="hidden"
|
||||||
textOverflow="ellipsis"
|
textOverflow="ellipsis"
|
||||||
sx={{
|
sx={{
|
||||||
|
|||||||
@@ -1,246 +0,0 @@
|
|||||||
import Stack from "@mui/material/Stack";
|
|
||||||
import Typography from "@mui/material/Typography";
|
|
||||||
import { Gauge } from "@/Components/design-elements";
|
|
||||||
import { useTheme } from "@mui/material/styles";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import prettyBytes from "pretty-bytes";
|
|
||||||
import type { Monitor } from "@/Types/Monitor";
|
|
||||||
import Grid from "@mui/material/Grid";
|
|
||||||
import useMediaQuery from "@mui/material/useMediaQuery";
|
|
||||||
import Box from "@mui/material/Box";
|
|
||||||
import { LAYOUT, SPACING } from "@/Utils/Theme/constants";
|
|
||||||
|
|
||||||
const GAUGE_RADIUS = 60;
|
|
||||||
const GAUGE_STROKE_WIDTH = 12;
|
|
||||||
const PERCENTAGE_MULTIPLIER = 100;
|
|
||||||
|
|
||||||
interface StatusPageMonitor extends Monitor {
|
|
||||||
checks?: Monitor["recentChecks"];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface MetricDetail {
|
|
||||||
label: string;
|
|
||||||
value: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface MetricConfig {
|
|
||||||
key: string;
|
|
||||||
label: string;
|
|
||||||
hasData: boolean;
|
|
||||||
progress: number;
|
|
||||||
details: MetricDetail[];
|
|
||||||
}
|
|
||||||
|
|
||||||
const MetricDetailRow = ({ label, value }: MetricDetail) => {
|
|
||||||
const theme = useTheme();
|
|
||||||
return (
|
|
||||||
<Stack
|
|
||||||
direction="row"
|
|
||||||
justifyContent="space-between"
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
variant="body2"
|
|
||||||
color={theme.palette.text.secondary}
|
|
||||||
>
|
|
||||||
{label}
|
|
||||||
</Typography>
|
|
||||||
<Typography variant="body2">{value}</Typography>
|
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
interface MetricItemProps {
|
|
||||||
label: string;
|
|
||||||
progress: number;
|
|
||||||
details?: MetricDetail[];
|
|
||||||
}
|
|
||||||
|
|
||||||
const MetricItem = ({ label, progress, details }: MetricItemProps) => {
|
|
||||||
const theme = useTheme();
|
|
||||||
const isSmall = useMediaQuery(theme.breakpoints.down("md"));
|
|
||||||
return (
|
|
||||||
<Grid
|
|
||||||
size={isSmall ? 12 : 4}
|
|
||||||
sx={{
|
|
||||||
display: "flex",
|
|
||||||
flexDirection: "column",
|
|
||||||
alignItems: "center",
|
|
||||||
textAlign: "center",
|
|
||||||
gap: theme.spacing(SPACING.LG),
|
|
||||||
padding: theme.spacing(LAYOUT.XS),
|
|
||||||
borderRight: isSmall ? "none" : `1px solid ${theme.palette.divider}`,
|
|
||||||
borderBottom: isSmall ? `1px solid ${theme.palette.divider}` : "none",
|
|
||||||
"&:last-child": {
|
|
||||||
borderRight: "none",
|
|
||||||
borderBottom: "none",
|
|
||||||
paddingBottom: theme.spacing(SPACING.LG),
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
display="flex"
|
|
||||||
flexDirection="column"
|
|
||||||
alignItems="center"
|
|
||||||
>
|
|
||||||
<Gauge
|
|
||||||
progress={progress}
|
|
||||||
radius={GAUGE_RADIUS}
|
|
||||||
strokeWidth={GAUGE_STROKE_WIDTH}
|
|
||||||
/>
|
|
||||||
<Typography variant="body2">{label}</Typography>
|
|
||||||
</Box>
|
|
||||||
{details && details.length > 0 && (
|
|
||||||
<Box
|
|
||||||
width="100%"
|
|
||||||
paddingX={theme.spacing(LAYOUT.LG)}
|
|
||||||
>
|
|
||||||
{details.map((detail) => (
|
|
||||||
<MetricDetailRow
|
|
||||||
key={detail.label}
|
|
||||||
label={detail.label}
|
|
||||||
value={detail.value}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
</Grid>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
type LatestCheck = NonNullable<Monitor["recentChecks"]>[number];
|
|
||||||
|
|
||||||
const buildCpuMetric = (
|
|
||||||
check: LatestCheck,
|
|
||||||
t: (key: string) => string
|
|
||||||
): MetricConfig | null => {
|
|
||||||
if (!check.cpu || typeof check.cpu.usage_percent !== "number") {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
const usagePercent = (check.cpu.usage_percent ?? 0) * PERCENTAGE_MULTIPLIER;
|
|
||||||
return {
|
|
||||||
key: "cpu",
|
|
||||||
label: t("pages.statusPages.monitorsList.infrastructure.cpu"),
|
|
||||||
hasData: true,
|
|
||||||
progress: usagePercent,
|
|
||||||
details: [
|
|
||||||
{
|
|
||||||
label: t("pages.statusPages.monitorsList.infrastructure.usage"),
|
|
||||||
value: `${usagePercent.toFixed(2)}%`,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const buildMemoryMetric = (
|
|
||||||
check: LatestCheck,
|
|
||||||
t: (key: string) => string
|
|
||||||
): MetricConfig | null => {
|
|
||||||
if (
|
|
||||||
!check.memory ||
|
|
||||||
typeof check.memory.usage_percent !== "number" ||
|
|
||||||
typeof check.memory.used_bytes !== "number" ||
|
|
||||||
typeof check.memory.total_bytes !== "number"
|
|
||||||
) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
key: "memory",
|
|
||||||
label: t("pages.statusPages.monitorsList.infrastructure.memory"),
|
|
||||||
hasData: true,
|
|
||||||
progress: (check.memory.usage_percent ?? 0) * PERCENTAGE_MULTIPLIER,
|
|
||||||
details: [
|
|
||||||
{
|
|
||||||
label: t("pages.statusPages.monitorsList.infrastructure.used"),
|
|
||||||
value: prettyBytes(check.memory.used_bytes ?? 0),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t("pages.statusPages.monitorsList.infrastructure.total"),
|
|
||||||
value: prettyBytes(check.memory.total_bytes ?? 0),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const buildDiskMetric = (
|
|
||||||
check: LatestCheck,
|
|
||||||
t: (key: string) => string
|
|
||||||
): MetricConfig | null => {
|
|
||||||
if (!check.disk || check.disk.length === 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
const disks = check.disk;
|
|
||||||
const avgUsagePercent =
|
|
||||||
(disks.reduce((acc, disk) => acc + (disk?.usage_percent ?? 0), 0) / disks.length) *
|
|
||||||
PERCENTAGE_MULTIPLIER;
|
|
||||||
const totalUsedBytes = disks.reduce((acc, disk) => acc + (disk?.used_bytes ?? 0), 0);
|
|
||||||
const totalTotalBytes = disks.reduce((acc, disk) => acc + (disk?.total_bytes ?? 0), 0);
|
|
||||||
|
|
||||||
return {
|
|
||||||
key: "disk",
|
|
||||||
label: t("pages.statusPages.monitorsList.infrastructure.disk"),
|
|
||||||
hasData: true,
|
|
||||||
progress: avgUsagePercent,
|
|
||||||
details: [
|
|
||||||
{
|
|
||||||
label: t("pages.statusPages.monitorsList.infrastructure.used"),
|
|
||||||
value: prettyBytes(totalUsedBytes),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t("pages.statusPages.monitorsList.infrastructure.total"),
|
|
||||||
value: prettyBytes(totalTotalBytes),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export const InfrastructureMetrics = ({ monitor }: { monitor: StatusPageMonitor }) => {
|
|
||||||
const theme = useTheme();
|
|
||||||
const { t } = useTranslation();
|
|
||||||
|
|
||||||
const latestCheck = monitor.recentChecks?.[0] ?? monitor.checks?.[0];
|
|
||||||
|
|
||||||
if (!latestCheck) {
|
|
||||||
return (
|
|
||||||
<Typography
|
|
||||||
variant="body2"
|
|
||||||
color={theme.palette.text.secondary}
|
|
||||||
>
|
|
||||||
{t("pages.statusPages.monitorsList.noData")}
|
|
||||||
</Typography>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const metrics: MetricConfig[] = [
|
|
||||||
buildCpuMetric(latestCheck, t),
|
|
||||||
buildMemoryMetric(latestCheck, t),
|
|
||||||
buildDiskMetric(latestCheck, t),
|
|
||||||
].filter((m): m is MetricConfig => m !== null);
|
|
||||||
|
|
||||||
if (metrics.length === 0) {
|
|
||||||
return (
|
|
||||||
<Typography
|
|
||||||
variant="body2"
|
|
||||||
color={theme.palette.text.secondary}
|
|
||||||
>
|
|
||||||
{t("pages.statusPages.monitorsList.noData")}
|
|
||||||
</Typography>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Grid
|
|
||||||
container
|
|
||||||
alignItems="center"
|
|
||||||
padding={theme.spacing(LAYOUT.XS)}
|
|
||||||
>
|
|
||||||
{metrics.map(({ key, label, progress, details }) => (
|
|
||||||
<MetricItem
|
|
||||||
key={key}
|
|
||||||
label={label}
|
|
||||||
progress={progress}
|
|
||||||
details={details}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</Grid>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -1,174 +0,0 @@
|
|||||||
import Stack from "@mui/material/Stack";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import Box from "@mui/material/Box";
|
|
||||||
import Typography from "@mui/material/Typography";
|
|
||||||
import { HistogramResponseTime, HeatmapResponseTime } from "@/Components/common";
|
|
||||||
import { StatusLabel, BaseBox } from "@/Components/design-elements";
|
|
||||||
import { SwitchComponent } from "@/Components/inputs";
|
|
||||||
import { InfrastructureMetrics } from "@/Pages/StatusPage/Status/Components/InfrastructureMetrics";
|
|
||||||
|
|
||||||
import { useTheme, type Theme } from "@mui/material/styles";
|
|
||||||
import { useSelector } from "react-redux";
|
|
||||||
import { useState } from "react";
|
|
||||||
import type { Monitor } from "@/Types/Monitor";
|
|
||||||
import type { StatusPage } from "@/Types/StatusPage";
|
|
||||||
import { getMonitorTypeLabel } from "@/Types/StatusPage";
|
|
||||||
import type { RootState } from "@/Types/state";
|
|
||||||
import { LAYOUT, SPACING } from "@/Utils/Theme/constants";
|
|
||||||
|
|
||||||
interface StatusPageMonitor extends Monitor {
|
|
||||||
checks?: Monitor["recentChecks"];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface MonitorsListProps {
|
|
||||||
statusPage: StatusPage;
|
|
||||||
monitors: StatusPageMonitor[];
|
|
||||||
}
|
|
||||||
|
|
||||||
const getMonitorBadgeStyles = (monitorType: string, theme: Theme) => {
|
|
||||||
const bg =
|
|
||||||
monitorType === "hardware" ? theme.palette.info.light : theme.palette.success.light;
|
|
||||||
return {
|
|
||||||
backgroundColor: bg,
|
|
||||||
color: theme.palette.background.paper,
|
|
||||||
padding: `${theme.spacing(SPACING.SM)} ${theme.spacing(SPACING.LG)}`,
|
|
||||||
borderRadius: theme.shape.borderRadius,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const MonitorHeader = ({
|
|
||||||
monitor,
|
|
||||||
showURL,
|
|
||||||
}: {
|
|
||||||
monitor: StatusPageMonitor;
|
|
||||||
showURL: boolean;
|
|
||||||
}) => {
|
|
||||||
const theme = useTheme();
|
|
||||||
const { t } = useTranslation();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Stack
|
|
||||||
direction="row"
|
|
||||||
alignItems="center"
|
|
||||||
justifyContent="space-between"
|
|
||||||
gap={theme.spacing(LAYOUT.XS)}
|
|
||||||
mb={theme.spacing(LAYOUT.XS)}
|
|
||||||
>
|
|
||||||
<Box sx={{ overflow: "hidden", minWidth: 0, flex: 1 }}>
|
|
||||||
<Stack
|
|
||||||
direction="row"
|
|
||||||
alignItems="center"
|
|
||||||
gap={theme.spacing(SPACING.LG)}
|
|
||||||
mb={theme.spacing(SPACING.SM)}
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
variant="h6"
|
|
||||||
className="sp-heading"
|
|
||||||
sx={{ overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }}
|
|
||||||
>
|
|
||||||
{monitor.name}
|
|
||||||
</Typography>
|
|
||||||
<Typography
|
|
||||||
variant="caption"
|
|
||||||
className="sp-badge"
|
|
||||||
sx={getMonitorBadgeStyles(monitor.type ?? "", theme)}
|
|
||||||
>
|
|
||||||
{getMonitorTypeLabel(monitor.type, t)}
|
|
||||||
</Typography>
|
|
||||||
</Stack>
|
|
||||||
{showURL && monitor.url && (
|
|
||||||
<Typography
|
|
||||||
variant="body2"
|
|
||||||
color={theme.palette.text.secondary}
|
|
||||||
sx={{ overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }}
|
|
||||||
>
|
|
||||||
{monitor.url}
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
</Box>
|
|
||||||
<StatusLabel status={monitor.status} />
|
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const MonitorContent = ({
|
|
||||||
monitor,
|
|
||||||
statusPage,
|
|
||||||
chartType,
|
|
||||||
}: {
|
|
||||||
monitor: StatusPageMonitor;
|
|
||||||
statusPage: StatusPage;
|
|
||||||
chartType: string;
|
|
||||||
}) => {
|
|
||||||
const theme = useTheme();
|
|
||||||
|
|
||||||
if (monitor.type === "hardware") {
|
|
||||||
if (statusPage.showInfrastructure === false) return null;
|
|
||||||
return <InfrastructureMetrics monitor={monitor} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (statusPage.showCharts === false) return null;
|
|
||||||
|
|
||||||
const checks = monitor.checks?.slice().reverse() ?? [];
|
|
||||||
return (
|
|
||||||
<Box sx={{ overflow: "hidden", minWidth: 0, flex: 1, mb: theme.spacing(SPACING.LG) }}>
|
|
||||||
{chartType === "histogram" ? (
|
|
||||||
<HistogramResponseTime
|
|
||||||
height={{ xs: 50, md: 100 }}
|
|
||||||
gap={{ xs: theme.spacing(SPACING.SM), md: theme.spacing(LAYOUT.SM) }}
|
|
||||||
checks={checks}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<HeatmapResponseTime checks={checks} />
|
|
||||||
)}
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const MonitorsList = ({ statusPage, monitors }: MonitorsListProps) => {
|
|
||||||
const theme = useTheme();
|
|
||||||
const { t } = useTranslation();
|
|
||||||
const showURL = useSelector((state: RootState) => state.ui?.showURL);
|
|
||||||
const [chartType, setChartType] = useState<"histogram" | "heatmap">("histogram");
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Stack gap={theme.spacing(LAYOUT.MD)}>
|
|
||||||
{statusPage.showCharts && (
|
|
||||||
<Stack
|
|
||||||
direction="row"
|
|
||||||
alignItems="center"
|
|
||||||
gap={theme.spacing(LAYOUT.SM)}
|
|
||||||
>
|
|
||||||
<Typography>{t("pages.statusPages.monitorsList.chartTypeHeatmap")}</Typography>
|
|
||||||
<SwitchComponent
|
|
||||||
dualOption
|
|
||||||
value={chartType}
|
|
||||||
checked={chartType === "histogram"}
|
|
||||||
onChange={(e) => setChartType(e.target.checked ? "histogram" : "heatmap")}
|
|
||||||
/>
|
|
||||||
<Typography>
|
|
||||||
{t("pages.statusPages.monitorsList.chartTypeHistogram")}
|
|
||||||
</Typography>
|
|
||||||
</Stack>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{monitors.map((monitor) => (
|
|
||||||
<BaseBox
|
|
||||||
key={monitor.id}
|
|
||||||
className="sp-card"
|
|
||||||
padding={theme.spacing(LAYOUT.MD)}
|
|
||||||
>
|
|
||||||
<MonitorHeader
|
|
||||||
monitor={monitor}
|
|
||||||
showURL={showURL}
|
|
||||||
/>
|
|
||||||
<MonitorContent
|
|
||||||
monitor={monitor}
|
|
||||||
statusPage={statusPage}
|
|
||||||
chartType={chartType}
|
|
||||||
/>
|
|
||||||
</BaseBox>
|
|
||||||
))}
|
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -1,173 +0,0 @@
|
|||||||
import {
|
|
||||||
AlertTriangle,
|
|
||||||
CircleCheck,
|
|
||||||
CircleX,
|
|
||||||
Loader,
|
|
||||||
PauseCircle,
|
|
||||||
ShieldAlert,
|
|
||||||
Wrench,
|
|
||||||
} from "lucide-react";
|
|
||||||
import Stack from "@mui/material/Stack";
|
|
||||||
import Typography from "@mui/material/Typography";
|
|
||||||
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import { useTheme } from "@mui/material";
|
|
||||||
import type { Monitor, MonitorStatus } from "@/Types/Monitor";
|
|
||||||
|
|
||||||
type SemanticTone = "up" | "down" | "warn" | "info";
|
|
||||||
|
|
||||||
interface StatusDisplay {
|
|
||||||
icon: JSX.Element;
|
|
||||||
msg?: string;
|
|
||||||
tone: SemanticTone;
|
|
||||||
}
|
|
||||||
|
|
||||||
const getMonitorStatus = (monitors: Monitor[], t: Function): StatusDisplay => {
|
|
||||||
if (monitors.length === 0) {
|
|
||||||
return {
|
|
||||||
msg: t("pages.statusPages.statusBar.noMonitors"),
|
|
||||||
tone: "warn",
|
|
||||||
icon: <CircleX size={24} />,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const allOf = (...statuses: MonitorStatus[]) =>
|
|
||||||
monitors.every((m) => statuses.includes(m.status));
|
|
||||||
const someOf = (...statuses: MonitorStatus[]) =>
|
|
||||||
monitors.some((m) => statuses.includes(m.status));
|
|
||||||
const noneOf = (...statuses: MonitorStatus[]) =>
|
|
||||||
monitors.every((m) => !statuses.includes(m.status));
|
|
||||||
|
|
||||||
if (allOf("up")) {
|
|
||||||
return {
|
|
||||||
msg: t("pages.statusPages.statusBar.allUp"),
|
|
||||||
tone: "up",
|
|
||||||
icon: <CircleCheck size={24} />,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (allOf("breached")) {
|
|
||||||
return {
|
|
||||||
msg: t("pages.statusPages.statusBar.allBreached"),
|
|
||||||
tone: "down",
|
|
||||||
icon: <ShieldAlert size={24} />,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (allOf("maintenance")) {
|
|
||||||
return {
|
|
||||||
msg: t("pages.statusPages.statusBar.allMaintenance"),
|
|
||||||
tone: "warn",
|
|
||||||
icon: <Wrench size={24} />,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (allOf("down")) {
|
|
||||||
return {
|
|
||||||
msg: t("pages.statusPages.statusBar.allDown"),
|
|
||||||
tone: "down",
|
|
||||||
icon: <CircleX size={24} />,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (allOf("paused")) {
|
|
||||||
return {
|
|
||||||
msg: t("pages.statusPages.statusBar.allPaused"),
|
|
||||||
tone: "warn",
|
|
||||||
icon: <PauseCircle size={24} />,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (allOf("initializing")) {
|
|
||||||
return {
|
|
||||||
msg: t("pages.statusPages.statusBar.allInitializing"),
|
|
||||||
tone: "warn",
|
|
||||||
icon: <Loader size={24} />,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Breached takes highest priority in mixed states
|
|
||||||
if (someOf("breached") && someOf("down")) {
|
|
||||||
return {
|
|
||||||
msg: t("pages.statusPages.statusBar.breachedAndDown"),
|
|
||||||
tone: "down",
|
|
||||||
icon: <ShieldAlert size={24} />,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (someOf("breached")) {
|
|
||||||
return {
|
|
||||||
msg: t("pages.statusPages.statusBar.breached"),
|
|
||||||
tone: "down",
|
|
||||||
icon: <ShieldAlert size={24} />,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (someOf("maintenance") && someOf("down")) {
|
|
||||||
return {
|
|
||||||
msg: t("pages.statusPages.statusBar.maintenanceAndDown"),
|
|
||||||
tone: "down",
|
|
||||||
icon: <Wrench size={24} />,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (someOf("maintenance") && noneOf("down")) {
|
|
||||||
return {
|
|
||||||
msg: t("pages.statusPages.statusBar.maintenance"),
|
|
||||||
tone: "warn",
|
|
||||||
icon: <Wrench size={24} />,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (someOf("down")) {
|
|
||||||
return {
|
|
||||||
msg: t("pages.statusPages.statusBar.degraded"),
|
|
||||||
tone: "warn",
|
|
||||||
icon: <AlertTriangle size={24} />,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (someOf("paused")) {
|
|
||||||
return {
|
|
||||||
msg: t("pages.statusPages.statusBar.partiallyPaused"),
|
|
||||||
tone: "warn",
|
|
||||||
icon: <PauseCircle size={24} />,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (someOf("initializing")) {
|
|
||||||
return {
|
|
||||||
msg: t("pages.statusPages.statusBar.initializing"),
|
|
||||||
tone: "info",
|
|
||||||
icon: <Loader size={24} />,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
msg: t("pages.statusPages.statusBar.unknown"),
|
|
||||||
tone: "warn",
|
|
||||||
icon: <AlertTriangle size={24} />,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const toneToCssVar: Record<SemanticTone, string> = {
|
|
||||||
up: "var(--sp-up)",
|
|
||||||
down: "var(--sp-down)",
|
|
||||||
warn: "var(--sp-warn)",
|
|
||||||
info: "var(--sp-up)",
|
|
||||||
};
|
|
||||||
|
|
||||||
interface StatusBarProps {
|
|
||||||
monitors: Monitor[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export const StatusBar = ({ monitors }: StatusBarProps) => {
|
|
||||||
const theme = useTheme();
|
|
||||||
const { t } = useTranslation();
|
|
||||||
const monitorsStatus = getMonitorStatus(monitors, t);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Stack
|
|
||||||
direction="row"
|
|
||||||
alignItems="center"
|
|
||||||
justifyContent="center"
|
|
||||||
gap={theme.spacing(2)}
|
|
||||||
height={theme.spacing(30)}
|
|
||||||
bgcolor={toneToCssVar[monitorsStatus.tone]}
|
|
||||||
borderRadius={theme.shape.borderRadius}
|
|
||||||
className="sp-hero"
|
|
||||||
>
|
|
||||||
{monitorsStatus.icon}
|
|
||||||
<Typography className="sp-hero-title">{monitorsStatus.msg}</Typography>
|
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -1,18 +1,20 @@
|
|||||||
import { BasePage, BaseFallback } from "@/Components/design-elements";
|
import { BasePage, BaseFallback } from "@/Components/design-elements";
|
||||||
import { StatusBar } from "@/Pages/StatusPage/Status/Components/StatusBar";
|
|
||||||
import { MonitorsList } from "@/Pages/StatusPage/Status/Components/MonitorsList";
|
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import Stack from "@mui/material/Stack";
|
import Stack from "@mui/material/Stack";
|
||||||
import Box from "@mui/material/Box";
|
|
||||||
|
|
||||||
import { useMediaQuery, useTheme } from "@mui/material";
|
import { useTheme } from "@mui/material";
|
||||||
import { useTranslation } from "react-i18next";
|
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 type { Monitor } from "@/Types/Monitor";
|
||||||
import type { StatusPage, StatusPageResponse, StatusPageTheme } from "@/Types/StatusPage";
|
import {
|
||||||
|
DEFAULT_STATUS_PAGE_THEME,
|
||||||
|
type StatusPage,
|
||||||
|
type StatusPageResponse,
|
||||||
|
type StatusPageTheme,
|
||||||
|
} from "@/Types/StatusPage";
|
||||||
import { HeaderStatusPageControls } from "./Components/HeaderStatusPageControls";
|
import { HeaderStatusPageControls } from "./Components/HeaderStatusPageControls";
|
||||||
import { StatusPageThemeProvider } from "./themes/StatusPageThemeProvider";
|
import { StatusPageThemeProvider } from "./themes/StatusPageThemeProvider";
|
||||||
import { RefinedStatusPage } from "./themes/refined/RefinedStatusPage";
|
import { RefinedStatusPage } from "./themes/refined/RefinedStatusPage";
|
||||||
@@ -26,8 +28,9 @@ type ThemedRendererProps = {
|
|||||||
monitors: (Monitor & { checks?: Monitor["recentChecks"] })[];
|
monitors: (Monitor & { checks?: Monitor["recentChecks"] })[];
|
||||||
};
|
};
|
||||||
|
|
||||||
const THEMED_RENDERERS: Partial<
|
const THEMED_RENDERERS: Record<
|
||||||
Record<StatusPageTheme, React.ComponentType<ThemedRendererProps>>
|
StatusPageTheme,
|
||||||
|
React.ComponentType<ThemedRendererProps>
|
||||||
> = {
|
> = {
|
||||||
refined: RefinedStatusPage,
|
refined: RefinedStatusPage,
|
||||||
modern: ModernStatusPage,
|
modern: ModernStatusPage,
|
||||||
@@ -41,7 +44,6 @@ const StatusPageView = () => {
|
|||||||
const { url } = useParams();
|
const { url } = useParams();
|
||||||
const isAdmin = useIsAdmin();
|
const isAdmin = useIsAdmin();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const isSmall = useMediaQuery(theme.breakpoints.down("md"));
|
|
||||||
const isPublic = location.pathname.startsWith("/status/public");
|
const isPublic = location.pathname.startsWith("/status/public");
|
||||||
|
|
||||||
const apiUrl = url ? `/status-page/${url}?type=uptime&type=infrastructure` : null;
|
const apiUrl = url ? `/status-page/${url}?type=uptime&type=infrastructure` : null;
|
||||||
@@ -86,103 +88,51 @@ const StatusPageView = () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let sx: React.CSSProperties = {};
|
const ThemedRenderer =
|
||||||
if (isPublic) {
|
THEMED_RENDERERS[statusPage.theme ?? DEFAULT_STATUS_PAGE_THEME] ??
|
||||||
sx.paddingTop = theme.spacing(20);
|
THEMED_RENDERERS[DEFAULT_STATUS_PAGE_THEME];
|
||||||
sx.paddingLeft = isSmall ? "5vw" : "20vw";
|
const themedRenderer = (
|
||||||
sx.paddingRight = isSmall ? "5vw" : "20vw";
|
|
||||||
}
|
|
||||||
|
|
||||||
const logoSrc = statusPage.logo?.data
|
|
||||||
? `data:${statusPage.logo.contentType};base64,${statusPage.logo.data}`
|
|
||||||
: null;
|
|
||||||
|
|
||||||
const ThemedRenderer = statusPage.theme
|
|
||||||
? THEMED_RENDERERS[statusPage.theme]
|
|
||||||
: undefined;
|
|
||||||
const themedRenderer = ThemedRenderer ? (
|
|
||||||
<ThemedRenderer
|
<ThemedRenderer
|
||||||
statusPage={statusPage}
|
statusPage={statusPage}
|
||||||
monitors={monitors}
|
monitors={monitors}
|
||||||
/>
|
/>
|
||||||
) : null;
|
);
|
||||||
|
|
||||||
if (themedRenderer) {
|
// Public route: render directly on the viewport, themed background covers everything.
|
||||||
// Public route: render directly on the viewport, themed background covers everything.
|
if (isPublic) {
|
||||||
if (isPublic) {
|
|
||||||
return (
|
|
||||||
<StatusPageThemeProvider
|
|
||||||
theme={statusPage.theme}
|
|
||||||
themeMode={statusPage.themeMode}
|
|
||||||
paintBody
|
|
||||||
>
|
|
||||||
{themedRenderer}
|
|
||||||
</StatusPageThemeProvider>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Admin preview: wrap in a mock browser frame inside the admin shell.
|
|
||||||
const publicUrl = `${window.location.origin}/status/public/${statusPage.url}`;
|
|
||||||
return (
|
return (
|
||||||
<BasePage
|
<StatusPageThemeProvider
|
||||||
loading={isLoading}
|
theme={statusPage.theme}
|
||||||
error={error}
|
themeMode={statusPage.themeMode}
|
||||||
breadcrumbOverride={undefined}
|
paintBody
|
||||||
sx={{ flex: 1, minHeight: 0 }}
|
|
||||||
>
|
>
|
||||||
<HeaderStatusPageControls
|
{themedRenderer}
|
||||||
isAdmin={isAdmin}
|
</StatusPageThemeProvider>
|
||||||
statusPage={statusPage}
|
|
||||||
isPublic={false}
|
|
||||||
/>
|
|
||||||
<StatusPageThemeProvider
|
|
||||||
theme={statusPage.theme}
|
|
||||||
themeMode={statusPage.themeMode}
|
|
||||||
transparent
|
|
||||||
>
|
|
||||||
<BrowserFrame url={publicUrl}>{themedRenderer}</BrowserFrame>
|
|
||||||
</StatusPageThemeProvider>
|
|
||||||
</BasePage>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Admin preview: wrap in a mock browser frame inside the admin shell.
|
||||||
|
const publicUrl = `${window.location.origin}/status/public/${statusPage.url}`;
|
||||||
return (
|
return (
|
||||||
<StatusPageThemeProvider
|
<BasePage
|
||||||
theme={statusPage.theme}
|
loading={isLoading}
|
||||||
themeMode={statusPage.themeMode}
|
error={error}
|
||||||
|
breadcrumbOverride={undefined}
|
||||||
|
sx={{ flex: 1, minHeight: 0 }}
|
||||||
>
|
>
|
||||||
<BasePage
|
<HeaderStatusPageControls
|
||||||
loading={isLoading}
|
isAdmin={isAdmin}
|
||||||
error={error}
|
statusPage={statusPage}
|
||||||
sx={sx}
|
isPublic={false}
|
||||||
breadcrumbOverride={isPublic ? [] : undefined}
|
/>
|
||||||
|
<StatusPageThemeProvider
|
||||||
|
theme={statusPage.theme}
|
||||||
|
themeMode={statusPage.themeMode}
|
||||||
|
transparent
|
||||||
>
|
>
|
||||||
<HeaderStatusPageControls
|
<BrowserFrame url={publicUrl}>{themedRenderer}</BrowserFrame>
|
||||||
isAdmin={isAdmin}
|
</StatusPageThemeProvider>
|
||||||
statusPage={statusPage}
|
</BasePage>
|
||||||
isPublic={isPublic}
|
|
||||||
/>
|
|
||||||
{logoSrc && (
|
|
||||||
<Box
|
|
||||||
component="img"
|
|
||||||
src={logoSrc}
|
|
||||||
alignSelf={"flex-start"}
|
|
||||||
alt={statusPage.companyName}
|
|
||||||
sx={{
|
|
||||||
maxHeight: 120,
|
|
||||||
maxWidth: "100%",
|
|
||||||
objectFit: "contain",
|
|
||||||
mb: 2,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<StatusBar monitors={monitors} />
|
|
||||||
<MonitorsList
|
|
||||||
statusPage={statusPage}
|
|
||||||
monitors={monitors}
|
|
||||||
/>
|
|
||||||
</BasePage>
|
|
||||||
</StatusPageThemeProvider>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import {
|
|||||||
type StatusPageThemeMode,
|
type StatusPageThemeMode,
|
||||||
} from "@/Types/StatusPage";
|
} from "@/Types/StatusPage";
|
||||||
import { themeTokens, toCssVars, type StatusPageThemeTokens } from "./tokens";
|
import { themeTokens, toCssVars, type StatusPageThemeTokens } from "./tokens";
|
||||||
import "./theme-overrides.css";
|
|
||||||
|
|
||||||
type ResolvedMode = "light" | "dark";
|
type ResolvedMode = "light" | "dark";
|
||||||
|
|
||||||
|
|||||||
@@ -1,156 +0,0 @@
|
|||||||
/*
|
|
||||||
* Scoped styling for the public status page themes.
|
|
||||||
* Every selector is prefixed with [data-status-theme="..."] so these styles
|
|
||||||
* only apply inside the StatusPageThemeProvider subtree.
|
|
||||||
*
|
|
||||||
* Colour tokens come from CSS custom properties set by the provider
|
|
||||||
* (see tokens.ts → toCssVars). This file adds structural and surface rules
|
|
||||||
* that a plain token swap can't express.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* --- shared: push tokens onto MUI surfaces inside the themed tree --- */
|
|
||||||
[data-status-theme] {
|
|
||||||
color: var(--sp-text);
|
|
||||||
}
|
|
||||||
|
|
||||||
[data-status-theme] .sp-card,
|
|
||||||
[data-status-theme] .MuiBox-root.sp-card {
|
|
||||||
background-color: var(--sp-surface) !important;
|
|
||||||
border-color: var(--sp-border) !important;
|
|
||||||
border-radius: var(--sp-radius) !important;
|
|
||||||
color: var(--sp-text);
|
|
||||||
}
|
|
||||||
|
|
||||||
[data-status-theme] .sp-heading {
|
|
||||||
color: var(--sp-text);
|
|
||||||
}
|
|
||||||
|
|
||||||
[data-status-theme] .sp-badge {
|
|
||||||
background-color: var(--sp-up-soft) !important;
|
|
||||||
color: var(--sp-up) !important;
|
|
||||||
border-radius: 999px;
|
|
||||||
padding: 2px 10px;
|
|
||||||
font-weight: 600;
|
|
||||||
letter-spacing: 0.04em;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Status bar / hero */
|
|
||||||
[data-status-theme] .sp-hero {
|
|
||||||
border-radius: var(--sp-radius);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --- refined: soft shadow, small accent on card --- */
|
|
||||||
[data-status-theme="refined"] .sp-card {
|
|
||||||
box-shadow:
|
|
||||||
0 1px 2px rgba(10, 16, 32, 0.06),
|
|
||||||
0 6px 18px rgba(10, 16, 32, 0.08) !important;
|
|
||||||
}
|
|
||||||
[data-status-theme="refined"] .sp-hero-title {
|
|
||||||
font-weight: 600;
|
|
||||||
letter-spacing: -0.01em;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --- modern: stronger shadow, larger radius, pulse dot + staggered fade --- */
|
|
||||||
[data-status-theme="modern"] .sp-card {
|
|
||||||
box-shadow:
|
|
||||||
0 2px 4px rgba(16, 24, 40, 0.04),
|
|
||||||
0 12px 32px rgba(16, 24, 40, 0.06) !important;
|
|
||||||
border-radius: 16px !important;
|
|
||||||
opacity: 0;
|
|
||||||
transform: translateY(8px);
|
|
||||||
animation: sp-card-fadein 0.5s forwards;
|
|
||||||
}
|
|
||||||
[data-status-theme="modern"] .sp-card:nth-of-type(1) {
|
|
||||||
animation-delay: 0.05s;
|
|
||||||
}
|
|
||||||
[data-status-theme="modern"] .sp-card:nth-of-type(2) {
|
|
||||||
animation-delay: 0.1s;
|
|
||||||
}
|
|
||||||
[data-status-theme="modern"] .sp-card:nth-of-type(3) {
|
|
||||||
animation-delay: 0.15s;
|
|
||||||
}
|
|
||||||
[data-status-theme="modern"] .sp-card:nth-of-type(4) {
|
|
||||||
animation-delay: 0.2s;
|
|
||||||
}
|
|
||||||
[data-status-theme="modern"] .sp-card:nth-of-type(5) {
|
|
||||||
animation-delay: 0.25s;
|
|
||||||
}
|
|
||||||
[data-status-theme="modern"] .sp-card:nth-of-type(n + 6) {
|
|
||||||
animation-delay: 0.3s;
|
|
||||||
}
|
|
||||||
@keyframes sp-card-fadein {
|
|
||||||
to {
|
|
||||||
opacity: 1;
|
|
||||||
transform: translateY(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[data-status-theme="modern"] .sp-hero-title {
|
|
||||||
font-size: 22px;
|
|
||||||
font-weight: 700;
|
|
||||||
letter-spacing: -0.02em;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --- bold: large type, conic-gradient hero accent when no logo --- */
|
|
||||||
[data-status-theme="bold"] .sp-hero {
|
|
||||||
background:
|
|
||||||
linear-gradient(135deg, var(--sp-up-soft), transparent 60%), var(--sp-surface) !important;
|
|
||||||
border: 1px solid var(--sp-border) !important;
|
|
||||||
}
|
|
||||||
[data-status-theme="bold"] .sp-hero-title {
|
|
||||||
font-size: 32px;
|
|
||||||
font-weight: 800;
|
|
||||||
letter-spacing: -0.02em;
|
|
||||||
line-height: 1.1;
|
|
||||||
color: var(--sp-text) !important;
|
|
||||||
}
|
|
||||||
[data-status-theme="bold"] .sp-card {
|
|
||||||
border-radius: 18px !important;
|
|
||||||
border: 1px solid var(--sp-border) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --- editorial: serif headings, hairline dividers instead of cards --- */
|
|
||||||
[data-status-theme="editorial"] .sp-heading {
|
|
||||||
font-family: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
|
|
||||||
letter-spacing: -0.01em;
|
|
||||||
}
|
|
||||||
[data-status-theme="editorial"] .sp-card {
|
|
||||||
background-color: transparent !important;
|
|
||||||
border: 0 !important;
|
|
||||||
border-bottom: 1px solid var(--sp-border) !important;
|
|
||||||
border-radius: 0 !important;
|
|
||||||
box-shadow: none !important;
|
|
||||||
padding-left: 0 !important;
|
|
||||||
padding-right: 0 !important;
|
|
||||||
}
|
|
||||||
[data-status-theme="editorial"] .sp-card:last-of-type {
|
|
||||||
border-bottom: 0 !important;
|
|
||||||
}
|
|
||||||
[data-status-theme="editorial"] .sp-hero {
|
|
||||||
background: transparent !important;
|
|
||||||
color: var(--sp-text) !important;
|
|
||||||
border-bottom: 2px solid var(--sp-text) !important;
|
|
||||||
border-radius: 0 !important;
|
|
||||||
box-shadow: none !important;
|
|
||||||
}
|
|
||||||
[data-status-theme="editorial"] .sp-hero-title {
|
|
||||||
font-family: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
|
|
||||||
font-weight: 700;
|
|
||||||
}
|
|
||||||
[data-status-theme="editorial"] .sp-badge {
|
|
||||||
background-color: transparent !important;
|
|
||||||
color: var(--sp-text-muted) !important;
|
|
||||||
border: 1px solid var(--sp-border) !important;
|
|
||||||
border-radius: 0 !important;
|
|
||||||
text-transform: uppercase;
|
|
||||||
font-size: 10px;
|
|
||||||
letter-spacing: 0.12em;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Reduce motion */
|
|
||||||
@media (prefers-reduced-motion: reduce) {
|
|
||||||
[data-status-theme] .sp-card {
|
|
||||||
animation: none;
|
|
||||||
opacity: 1;
|
|
||||||
transform: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user