Skip to content

Commit

Permalink
[Fix #621] Localize dialogs for renaming and deleting fault trees and…
Browse files Browse the repository at this point in the history
… systems
  • Loading branch information
kostobog committed Oct 8, 2024
1 parent a053bd3 commit e5b8479
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 16 deletions.
16 changes: 15 additions & 1 deletion public/locales/cs/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@
"namePlaceholder": "Název systému",
"create": "Vytvořit"
},
"deleteSystemModal": {
"title": "Smazat systém",
"explanation": "Smazáním systému budou smazány i všechny komponenty, funkce a režimy poruch. Pokračovat ve smazání systému?"
},
"renameSystemModal": {
"title": "Přejmenovat systém",
"nameFieldLabel": "Název systému"
},
"newFtaModal": {
"title": "Vytvořit strom poruch",
"namePlaceholder": "Systém",
Expand All @@ -34,6 +42,10 @@
"gateType": "Typ hradla",
"noSystemError": "Na panelu Navigační panel vyberte možnost Systém"
},
"renameFtaModal": {
"title": "Přejmenujte strom poruch",
"nameFieldLabel": "Název stromu poruch"
},
"deleteFtaModal": {
"title": "Smazat strom poruch",
"explanation": "Smazáním stromu chyb se smaže celá stromová struktura. Pokračovat ve smazání stromu?"
Expand Down Expand Up @@ -141,7 +153,9 @@
"delete": "Smazat",
"rename": "Přejmenovat",
"save": "Uložit",
"discard": "Zahodit"
"discard": "Zahodit",
"cancel": "Zrušit",
"confirm": "Potvrdit"
},

"error": {
Expand Down
16 changes: 15 additions & 1 deletion public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@
"namePlaceholder": "System name",
"create": "Create"
},
"deleteSystemModal": {
"title": "Delete System",
"explanation": "By deleting the system, all components, functions and failure modes will be deleted as well. Proceed to delete the system?"
},
"renameSystemModal": {
"title": "Rename System",
"nameFieldLabel": "System Name"
},
"newFtaModal": {
"title": "Create Fault Tree",
"namePlaceholder": "System",
Expand All @@ -34,6 +42,10 @@
"gateType": "Gate type",
"noSystemError": "Select the System from the Navbar"
},
"renameFtaModal": {
"title": "Rename Fault Tree",
"nameFieldLabel": "Fault Tree Name"
},
"deleteFtaModal": {
"title": "Delete Fault Tree",
"explanation": "Deleting fault tree will delete the whole tree structure. Proceed to delete the tree?"
Expand Down Expand Up @@ -141,7 +153,9 @@
"delete": "Delete",
"rename": "Rename",
"save": "Save",
"discard": "Discard"
"discard": "Discard",
"cancel": "Cancel",
"confirm": "Confirm"
},
"error": {
"default": "An error occurred",
Expand Down
7 changes: 4 additions & 3 deletions src/components/dashboard/content/list/DashboardSystemList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ import { System } from "@models/systemModel";
import SystemEditDialog from "@components/dialog/system/SystemEditDialog";
import { contextMenuDefaultAnchor, ElementContextMenuAnchor } from "@utils/contextMenu";
import SystemContextMenu from "@components/editor/system/menu/SystemContextMenu";
import { useTranslation } from "react-i18next";

const DashboardSystemList = () => {
const { t } = useTranslation();
const { classes } = useStyles();
const [systems, , , removeSystem] = useSystems();

Expand All @@ -39,9 +41,8 @@ const DashboardSystemList = () => {

const handleDelete = (systemToDelete: System) => {
showConfirmDialog({
title: "Delete System",
explanation:
"By deleting the system, all components, functions and failure modes will be deleted as well. Proceed to delete the system?",
title: t("deleteSystemModal.title"),
explanation: t("deleteSystemModal.explanation"),
onConfirm: () => {
removeSystem(systemToDelete);
},
Expand Down
5 changes: 2 additions & 3 deletions src/components/dashboard/content/list/SystemOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ const SystemOverview = () => {

const handleDelete = (systemToDelete: System) => {
showConfirmDialog({
title: "Delete System",
explanation:
"By deleting the system, all components, functions and failure modes will be deleted as well. Proceed to delete the system?",
title: t("deleteSystemModal.title"),
explanation: t("deleteSystemModal.explanation"),
onConfirm: () => {
removeSystem(systemToDelete);
},
Expand Down
6 changes: 4 additions & 2 deletions src/components/dialog/ConfirmDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Dialog from "@mui/material/Dialog";
import { DialogTitle } from "@components/materialui/dialog/DialogTitle";
import { DialogContent } from "@components/materialui/dialog/DialogContent";
import { DialogActions } from "@components/materialui/dialog/DialogActions";
import { useTranslation } from "react-i18next";

interface Props {
title: string;
Expand All @@ -14,6 +15,7 @@ interface Props {
}

const ConfirmDialog = ({ title, explanation, open, onClose, onConfirm }: Props) => {
const { t } = useTranslation();
return (
<Dialog open={open} onClose={onClose} aria-labelledby="confirm-dialog">
<DialogTitle id="confirm-dialog" onClose={onClose}>
Expand All @@ -22,7 +24,7 @@ const ConfirmDialog = ({ title, explanation, open, onClose, onConfirm }: Props)
<DialogContent>{explanation}</DialogContent>
<DialogActions>
<Button color="primary" onClick={onClose}>
Cancel
{t("common.cancel")}
</Button>
<Button
color="primary"
Expand All @@ -31,7 +33,7 @@ const ConfirmDialog = ({ title, explanation, open, onClose, onConfirm }: Props)
onConfirm();
}}
>
Confirm
{t("common.confirm")}
</Button>
</DialogActions>
</Dialog>
Expand Down
8 changes: 5 additions & 3 deletions src/components/dialog/faultTree/FaultTreeEditDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { DialogActions } from "@components/materialui/dialog/DialogActions";
import { useFaultTrees } from "@hooks/useFaultTrees";
import { FaultTree } from "@models/faultTreeModel";
import { yupResolver } from "@hookform/resolvers/yup";
import { useTranslation } from "react-i18next";

interface Props {
open: boolean;
Expand All @@ -18,6 +19,7 @@ interface Props {
}

const FaultTreeEditDialog = ({ open, handleCloseDialog, faultTree }: Props) => {
const { t } = useTranslation();
const [, , updateTree] = useFaultTrees();
const [processing, setIsProcessing] = useState(false);

Expand Down Expand Up @@ -46,13 +48,13 @@ const FaultTreeEditDialog = ({ open, handleCloseDialog, faultTree }: Props) => {
return (
<Dialog open={open} onClose={handleCloseDialog} aria-labelledby="tree-edit-dialog-title" maxWidth="md" fullWidth>
<DialogTitle id="tree-edit-dialog-title" onClose={handleCloseDialog}>
Edit Fault Tree
{t("renameFtaModal.title")}
</DialogTitle>
<DialogContent dividers>
<TextField
autoFocus
margin="dense"
label="Fault Tree Name"
label={t("renameFtaModal.nameFieldLabel")}
name="faultTreeName"
type="text"
fullWidth
Expand All @@ -62,7 +64,7 @@ const FaultTreeEditDialog = ({ open, handleCloseDialog, faultTree }: Props) => {
</DialogContent>
<DialogActions>
<Button disabled={processing} color="primary" onClick={handleSubmit(handleCreateFaultTree)}>
Save Fault Tree
{t("common.rename")}
</Button>
</DialogActions>
</Dialog>
Expand Down
8 changes: 5 additions & 3 deletions src/components/dialog/system/SystemEditDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { yupResolver } from "@hookform/resolvers/yup";
import { System } from "@models/systemModel";
import { useSystems } from "@hooks/useSystems";
import { schema } from "./SystemDialog.schema";
import { useTranslation } from "react-i18next";

interface Props {
open: boolean;
Expand All @@ -18,6 +19,7 @@ interface Props {
}

const SystemEditDialog = ({ open, handleCloseDialog, system }: Props) => {
const { t } = useTranslation();
const [, , updateSystem] = useSystems();
const [processing, setIsProcessing] = useState(false);

Expand Down Expand Up @@ -51,13 +53,13 @@ const SystemEditDialog = ({ open, handleCloseDialog, system }: Props) => {
return (
<Dialog open={open} onClose={handleCloseDialog} aria-labelledby="system-edit-dialog-title" maxWidth="md" fullWidth>
<DialogTitle id="system-edit-dialog-title" onClose={handleCloseDialog}>
Edit System
{t("renameSystemModal.title")}
</DialogTitle>
<DialogContent dividers>
<TextField
autoFocus
margin="dense"
label="System Name"
label={t("renameSystemModal.nameFieldLabel")}
name="systemName"
type="text"
fullWidth
Expand All @@ -67,7 +69,7 @@ const SystemEditDialog = ({ open, handleCloseDialog, system }: Props) => {
</DialogContent>
<DialogActions>
<Button disabled={processing} color="primary" onClick={handleSubmit(handleUpdateSystem)}>
Save System
{t("common.rename")}
</Button>
</DialogActions>
</Dialog>
Expand Down

0 comments on commit e5b8479

Please sign in to comment.