Skip to content

Feat: Migrate Hardcoded Strings #1945

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions src/Pages/Maintenance/CreateMaintenance/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
} from "../../../Utils/timeUtils";
import { useNavigate, useParams } from "react-router-dom";
import { buildErrors, hasValidationErrors } from "../../../Validation/error";
import { useTranslation } from "react-i18next";

const getDurationAndUnit = (durationInMs) => {
if (durationInMs % MS_PER_DAY === 0) {
Expand Down Expand Up @@ -113,6 +114,7 @@ const CreateMaintenance = () => {
const { maintenanceWindowId } = useParams();
const navigate = useNavigate();
const theme = useTheme();
const { t } = useTranslation();
const { user } = useSelector((state) => state.auth);
const [monitors, setMonitors] = useState([]);
const [search, setSearch] = useState("");
Expand Down Expand Up @@ -293,29 +295,29 @@ const CreateMaintenance = () => {
component="span"
fontSize="inherit"
>
{`${maintenanceWindowId === undefined ? "Create a" : "Edit"}`}{" "}
{`${maintenanceWindowId === undefined ? t("createA") : t("edit")}`}{" "}
</Typography>
<Typography
component="span"
variant="h2"
fontSize="inherit"
fontWeight="inherit"
>
maintenance{" "}
{t("maintenance")}{" "}
</Typography>
<Typography
component="span"
fontSize="inherit"
>
window
{t("window")}
</Typography>
</Typography>
<Typography
component="h2"
variant="body2"
fontSize={14}
>
Your pings won&apos;t be sent during this time frame
{t("maintenanceWindowDescription")}
</Typography>
</Box>
<ConfigBox>
Expand All @@ -324,14 +326,14 @@ const CreateMaintenance = () => {
component="h2"
variant="h2"
>
General Settings
{t("settingsGeneralSettings")}
</Typography>
</Box>
<Stack gap={theme.spacing(15)}>
<TextInput
id="name"
label="Friendly name"
placeholder="Maintenance at __ : __ for ___ minutes"
label={t("friendlyNameInput")}
placeholder={t("friendlyNamePlaceholder")}
value={form.name}
onChange={(event) => {
handleFormChange("name", event.target.value);
Expand All @@ -342,7 +344,7 @@ const CreateMaintenance = () => {
<Select
id="repeat"
name="maintenance-repeat"
label="Maintenance Repeat"
label={t("maintenanceRepeat")}
value={getIdByValue(repeatConfig, form.repeat)}
onChange={(event) => {
handleFormChange(
Expand Down Expand Up @@ -437,15 +439,15 @@ const CreateMaintenance = () => {
component="h2"
variant="h2"
>
Start time
{t("startTime")}
</Typography>
<Typography>All dates and times are in GMT+0 time zone.</Typography>
<Typography>{t("timeZoneInfo")}</Typography>
</Box>
<Stack gap={theme.spacing(15)}>
<LocalizationProvider dateAdapter={AdapterDayjs}>
<MobileTimePicker
id="startTime"
label="Start time"
label={t("startTime")}
value={form.startTime}
onChange={(newTime) => {
handleTimeChange("startTime", newTime);
Expand Down Expand Up @@ -486,7 +488,7 @@ const CreateMaintenance = () => {
<TextInput
type="number"
id="duration"
label="Duration"
label={t("duration")}
value={form.duration}
onChange={(event) => {
handleFormChange("duration", event.target.value);
Expand Down Expand Up @@ -516,13 +518,13 @@ const CreateMaintenance = () => {
component="h2"
variant="h2"
>
Monitors to apply maintenance window to
{t("monitorsToApply")}
</Typography>
</Box>
<Stack gap={theme.spacing(15)}>
<Search
id={"monitors"}
label="Add monitors"
label={t("addMonitors")}
multiple={true}
isAdorned={false}
options={monitors ? monitors : []}
Expand All @@ -547,7 +549,7 @@ const CreateMaintenance = () => {
onClick={() => navigate("/maintenance")}
sx={{ mr: theme.spacing(6) }}
>
Cancel
{t("cancel")}
</Button>
<Button
loading={isLoading}
Expand All @@ -558,8 +560,8 @@ const CreateMaintenance = () => {
>
{`${
maintenanceWindowId === undefined
? "Create maintenance"
: "Edit maintenance"
? t("createMaintenance")
: t("editMaintenance")
}`}
</Button>
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Settings from "../../../../assets/icons/settings-bold.svg?react";
import PropTypes from "prop-types";
import { networkService } from "../../../../main";
import { createToast } from "../../../../Utils/toastUtils";
import { useTranslation } from "react-i18next";

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

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

const theme = useTheme();
const { t } = useTranslation();

const handleRemove = async (event) => {
event.preventDefault();
Expand Down Expand Up @@ -124,7 +126,7 @@ const ActionsMenu = ({ /* isAdmin, */ maintenanceWindow, updateCallback }) => {
handleEdit();
}}
>
Edit
{t("edit")}
</MenuItem>
<MenuItem
onClick={(e) => {
Expand All @@ -142,7 +144,7 @@ const ActionsMenu = ({ /* isAdmin, */ maintenanceWindow, updateCallback }) => {
openRemove(e);
}}
>
Remove
{t("remove")}
</MenuItem>
</Menu>
<Dialog
Expand Down
13 changes: 8 additions & 5 deletions src/Pages/Maintenance/MaintenanceTable/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useDispatch, useSelector } from "react-redux";
import { formatDurationRounded } from "../../../Utils/timeUtils";
import { StatusLabel } from "../../../Components/Label";
import { setRowsPerPage } from "../../../Features/UI/uiSlice";
import { useTranslation } from "react-i18next";
import dayjs from "dayjs";
/**
* Component for pagination actions (first, previous, next, last).
Expand Down Expand Up @@ -49,13 +50,15 @@ const MaintenanceTable = ({
);
setPage(0);
};

const { t } = useTranslation();

const headers = [
{
id: "name",
content: (
<Box onClick={() => handleSort("name")}>
Maintenance Window Name
{t("maintenanceWindowName")}
<span
style={{
visibility: sort.field === "name" ? "visible" : "hidden",
Expand All @@ -76,7 +79,7 @@ const MaintenanceTable = ({
content: (
<Box onClick={() => handleSort("status")}>
{" "}
Status
{t("status")}
<span
style={{
visibility: sort.field === "active" ? "visible" : "hidden",
Expand Down Expand Up @@ -105,21 +108,21 @@ const MaintenanceTable = ({
},
{
id: "nextWindow",
content: "Next window",
content: t("nextWindow"),
render: (row) => {
return getTimeToNextWindow(row.start, row.end, row.repeat);
},
},
{
id: "repeat",
content: "Repeat",
content: t("repeat"),
render: (row) => {
return row.repeat === 0 ? "N/A" : formatDurationRounded(row.repeat);
},
},
{
id: "actions",
content: "Actions",
content: t("actions"),
render: (row) => (
<ActionsMenu
maintenanceWindow={row}
Expand Down
4 changes: 3 additions & 1 deletion src/Pages/Maintenance/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import { networkService } from "../../main";
import Breadcrumbs from "../../Components/Breadcrumbs";
import { useNavigate } from "react-router-dom";
import { useIsAdmin } from "../../Hooks/useIsAdmin";
import { useTranslation } from "react-i18next";

const Maintenance = () => {
const theme = useTheme();
const { t } = useTranslation();
const navigate = useNavigate();
const { rowsPerPage } = useSelector((state) => state.ui.maintenance);
const isAdmin = useIsAdmin();
Expand Down Expand Up @@ -74,7 +76,7 @@ const Maintenance = () => {
}}
sx={{ fontWeight: 500 }}
>
Create maintenance window
{t("createMaintenanceWindow")}
</Button>
</Stack>
<MaintenanceTable
Expand Down
4 changes: 3 additions & 1 deletion src/Pages/NotFound/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import NotFoundSvg from "../../../src/assets/Images/sushi_404.svg";
import { Button, Stack, Typography } from "@mui/material";
import { useNavigate } from "react-router";
import { useTheme } from "@emotion/react";
import { useTranslation } from "react-i18next";

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

return (
<Stack
Expand Down Expand Up @@ -62,7 +64,7 @@ const NotFound = ({ title = DefaultValue.title, desc = DefaultValue.desc }) => {
sx={{ mt: theme.spacing(10) }}
onClick={() => navigate("/")}
>
Go to the main dashboard
{t("notFoundButton")}
</Button>
</Stack>
</Stack>
Expand Down
Loading