-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Petu Eusebiu <[email protected]>
- Loading branch information
1 parent
2e1e2e9
commit 939f2ea
Showing
7 changed files
with
106 additions
and
9 deletions.
There are no files selected for viewing
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
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
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
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,29 @@ | ||
import * as React from 'react'; | ||
|
||
// components | ||
import { Button, Dialog, DialogTitle, DialogActions } from '@mui/material'; | ||
|
||
export default function ConfirmDialog(props) { | ||
const { onClose, open, title, onConfirm } = props; | ||
|
||
return ( | ||
<Dialog onClose={onClose} open={open} color="primary"> | ||
<DialogTitle> {title} </DialogTitle> | ||
<DialogActions style={{ justifyContent: 'center' }}> | ||
<Button variant="contained" onClick={() => onClose()} color="primary"> | ||
Cancel | ||
</Button> | ||
<Button | ||
color="error" | ||
variant="contained" | ||
onClick={() => { | ||
onConfirm(); | ||
onClose(); | ||
}} | ||
> | ||
Delete | ||
</Button> | ||
</DialogActions> | ||
</Dialog> | ||
); | ||
} |
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,54 @@ | ||
import * as React from 'react'; | ||
import { IconButton } from '@mui/material'; | ||
import DeleteIcon from '@mui/icons-material/Delete'; | ||
|
||
// utility | ||
import { api, endpoints } from '../../api'; | ||
|
||
// components | ||
import ConfirmDialog from 'components/Shared/ConfirmDialog'; | ||
import { host } from '../../host'; | ||
|
||
export default function DeleteTag(props) { | ||
const { repo, tag, handleDeleteTag } = props; | ||
const [open, setOpen] = React.useState(false); | ||
|
||
const handleClickOpen = () => { | ||
setOpen(true); | ||
}; | ||
|
||
const handleClose = () => { | ||
setOpen(false); | ||
}; | ||
|
||
const deleteTag = (repo, tag) => { | ||
api | ||
.delete(`${host()}${endpoints.deleteImage(repo, tag)}`) | ||
.then((response) => { | ||
if (response && response.status == 202) { | ||
handleDeleteTag(tag); | ||
} | ||
}) | ||
.catch((err) => { | ||
console.error(err); | ||
}); | ||
}; | ||
|
||
const onConfirm = () => { | ||
deleteTag(repo, tag); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<IconButton onClick={handleClickOpen}> | ||
<DeleteIcon /> | ||
</IconButton> | ||
<ConfirmDialog | ||
onClose={handleClose} | ||
open={open} | ||
title={`Permanently delete ${repo}:${tag} image`} | ||
onConfirm={onConfirm} | ||
/> | ||
</div> | ||
); | ||
} |
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
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