Feat: Migrate Hardcoded Strings

This commit is contained in:
Br0wnHammer committed 2025-03-17 01:16:42 +05:30
1 parent b6113a176f
commit cdbabeb225
30 files changed
+334 -187

No files matched your search

+22 -23
View File
@@ -6,6 +6,7 @@ import { Box, Stack, Tooltip, Typography, Button } from "@mui/material";
import { monitorValidation } from "../../../Validation/validation";
import { createToast } from "../../../Utils/toastUtils";
import { logger } from "../../../Utils/Logger";
import { useTranslation } from "react-i18next";
import ConfigBox from "../../../Components/ConfigBox";
import {
updateUptimeMonitor,
@@ -207,6 +208,8 @@ const Configure = () => {
undefined: "Pending...",
};
const { t } = useTranslation();
return (
<Stack
className="configure-monitor"
@@ -293,7 +296,7 @@ const Configure = () => {
},
}}
>
Editing...
{t("editing")}
</Typography>
</Stack>
</Box>
@@ -326,12 +329,12 @@ const Configure = () => {
{monitor?.isActive ? (
<>
<PauseIcon />
Pause
{t("pause")}
</>
) : (
<>
<ResumeIcon />
Resume
{t("resume")}
</>
)}
</Button>
@@ -342,16 +345,15 @@ const Configure = () => {
sx={{ px: theme.spacing(8) }}
onClick={() => setIsOpen(true)}
>
Remove
{t("remove")}
</Button>
</Box>
</Stack>
<ConfigBox>
<Box>
<Typography component="h2">General settings</Typography>
<Typography component="h2">{t("settingsGeneralSettings")}</Typography>
<Typography component="p">
Here you can select the URL of the host, together with the type of
monitor.
{t("distributedUptimeCreateSelectURL")}
</Typography>
</Box>
<Stack gap={theme.spacing(20)}>
@@ -364,7 +366,7 @@ const Configure = () => {
)
}
id="monitor-url"
label="URL to monitor"
label={t("urlMonitor")}
placeholder="google.com"
value={parsedUrl?.host || monitor?.url || ""}
disabled={true}
@@ -372,7 +374,7 @@ const Configure = () => {
<TextInput
type="text"
id="monitor-name"
label="Display name"
label={t("displayName")}
isOptional={true}
placeholder="Google"
value={monitor?.name || ""}
@@ -384,13 +386,13 @@ const Configure = () => {
</ConfigBox>
<ConfigBox>
<Box>
<Typography component="h2">Incident notifications</Typography>
<Typography component="h2">{t("distributedUptimeCreateIncidentNotification")}</Typography>
<Typography component="p">
When there is an incident, notify users.
{t("distributedUptimeCreateIncidentDescription")}
</Typography>
</Box>
<Stack gap={theme.spacing(6)}>
<Typography component="p">When there is a new incident,</Typography>
<Typography component="p">{t("whenNewIncident")}</Typography>
{/* {Leaving components commented for future funtionality implimentation} */}
{/* <Checkbox
id="notify-sms"
@@ -441,12 +443,12 @@ const Configure = () => {
</ConfigBox>
<ConfigBox>
<Box>
<Typography component="h2">Advanced settings</Typography>
<Typography component="h2">{t("distributedUptimeCreateAdvancedSettings")}</Typography>
</Box>
<Stack gap={theme.spacing(20)}>
<Select
id="monitor-interval-configure"
label="Check frequency"
label={t("checkFrequency")}
value={monitor?.interval / MS_PER_MINUTE || 1}
onChange={(event) => handleChange(event, "interval")}
items={frequencies}
@@ -455,7 +457,7 @@ const Configure = () => {
<>
<Select
id="match-method"
label="Match Method"
label={t("matchMethod")}
value={monitor.matchMethod || "equal"}
onChange={(event) => handleChange(event, "matchMethod")}
items={matchMethodOptions}
@@ -464,7 +466,7 @@ const Configure = () => {
<TextInput
type="text"
id="expected-value"
label="Expected value"
label={t("expectedValue")}
isOptional={true}
placeholder={
expectedValuePlaceholders[monitor.matchMethod || "equal"]
@@ -479,8 +481,7 @@ const Configure = () => {
color={theme.palette.primary.contrastTextTertiary}
opacity={0.8}
>
The expected value is used to match against response result, and
the match determines the status.
{t("uptimeCreate")}
</Typography>
</Stack>
<Stack>
@@ -500,9 +501,7 @@ const Configure = () => {
color={theme.palette.primary.contrastTextTertiary}
opacity={0.8}
>
This expression will be evaluated against the reponse JSON data
and the result will be used to match against the expected value.
See&nbsp;
{t("uptimeCreateJsonPath")}&nbsp;
<Typography
component="a"
href="https://jmespath.org/"
@@ -511,7 +510,7 @@ const Configure = () => {
>
jmespath.org
</Typography>
&nbsp;for query language documentation.
&nbsp;{t("uptimeCreateJsonPathQuery")}
</Typography>
</Stack>
</>
@@ -530,7 +529,7 @@ const Configure = () => {
sx={{ px: theme.spacing(12) }}
onClick={handleSubmit}
>
Save
{t("settingsSave")}
</Button>
</Stack>
</Stack>
+28 -28
View File
@@ -10,7 +10,7 @@ import { checkEndpointResolution } from "../../../Features/UptimeMonitors/uptime
import { monitorValidation } from "../../../Validation/validation";
import { getUptimeMonitorById } from "../../../Features/UptimeMonitors/uptimeMonitorsSlice";
import { createUptimeMonitor } from "../../../Features/UptimeMonitors/uptimeMonitorsSlice";
import { useTranslation } from "react-i18next";
// MUI
import { Box, Stack, Typography, Button, ButtonGroup } from "@mui/material";
@@ -240,6 +240,8 @@ const CreateMonitor = () => {
fetchMonitor();
}, [monitorId, dispatch, navigate]);
const { t } = useTranslation();
return (
<Box className="create-monitor">
<Breadcrumbs list={crumbs} />
@@ -257,7 +259,7 @@ const CreateMonitor = () => {
component="span"
fontSize="inherit"
>
Create your{" "}
{t("createYour")}{" "}
</Typography>
<Typography
component="span"
@@ -265,22 +267,22 @@ const CreateMonitor = () => {
fontSize="inherit"
fontWeight="inherit"
>
monitor
{t("monitor")}
</Typography>
</Typography>
<ConfigBox>
<Box>
<Typography component="h2">Checks to perform</Typography>
<Typography component="h2">{t("distributedUptimeCreateChecks")}</Typography>
<Typography component="p">
You can always add or remove checks after adding your site.
{t("distributedUptimeCreateChecksDescription")}
</Typography>
</Box>
<Stack gap={theme.spacing(12)}>
<Stack gap={theme.spacing(6)}>
<Radio
id="monitor-checks-http"
title="Website monitoring"
desc="Use HTTP(s) to monitor your website or API endpoint."
title={t("websiteMonitoring")}
desc={t("websiteMonitoringDescription")}
size="small"
value="http"
checked={monitor.type === "http"}
@@ -293,14 +295,14 @@ const CreateMonitor = () => {
filled={https.toString()}
onClick={() => setHttps(true)}
>
HTTPS
{t("https")}
</Button>
<Button
variant="group"
filled={(!https).toString()}
onClick={() => setHttps(false)}
>
HTTP
{t("http")}
</Button>
</ButtonGroup>
) : (
@@ -309,8 +311,8 @@ const CreateMonitor = () => {
</Stack>
<Radio
id="monitor-checks-ping"
title="Ping monitoring"
desc="Check whether your server is available or not."
title={t("pingMonitoring")}
desc={t("pingMonitoringDescription")}
size="small"
value="ping"
checked={monitor.type === "ping"}
@@ -318,8 +320,8 @@ const CreateMonitor = () => {
/>
<Radio
id="monitor-checks-docker"
title="Docker container monitoring"
desc="Check whether your container is running or not."
title={t("dockerContainerMonitoring")}
desc={t("dockerContainerMonitoringDescription")}
size="small"
value="docker"
checked={monitor.type === "docker"}
@@ -327,8 +329,8 @@ const CreateMonitor = () => {
/>
<Radio
id="monitor-checks-port"
title="Port monitoring"
desc="Check whether your port is open or not."
title={t("portMonitoring")}
desc={t("portMonitoringDescription")}
size="small"
value="port"
checked={monitor.type === "port"}
@@ -351,9 +353,9 @@ const CreateMonitor = () => {
</ConfigBox>
<ConfigBox>
<Box>
<Typography component="h2">General settings</Typography>
<Typography component="h2">{t("settingsGeneralSettings")}</Typography>
<Typography component="p">
Here you can select the URL of the host, together with the type of monitor.
{t("distributedUptimeCreateSelectURL")}
</Typography>
</Box>
<Stack gap={theme.spacing(15)}>
@@ -374,7 +376,7 @@ const CreateMonitor = () => {
<TextInput
type="number"
id="monitor-port"
label="Port to monitor"
label={t("portToMonitor")}
placeholder="5173"
value={monitor.port}
onChange={(event) => handleChange(event, "port")}
@@ -385,7 +387,7 @@ const CreateMonitor = () => {
<TextInput
type="text"
id="monitor-name"
label="Display name"
label={t("displayName")}
isOptional={true}
placeholder={monitorTypeMaps[monitor.type].namePlaceholder || ""}
value={monitor.name}
@@ -397,9 +399,9 @@ const CreateMonitor = () => {
</ConfigBox>
<ConfigBox>
<Box>
<Typography component="h2">Incident notifications</Typography>
<Typography component="h2">{t("distributedUptimeCreateIncidentNotification")}</Typography>
<Typography component="p">
When there is an incident, notify users.
{t("distributedUptimeCreateIncidentDescription")}
</Typography>
</Box>
<Stack gap={theme.spacing(6)}>
@@ -427,7 +429,7 @@ const CreateMonitor = () => {
</ConfigBox>
<ConfigBox>
<Box>
<Typography component="h2">Advanced settings</Typography>
<Typography component="h2">{t("distributedUptimeCreateAdvancedSettings")}</Typography>
</Box>
<Stack gap={theme.spacing(12)}>
<Select
@@ -465,8 +467,7 @@ const CreateMonitor = () => {
color={theme.palette.primary.contrastTextTertiary}
opacity={0.8}
>
The expected value is used to match against response result, and the
match determines the status.
{t("uptimeCreate")}
</Typography>
</Stack>
<Stack>
@@ -486,8 +487,7 @@ const CreateMonitor = () => {
color={theme.palette.primary.contrastTextTertiary}
opacity={0.8}
>
This expression will be evaluated against the reponse JSON data and
the result will be used to match against the expected value. See&nbsp;
{t("uptimeCreateJsonPath")}&nbsp;
<Typography
component="a"
href="https://jmespath.org/"
@@ -496,7 +496,7 @@ const CreateMonitor = () => {
>
jmespath.org
</Typography>
&nbsp;for query language documentation.
&nbsp;{t("uptimeCreateJsonPathQuery")}
</Typography>
</Stack>
</>
@@ -514,7 +514,7 @@ const CreateMonitor = () => {
disabled={!Object.values(errors).every((value) => value === undefined)}
loading={isLoading}
>
Create monitor
{t("createMonitor")}
</Button>
</Stack>
</Stack>
@@ -1,10 +1,11 @@
import PropTypes from "prop-types";
import { useTheme } from "@mui/material";
import { ResponsiveContainer, RadialBarChart, RadialBar, Cell } from "recharts";
import { useTranslation } from "react-i18next";
const ResponseGaugeChart = ({ avgResponseTime }) => {
const theme = useTheme();
const { t } = useTranslation();
let max = 1000; // max ms
const data = [
@@ -61,7 +62,7 @@ const ResponseGaugeChart = ({ avgResponseTime }) => {
textAnchor="start"
fontSize={11}
>
low
{t("low")}
</text>
<text
x="100%"
@@ -71,7 +72,7 @@ const ResponseGaugeChart = ({ avgResponseTime }) => {
textAnchor="end"
fontSize={11}
>
high
{t("high")}
</text>
<text
x="50%"
@@ -4,6 +4,7 @@ import HistoryIcon from "../../../../../assets/icons/history-icon.svg?react";
import Table from "../../../../../Components/Table";
import TablePagination from "../../../../../Components/Table/TablePagination";
import { StatusLabel } from "../../../../../Components/Label";
import { useTranslation } from "react-i18next";
import { formatDateWithTz } from "../../../../../Utils/timeUtils";
import SkeletonLayout from "./skeleton";
const ResponseTable = ({
@@ -16,6 +17,7 @@ const ResponseTable = ({
rowsPerPage,
setRowsPerPage,
}) => {
const { t } = useTranslation();
if (!shouldRender) {
return <SkeletonLayout />;
}
@@ -23,7 +25,7 @@ const ResponseTable = ({
const headers = [
{
id: "status",
content: "Status",
content: t("status"),
render: (row) => {
const status = row.status === true ? "up" : "down";
@@ -38,18 +40,18 @@ const ResponseTable = ({
},
{
id: "date",
content: "Date & Time",
content: t("date&Time"),
render: (row) =>
formatDateWithTz(row.createdAt, "ddd, MMMM D, YYYY, HH:mm A", uiTimezone),
},
{
id: "statusCode",
content: "Status code",
content: t("statusCode"),
render: (row) => (row.statusCode ? row.statusCode : "N/A"),
},
{
id: "message",
content: "Message",
content: t("message"),
render: (row) => row.message,
},
];
+5 -3
View File
@@ -19,6 +19,7 @@ import { useIsAdmin } from "../../../Hooks/useIsAdmin";
import useMonitorFetch from "./Hooks/useMonitorFetch";
import useCertificateFetch from "./Hooks/useCertificateFetch";
import useChecksFetch from "./Hooks/useChecksFetch";
import { useTranslation } from "react-i18next";
// Constants
const BREADCRUMBS = [
@@ -46,6 +47,7 @@ const UptimeDetails = () => {
const { monitorId } = useParams();
const theme = useTheme();
const isAdmin = useIsAdmin();
const { t } = useTranslation();
const [monitor, monitorIsLoading, monitorNetworkError] = useMonitorFetch({
monitorId,
@@ -86,9 +88,9 @@ const UptimeDetails = () => {
marginY={theme.spacing(4)}
color={theme.palette.primary.contrastTextTertiary}
>
Network error
{t("networkError")}
</Typography>
<Typography>Please check your connection</Typography>
<Typography>{t("checkConnection")}</Typography>
</GenericFallback>
);
}
@@ -105,7 +107,7 @@ const UptimeDetails = () => {
monitor={monitor}
/>
<GenericFallback>
<Typography>There is no check history for this monitor yet.</Typography>
<Typography>{t("distributedUptimeDetailsNoMonitorHistory")}</Typography>
</GenericFallback>
</Stack>
);
@@ -16,6 +16,7 @@ import { useTheme } from "@emotion/react";
import useUtils from "../../Hooks/useUtils";
import { useNavigate } from "react-router-dom";
import PropTypes from "prop-types";
import { useTranslation } from "react-i18next";
/**
* UptimeDataTable displays a table of uptime monitors with sorting, searching, and action capabilities
@@ -59,6 +60,7 @@ const UptimeDataTable = ({
const navigate = useNavigate();
const { determineState } = useUtils();
const theme = useTheme();
const { t } = useTranslation();
// Local state
// Handlers
@@ -82,7 +84,7 @@ const UptimeDataTable = ({
direction="row"
onClick={() => handleSort("name")}
>
Host
{t("host")}
<Stack
justifyContent="center"
style={{
@@ -118,7 +120,7 @@ const UptimeDataTable = ({
onClick={() => handleSort("status")}
>
{" "}
Status
{t("status")}
<Stack
justifyContent="center"
style={{
@@ -146,12 +148,12 @@ const UptimeDataTable = ({
},
{
id: "responseTime",
content: "Response Time",
content: t("responseTime"),
render: (row) => <BarChart checks={row.monitor.checks.slice().reverse()} />,
},
{
id: "type",
content: "Type",
content: t("type"),
render: (row) => (
<span style={{ textTransform: "uppercase" }}>
{row.monitor.type === "http" ? "HTTP(s)" : row.monitor.type}
@@ -160,7 +162,7 @@ const UptimeDataTable = ({
},
{
id: "actions",
content: "Actions",
content: t("actions"),
render: (row) => (
<ActionsMenu
monitor={row.monitor}
+4 -2
View File
@@ -30,6 +30,7 @@ import { setRowsPerPage } from "../../../Features/UI/uiSlice";
import PropTypes from "prop-types";
import useFetchMonitorsWithSummary from "../../../Hooks/useFetchMonitorsWithSummary";
import useFetchMonitorsWithChecks from "../../../Hooks/useFetchMonitorsWithChecks";
import { useTranslation } from "react-i18next";
const BREADCRUMBS = [{ name: `Uptime`, path: "/uptime" }];
const TYPES = ["http", "ping", "docker", "port"];
@@ -75,6 +76,7 @@ const UptimeMonitors = () => {
const theme = useTheme();
const isAdmin = useIsAdmin();
const dispatch = useDispatch();
const { t } = useTranslation();
// Handlers
const handleChangePage = (event, newPage) => {
@@ -130,9 +132,9 @@ const UptimeMonitors = () => {
marginY={theme.spacing(4)}
color={theme.palette.primary.contrastTextTertiary}
>
Network error
{t("networkError")}
</Typography>
<Typography>Please check your connection</Typography>
<Typography>{t("checkConnection")}</Typography>
</GenericFallback>
);
}