-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #840 from OpenSourceBrain/feature/717
Feature/717 - confirm dialog before deleting the workspace
- Loading branch information
Showing
2 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
applications/osb-portal/src/components/dialogs/DeleteDialog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<Dialog | ||
open={open} | ||
onClose={() => setOpen(false)} | ||
> | ||
<DialogTitle>{'Delete Workspace "' + workspace.name + '"'}</DialogTitle> | ||
<DialogContent>{'You are about to delete Workspace "' + workspace.name + '". This action cannot be undone. Are you sure?'}</DialogContent> | ||
<DialogActions> | ||
<Button | ||
color="primary" | ||
onClick={() => { | ||
setOpen(false); | ||
}} | ||
> | ||
CANCEL | ||
</Button> | ||
<Button color="primary" variant="contained" onClick={handleDelete}> | ||
DELETE | ||
</Button> | ||
</DialogActions> | ||
</Dialog> | ||
) | ||
} | ||
|
||
export default DeleteDialog; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters