-
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 07dd11c
Showing
9 changed files
with
122 additions
and
10 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
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 React, { useState } from 'react'; | ||
import { IconButton } from '@mui/material'; | ||
import DeleteIcon from '@mui/icons-material/Delete'; | ||
|
||
// utility | ||
import { api, endpoints } from '../../api'; | ||
|
||
// components | ||
import DeleteTagConfirmDialog from 'components/Shared/DeleteTagConfirmDialog'; | ||
import { host } from '../../host'; | ||
|
||
export default function DeleteTag(props) { | ||
const { repo, tag, onTagDelete } = props; | ||
const [open, setOpen] = 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) { | ||
onTagDelete(tag); | ||
} | ||
}) | ||
.catch((err) => { | ||
console.error(err); | ||
}); | ||
}; | ||
|
||
const onConfirm = () => { | ||
deleteTag(repo, tag); | ||
}; | ||
|
||
return ( | ||
<React.Fragment> | ||
<IconButton onClick={handleClickOpen}> | ||
<DeleteIcon /> | ||
</IconButton> | ||
<DeleteTagConfirmDialog | ||
onClose={handleClose} | ||
open={open} | ||
title={`Permanently delete image ${repo}:${tag}?`} | ||
onConfirm={onConfirm} | ||
/> | ||
</React.Fragment> | ||
); | ||
} |
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,30 @@ | ||
import React from 'react'; | ||
|
||
// components | ||
import { Button, Dialog, DialogTitle, DialogActions } from '@mui/material'; | ||
|
||
export default function DeleteTagConfirmDialog(props) { | ||
const { onClose, open, title, onConfirm } = props; | ||
|
||
return ( | ||
<Dialog data-testid="delete-dialog" onClose={onClose} open={open} color="primary"> | ||
<DialogTitle> {title} </DialogTitle> | ||
<DialogActions style={{ justifyContent: 'center' }}> | ||
<Button data-testid="cancel-delete" variant="contained" onClick={onClose} color="primary"> | ||
Cancel | ||
</Button> | ||
<Button | ||
data-testid="confirm-delete" | ||
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
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