Skip to content

Commit a4d1f21

Browse files
authored
Merge pull request #1945 from Br0wnHammer/feat/fe/migrate-hardcoded-strings
Feat: Migrate Hardcoded Strings
2 parents 9b769fe + 66bc2a8 commit a4d1f21

File tree

30 files changed

+339
-191
lines changed

30 files changed

+339
-191
lines changed

src/Pages/Maintenance/CreateMaintenance/index.jsx

+19-17
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
} from "../../../Utils/timeUtils";
2929
import { useNavigate, useParams } from "react-router-dom";
3030
import { buildErrors, hasValidationErrors } from "../../../Validation/error";
31+
import { useTranslation } from "react-i18next";
3132

3233
const getDurationAndUnit = (durationInMs) => {
3334
if (durationInMs % MS_PER_DAY === 0) {
@@ -113,6 +114,7 @@ const CreateMaintenance = () => {
113114
const { maintenanceWindowId } = useParams();
114115
const navigate = useNavigate();
115116
const theme = useTheme();
117+
const { t } = useTranslation();
116118
const { user } = useSelector((state) => state.auth);
117119
const [monitors, setMonitors] = useState([]);
118120
const [search, setSearch] = useState("");
@@ -293,29 +295,29 @@ const CreateMaintenance = () => {
293295
component="span"
294296
fontSize="inherit"
295297
>
296-
{`${maintenanceWindowId === undefined ? "Create a" : "Edit"}`}{" "}
298+
{`${maintenanceWindowId === undefined ? t("createA") : t("edit")}`}{" "}
297299
</Typography>
298300
<Typography
299301
component="span"
300302
variant="h2"
301303
fontSize="inherit"
302304
fontWeight="inherit"
303305
>
304-
maintenance{" "}
306+
{t("maintenance")}{" "}
305307
</Typography>
306308
<Typography
307309
component="span"
308310
fontSize="inherit"
309311
>
310-
window
312+
{t("window")}
311313
</Typography>
312314
</Typography>
313315
<Typography
314316
component="h2"
315317
variant="body2"
316318
fontSize={14}
317319
>
318-
Your pings won&apos;t be sent during this time frame
320+
{t("maintenanceWindowDescription")}
319321
</Typography>
320322
</Box>
321323
<ConfigBox>
@@ -324,14 +326,14 @@ const CreateMaintenance = () => {
324326
component="h2"
325327
variant="h2"
326328
>
327-
General Settings
329+
{t("settingsGeneralSettings")}
328330
</Typography>
329331
</Box>
330332
<Stack gap={theme.spacing(15)}>
331333
<TextInput
332334
id="name"
333-
label="Friendly name"
334-
placeholder="Maintenance at __ : __ for ___ minutes"
335+
label={t("friendlyNameInput")}
336+
placeholder={t("friendlyNamePlaceholder")}
335337
value={form.name}
336338
onChange={(event) => {
337339
handleFormChange("name", event.target.value);
@@ -342,7 +344,7 @@ const CreateMaintenance = () => {
342344
<Select
343345
id="repeat"
344346
name="maintenance-repeat"
345-
label="Maintenance Repeat"
347+
label={t("maintenanceRepeat")}
346348
value={getIdByValue(repeatConfig, form.repeat)}
347349
onChange={(event) => {
348350
handleFormChange(
@@ -437,15 +439,15 @@ const CreateMaintenance = () => {
437439
component="h2"
438440
variant="h2"
439441
>
440-
Start time
442+
{t("startTime")}
441443
</Typography>
442-
<Typography>All dates and times are in GMT+0 time zone.</Typography>
444+
<Typography>{t("timeZoneInfo")}</Typography>
443445
</Box>
444446
<Stack gap={theme.spacing(15)}>
445447
<LocalizationProvider dateAdapter={AdapterDayjs}>
446448
<MobileTimePicker
447449
id="startTime"
448-
label="Start time"
450+
label={t("startTime")}
449451
value={form.startTime}
450452
onChange={(newTime) => {
451453
handleTimeChange("startTime", newTime);
@@ -486,7 +488,7 @@ const CreateMaintenance = () => {
486488
<TextInput
487489
type="number"
488490
id="duration"
489-
label="Duration"
491+
label={t("duration")}
490492
value={form.duration}
491493
onChange={(event) => {
492494
handleFormChange("duration", event.target.value);
@@ -516,13 +518,13 @@ const CreateMaintenance = () => {
516518
component="h2"
517519
variant="h2"
518520
>
519-
Monitors to apply maintenance window to
521+
{t("monitorsToApply")}
520522
</Typography>
521523
</Box>
522524
<Stack gap={theme.spacing(15)}>
523525
<Search
524526
id={"monitors"}
525-
label="Add monitors"
527+
label={t("addMonitors")}
526528
multiple={true}
527529
isAdorned={false}
528530
options={monitors ? monitors : []}
@@ -547,7 +549,7 @@ const CreateMaintenance = () => {
547549
onClick={() => navigate("/maintenance")}
548550
sx={{ mr: theme.spacing(6) }}
549551
>
550-
Cancel
552+
{t("cancel")}
551553
</Button>
552554
<Button
553555
loading={isLoading}
@@ -558,8 +560,8 @@ const CreateMaintenance = () => {
558560
>
559561
{`${
560562
maintenanceWindowId === undefined
561-
? "Create maintenance"
562-
: "Edit maintenance"
563+
? t("createMaintenance")
564+
: t("editMaintenance")
563565
}`}
564566
</Button>
565567
</Box>

src/Pages/Maintenance/MaintenanceTable/ActionsMenu/index.jsx

+7-5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import Settings from "../../../../assets/icons/settings-bold.svg?react";
88
import PropTypes from "prop-types";
99
import { networkService } from "../../../../main";
1010
import { createToast } from "../../../../Utils/toastUtils";
11+
import { useTranslation } from "react-i18next";
1112

1213
import Dialog from "../../../../Components/Dialog";
1314

@@ -18,6 +19,7 @@ const ActionsMenu = ({ /* isAdmin, */ maintenanceWindow, updateCallback }) => {
1819
const [isLoading, setIsLoading] = useState(false);
1920

2021
const theme = useTheme();
22+
const { t } = useTranslation();
2123

2224
const handleRemove = async (event) => {
2325
event.preventDefault();
@@ -124,7 +126,7 @@ const ActionsMenu = ({ /* isAdmin, */ maintenanceWindow, updateCallback }) => {
124126
handleEdit();
125127
}}
126128
>
127-
Edit
129+
{t("edit")}
128130
</MenuItem>
129131
<MenuItem
130132
onClick={(e) => {
@@ -133,7 +135,7 @@ const ActionsMenu = ({ /* isAdmin, */ maintenanceWindow, updateCallback }) => {
133135
e.stopPropagation();
134136
}}
135137
>
136-
{`${maintenanceWindow.active === true ? "Pause" : "Resume"}`}
138+
{`${maintenanceWindow.active === true ? t("pause") : t("resume")}`}
137139
</MenuItem>
138140

139141
<MenuItem
@@ -142,18 +144,18 @@ const ActionsMenu = ({ /* isAdmin, */ maintenanceWindow, updateCallback }) => {
142144
openRemove(e);
143145
}}
144146
>
145-
Remove
147+
{t("remove")}
146148
</MenuItem>
147149
</Menu>
148150
<Dialog
149151
open={isOpen}
150152
theme={theme}
151-
title={"Do you really want to remove this maintenance window?"}
153+
title={t("maintenanceTableActionMenuDialogTitle")}
152154
onCancel={(e) => {
153155
e.stopPropagation();
154156
setIsOpen(false);
155157
}}
156-
confirmationButtonLabel={"Delete"}
158+
confirmationButtonLabel={t("delete")}
157159
onConfirm={(e) => {
158160
e.stopPropagation(e);
159161
handleRemove(e);

src/Pages/Maintenance/MaintenanceTable/index.jsx

+8-5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { useDispatch, useSelector } from "react-redux";
1010
import { formatDurationRounded } from "../../../Utils/timeUtils";
1111
import { StatusLabel } from "../../../Components/Label";
1212
import { setRowsPerPage } from "../../../Features/UI/uiSlice";
13+
import { useTranslation } from "react-i18next";
1314
import dayjs from "dayjs";
1415
/**
1516
* Component for pagination actions (first, previous, next, last).
@@ -49,13 +50,15 @@ const MaintenanceTable = ({
4950
);
5051
setPage(0);
5152
};
53+
54+
const { t } = useTranslation();
5255

5356
const headers = [
5457
{
5558
id: "name",
5659
content: (
5760
<Box onClick={() => handleSort("name")}>
58-
Maintenance Window Name
61+
{t("maintenanceWindowName")}
5962
<span
6063
style={{
6164
visibility: sort.field === "name" ? "visible" : "hidden",
@@ -76,7 +79,7 @@ const MaintenanceTable = ({
7679
content: (
7780
<Box onClick={() => handleSort("status")}>
7881
{" "}
79-
Status
82+
{t("status")}
8083
<span
8184
style={{
8285
visibility: sort.field === "active" ? "visible" : "hidden",
@@ -105,21 +108,21 @@ const MaintenanceTable = ({
105108
},
106109
{
107110
id: "nextWindow",
108-
content: "Next window",
111+
content: t("nextWindow"),
109112
render: (row) => {
110113
return getTimeToNextWindow(row.start, row.end, row.repeat);
111114
},
112115
},
113116
{
114117
id: "repeat",
115-
content: "Repeat",
118+
content: t("repeat"),
116119
render: (row) => {
117120
return row.repeat === 0 ? "N/A" : formatDurationRounded(row.repeat);
118121
},
119122
},
120123
{
121124
id: "actions",
122-
content: "Actions",
125+
content: t("actions"),
123126
render: (row) => (
124127
<ActionsMenu
125128
maintenanceWindow={row}

src/Pages/Maintenance/index.jsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ import { networkService } from "../../main";
99
import Breadcrumbs from "../../Components/Breadcrumbs";
1010
import { useNavigate } from "react-router-dom";
1111
import { useIsAdmin } from "../../Hooks/useIsAdmin";
12+
import { useTranslation } from "react-i18next";
1213

1314
const Maintenance = () => {
1415
const theme = useTheme();
16+
const { t } = useTranslation();
1517
const navigate = useNavigate();
1618
const { rowsPerPage } = useSelector((state) => state.ui.maintenance);
1719
const isAdmin = useIsAdmin();
@@ -74,7 +76,7 @@ const Maintenance = () => {
7476
}}
7577
sx={{ fontWeight: 500 }}
7678
>
77-
Create maintenance window
79+
{t("createMaintenanceWindow")}
7880
</Button>
7981
</Stack>
8082
<MaintenanceTable

src/Pages/NotFound/index.jsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import NotFoundSvg from "../../../src/assets/Images/sushi_404.svg";
44
import { Button, Stack, Typography } from "@mui/material";
55
import { useNavigate } from "react-router";
66
import { useTheme } from "@emotion/react";
7+
import { useTranslation } from "react-i18next";
78

89
/**
910
* Support for defaultProps will be removed from function components in a future major release
@@ -33,6 +34,7 @@ const DefaultValue = {
3334
const NotFound = ({ title = DefaultValue.title, desc = DefaultValue.desc }) => {
3435
const navigate = useNavigate();
3536
const theme = useTheme();
37+
const { t } = useTranslation();
3638

3739
return (
3840
<Stack
@@ -62,7 +64,7 @@ const NotFound = ({ title = DefaultValue.title, desc = DefaultValue.desc }) => {
6264
sx={{ mt: theme.spacing(10) }}
6365
onClick={() => navigate("/")}
6466
>
65-
Go to the main dashboard
67+
{t("notFoundButton")}
6668
</Button>
6769
</Stack>
6870
</Stack>

0 commit comments

Comments
 (0)