Skip to content

Commit 22ff35c

Browse files
authored
Merge pull request Azure#134 from kairu-ms/feature-hidden-delete-icon
Add delete confirmation for workspace delete
2 parents f60705f + 6591357 commit 22ff35c

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

src/web/src/views/workspace/WSEditor.tsx

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,7 @@ function WSEditorDeleteDialog(props: {
494494
}) {
495495
const [updating, setUpdating] = React.useState<boolean>(false);
496496
const [invalidText, setInvalidText] = React.useState<string | undefined>(undefined);
497+
const [confirmName, setConfirmName] = React.useState<string | undefined>(undefined);
497498

498499
const handleClose = () => {
499500
props.onClose(false);
@@ -525,10 +526,23 @@ function WSEditorDeleteDialog(props: {
525526
disableEscapeKeyDown
526527
open={props.open}
527528
>
528-
<DialogTitle>Confirm to delete workspace?</DialogTitle>
529-
<DialogContent>
530-
{invalidText && <Alert variant="filled" severity='error'> {invalidText} </Alert>}
531-
</DialogContent>
529+
<DialogTitle>Delete '{props.workspaceName}' workspace?</DialogTitle>
530+
<DialogContent dividers={true}>
531+
{invalidText && <Alert variant="filled" severity='error'> {invalidText} </Alert>}
532+
<TextField
533+
id="name"
534+
label="Workspace Name"
535+
helperText="Please type workspace name to confirm."
536+
type="text"
537+
fullWidth
538+
variant='standard'
539+
value={confirmName}
540+
onChange={(event: any) => {
541+
setConfirmName(event.target.value)
542+
}}
543+
margin="normal" required
544+
/>
545+
</DialogContent>
532546
<DialogActions>
533547
{updating &&
534548
<Box sx={{ width: '100%' }}>
@@ -537,7 +551,7 @@ function WSEditorDeleteDialog(props: {
537551
}
538552
{!updating && <React.Fragment>
539553
<Button onClick={handleClose}>Cancel</Button>
540-
<Button onClick={handleDelete}>Confirm</Button>
554+
<Button onClick={handleDelete} disabled={props.workspaceName !== confirmName}>Confirm</Button>
541555
</React.Fragment>}
542556
</DialogActions>
543557
</Dialog>

src/web/src/views/workspace/WSEditorToolBar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ class WSEditorToolBar extends React.Component<WSEditorToolBarProps> {
6868
startIcon={<EditIcon sx={{ color: grey[100] }} fontSize='small' />}
6969
onClick={onModify}
7070
>
71-
<ArgEditTypography>Edit</ArgEditTypography>
71+
<ArgEditTypography>EDIT</ArgEditTypography>
7272
</Button>
7373
<Button sx={{ flexShrink: 0, ml: 1 }}
7474
startIcon={<DeleteIcon sx={{ color: grey[100] }} fontSize='small' />}
7575
onClick={onDelete}
7676
>
77-
<ArgEditTypography>Delete</ArgEditTypography>
77+
<ArgEditTypography>DELETE</ArgEditTypography>
7878
</Button>
7979

8080
<Box sx={{ flexGrow: 1 }} />

0 commit comments

Comments
 (0)