extract hardcoded strings

This commit is contained in:
Alex Holliday committed 2026-07-30 10:56:24 -07:00
1 parent c102cd8d26
commit 6856914d41
4 files changed
+41 -221

No files matched your search

@@ -17,6 +17,7 @@ import Typography from "@mui/material/Typography";
import prettyMilliseconds from "pretty-ms";
import { XTick } from "@/Components/monitors/charts/XTick";
import { useSelector } from "react-redux";
import { useTranslation } from "react-i18next";
import { formatDateWithTz, tooltipDateFormatLookup } from "@/Utils/TimeUtils";
import { useTheme } from "@mui/material/styles";
import type { Theme } from "@mui/material/styles";
@@ -29,7 +30,7 @@ import { SPACING } from "@/Utils/Theme/constants";
import {
PHASE_COLOR_KEYS,
PHASE_KEYS,
PHASE_LABELS,
PHASE_LABEL_KEYS,
} from "@/Components/monitors/charts/ChartUtils";
type DetailsCheck = GroupedCheck &
@@ -49,6 +50,7 @@ const ResponseTimeToolTip = ({
theme,
uiTimezone,
}: ResponseTimeToolTipProps) => {
const { t } = useTranslation();
if (!label) return null;
if (!payload) return null;
if (!active) return null;
@@ -59,8 +61,12 @@ const ResponseTimeToolTip = ({
<BaseBox sx={{ py: theme.spacing(2), px: theme.spacing(4) }}>
<Typography>{formatDateWithTz(String(label), format, uiTimezone)}</Typography>
<Typography>
Response time:{" "}
{prettyMilliseconds(responseTime, { formatSubMilliseconds: true, compact: true })}
{t("common.charts.histogram.responseTime", {
value: prettyMilliseconds(responseTime, {
formatSubMilliseconds: true,
compact: true,
}),
})}
</Typography>
</BaseBox>
);
@@ -79,6 +85,7 @@ const TimingPhasesToolTip = ({
theme,
uiTimezone,
}: TimingPhaseToolTipProps) => {
const { t } = useTranslation();
if (!active || !payload?.length) return null;
const bucket = payload[0].payload as GroupedUptimeCheck;
const total = PHASE_KEYS.reduce((sum, key) => sum + bucket[key], 0);
@@ -86,7 +93,9 @@ const TimingPhasesToolTip = ({
return (
<BaseBox sx={{ py: theme.spacing(2), px: theme.spacing(4) }}>
<Typography>{formatDateWithTz(bucket.bucketDate, format, uiTimezone)}</Typography>
<Typography>Total: {prettyMilliseconds(total)}</Typography>
<Typography>
{t("common.charts.histogram.total", { value: prettyMilliseconds(total) })}
</Typography>
{PHASE_KEYS.map((key) => (
<Stack
alignItems={"center"}
@@ -99,7 +108,7 @@ const TimingPhasesToolTip = ({
color={theme.palette.chart.phases[PHASE_COLOR_KEYS[key]]}
/>
<Typography>
{PHASE_LABELS[key]}:{" "}
{t(PHASE_LABEL_KEYS[key])}:{" "}
{prettyMilliseconds(bucket[key], {
formatSubMilliseconds: true,
compact: true,
@@ -119,6 +128,7 @@ export const HistogramDetails = ({
range: string;
}) => {
const [showTimingPhases, setShowTimingPhases] = useState(false);
const { t } = useTranslation();
const theme = useTheme();
const uiTimezone = useSelector((state: RootState) => state.ui.timezone);
const yMax = useMemo(() => {
@@ -142,7 +152,11 @@ export const HistogramDetails = ({
strokeWidth={1.5}
/>
}
title={showTimingPhases ? "Timing Phases" : "Response Time"}
title={
showTimingPhases
? t("common.charts.labels.timingPhases")
: t("common.charts.labels.responseTime")
}
onClick={() => {
if (!hasTimingPhases) return;
setShowTimingPhases((prev) => !prev);