Skip to content

Commit

Permalink
Merge pull request #553 from kbss-cvut/fix/small-ui-fixes
Browse files Browse the repository at this point in the history
Small UI fixes
  • Loading branch information
blcham authored Aug 16, 2024
2 parents e1f95b0 + dd4dae4 commit 0c741d0
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 8 deletions.
4 changes: 4 additions & 0 deletions public/locales/cs/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@
"lastEditor": "Poslední editor",
"status": "Stav",
"edit": "Upravit",
"renameHint": "Změnit jméno stromu poruch",
"renameDisabledHint": "Stromy poruch založené na FHA nelze přejmenovat.",
"deleteHint": "Smazat strom poruch",
"created": "Vytvořeno",
"operationalHours": "Doba provozu"
},
Expand All @@ -110,6 +113,7 @@
"common": {
"defaultErrorMsg": "Došlo k neočekávané chybě",
"delete": "Smazat",
"rename": "Přejmenovat",
"save": "Uložit",
"discard": "Zahodit"
}
Expand Down
4 changes: 4 additions & 0 deletions public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@
"lastEditor": "Last editor",
"status": "Status",
"edit": "Edit",
"renameHint": "Change fault tree label",
"renameDisabledHint": "FHA-based fault trees cannot be renamed.",
"deleteHint": "Delete fault tree",
"created": "Created",
"operationalHours": "Operational Hours"
},
Expand All @@ -110,6 +113,7 @@
"common": {
"defaultErrorMsg": "Unexpected error occurred",
"delete": "Delete",
"rename": "Rename",
"save": "Save",
"discard": "Discard"
}
Expand Down
4 changes: 4 additions & 0 deletions src/components/dashboard/content/list/FaultTreeOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ const FaultTreeOverview = () => {
onDelete={() => handleDelete(contextMenuSelectedTree)}
onClose={() => setContextMenuAnchor(contextMenuDefaultAnchor)}
canRename={canRename}
renameTooltip={
canRename ? t("faultTreeOverviewTable.renameHint") : t("faultTreeOverviewTable.renameDisabledHint")
}
deleteTooltip={t("faultTreeOverviewTable.deleteHint")}
/>

<FaultTreeEditDialog
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
import * as React from "react";
import { Menu, MenuItem } from "@mui/material";
import { ElementContextMenuAnchor } from "../../../../../utils/contextMenu";
import { useTranslation } from "react-i18next";

interface Props {
anchorPosition: ElementContextMenuAnchor;
onEditClick: () => void;
onDelete: () => void;
onClose: () => void;
canRename: boolean;
renameTooltip: string;
deleteTooltip?: string;
}

const FaultTreeContextMenu = ({ anchorPosition, onClose, onEditClick, onDelete, canRename }: Props) => {
const FaultTreeContextMenu = ({
anchorPosition,
onClose,
onEditClick,
onDelete,
canRename,
renameTooltip,
deleteTooltip,
}: Props) => {
const { t } = useTranslation();
const handleEditClick = () => {
onClose();
onEditClick();
Expand All @@ -36,12 +48,16 @@ const FaultTreeContextMenu = ({ anchorPosition, onClose, onEditClick, onDelete,
: undefined
}
>
<MenuItem disabled={!canRename} key="fault-tree-menu-rename" onClick={handleEditClick}>
Rename
</MenuItem>
<MenuItem key="fault-tree-delete" onClick={handleDeleteClick}>
Delete
</MenuItem>
<span title={renameTooltip ? renameTooltip : t("common.rename")}>
<MenuItem disabled={!canRename} key="fault-tree-menu-rename" onClick={handleEditClick}>
{t("common.rename")}
</MenuItem>
</span>
<span title={deleteTooltip ? deleteTooltip : t("common.delete")}>
<MenuItem key="fault-tree-delete" onClick={handleDeleteClick}>
{t("common.delete")}
</MenuItem>
</span>
</Menu>
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/table/FaultTreeTableBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const FaultTreeTableBody: FC<FaultTreeTableBodyProps> = ({ faultTrees, handleFau
<>
{faultTrees.map((faultTree, rowIndex) => {
const routePath = ROUTES.FTA + `/${extractFragment(faultTree.iri)}`;
const statusColor = faultTree?.status !== Status.OK ? "red" : "white";
const statusColor = faultTree?.status !== Status.OK ? "red" : "black";
const editor = faultTree?.editor || faultTree?.creator;
return (
<TableRow key={rowIndex} className={classes.noBorder}>
Expand Down

0 comments on commit 0c741d0

Please sign in to comment.