From a2a7bafe1969a110c5843d0de7c74a6afbff35dc Mon Sep 17 00:00:00 2001 From: "D. Gopal Krishna" Date: Thu, 7 Dec 2023 18:43:50 +0530 Subject: [PATCH 1/2] #717 confirm dialog before deleting the workspace --- .../src/components/dialogs/DeleteDialog.tsx | 51 +++++++++++++++++++ .../workspace/WorkspaceActionsMenu.tsx | 19 ++++++- 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 applications/osb-portal/src/components/dialogs/DeleteDialog.tsx diff --git a/applications/osb-portal/src/components/dialogs/DeleteDialog.tsx b/applications/osb-portal/src/components/dialogs/DeleteDialog.tsx new file mode 100644 index 00000000..77c3ca31 --- /dev/null +++ b/applications/osb-portal/src/components/dialogs/DeleteDialog.tsx @@ -0,0 +1,51 @@ +import React from 'react'; +import DialogTitle from "@mui/material/DialogTitle"; +import DialogContent from "@mui/material/DialogContent"; +import DialogActions from "@mui/material/DialogActions"; +import Dialog from "@mui/material/Dialog"; +import { + useNavigate, +} from "react-router-dom"; +import { Button } from "@mui/material"; + + +const DeleteDialog = ({ + open, + setOpen, + workspace, + handleDeleteWorkspace, +}) => { + const navigate = useNavigate(); + + const handleDelete = () => { + handleDeleteWorkspace(); + if (window.location.pathname !== "/") { + navigate("/"); + } + } + + return ( + setOpen(false)} + > + {'Delete Workspace ' + workspace.name} + {'You are about to delete Workspace ' + workspace.name + '. This action cannot be undone. Are you sure?'} + + + + + + ) +} + +export default DeleteDialog; \ No newline at end of file diff --git a/applications/osb-portal/src/components/workspace/WorkspaceActionsMenu.tsx b/applications/osb-portal/src/components/workspace/WorkspaceActionsMenu.tsx index 7484b913..b0cb8f91 100644 --- a/applications/osb-portal/src/components/workspace/WorkspaceActionsMenu.tsx +++ b/applications/osb-portal/src/components/workspace/WorkspaceActionsMenu.tsx @@ -18,6 +18,7 @@ import OSBLoader from "../common/OSBLoader"; import { bgDarkest, textColor, lightWhite } from "../../theme"; import MoreHorizIcon from "@mui/icons-material/MoreHoriz"; import * as Icons from "../icons"; +import DeleteDialog from "../dialogs/DeleteDialog"; interface WorkspaceActionsMenuProps { @@ -51,6 +52,7 @@ export default (props: WorkspaceActionsMenuProps) => { const [anchorEl, setAnchorEl] = React.useState(null); const canEdit = canEditWorkspace(props?.user, props?.workspace); const navigate = useNavigate(); + const [showDeleteWorkspaceDialog, setShowDeleteWorkspaceDialog] = React.useState(false); const handleClick = (event: React.MouseEvent) => { @@ -210,7 +212,10 @@ export default (props: WorkspaceActionsMenuProps) => { {canEdit && ( { + setShowDeleteWorkspaceDialog(true); + setAnchorEl(null); + }} > Delete @@ -261,6 +266,18 @@ export default (props: WorkspaceActionsMenuProps) => { } /> + <> + { + showDeleteWorkspaceDialog && ( + + ) + } + ); }; From f0cd406420f57d49995ddc6013e4c4ed4c245233 Mon Sep 17 00:00:00 2001 From: "D. Gopal Krishna" Date: Fri, 8 Dec 2023 15:23:54 +0530 Subject: [PATCH 2/2] #717 double quotes to workspace name in dialog --- .../osb-portal/src/components/dialogs/DeleteDialog.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/osb-portal/src/components/dialogs/DeleteDialog.tsx b/applications/osb-portal/src/components/dialogs/DeleteDialog.tsx index 77c3ca31..477e2c89 100644 --- a/applications/osb-portal/src/components/dialogs/DeleteDialog.tsx +++ b/applications/osb-portal/src/components/dialogs/DeleteDialog.tsx @@ -29,8 +29,8 @@ const DeleteDialog = ({ open={open} onClose={() => setOpen(false)} > - {'Delete Workspace ' + workspace.name} - {'You are about to delete Workspace ' + workspace.name + '. This action cannot be undone. Are you sure?'} + {'Delete Workspace "' + workspace.name + '"'} + {'You are about to delete Workspace "' + workspace.name + '". This action cannot be undone. Are you sure?'}