fix duplicate and delete row buttons not showing for read-only tables even for admins

This commit is contained in:
Sidney Alcantara
2022-03-07 19:00:09 +11:00
parent 670234b22b
commit 17c68ce1df

View File

@@ -6,6 +6,7 @@ import CopyCellsIcon from "@src/assets/icons/CopyCells";
import DeleteIcon from "@mui/icons-material/DeleteOutlined";
import { useConfirmation } from "@src/components/ConfirmationDialog/Context";
import { useAppContext } from "@src/contexts/AppContext";
import { useProjectContext } from "@src/contexts/ProjectContext";
import useKeyPress from "@src/hooks/useKeyPress";
@@ -27,6 +28,7 @@ const useStyles = makeStyles((theme) =>
export default function FinalColumn({ row }: FormatterProps<any, any>) {
useStyles();
const { userClaims } = useAppContext();
const { requestConfirmation } = useConfirmation();
const { deleteRow, addRow, table } = useProjectContext();
const altPress = useKeyPress("Alt");
@@ -35,7 +37,8 @@ export default function FinalColumn({ row }: FormatterProps<any, any>) {
if (deleteRow) deleteRow(row.id);
};
if (table?.readOnly) return null;
if (!userClaims?.roles.includes("ADMIN") && table?.readOnly === true)
return null;
return (
<Stack direction="row" spacing={0.5}>