-
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
e97e04e
commit 4913b78
Showing
7 changed files
with
104 additions
and
8 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> | ||
<Button variant="contained" onClick={() => onClose()} color="primary"> | ||
No | ||
</Button> | ||
<Button | ||
color="primary" | ||
variant="contained" | ||
onClick={() => { | ||
onConfirm(); | ||
onClose(); | ||
}} | ||
> | ||
Yes | ||
</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,48 @@ | ||
import * as React from 'react'; | ||
import { Button } from '@mui/material'; | ||
|
||
// 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, rerender } = 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(() => { | ||
console.log('delete successfully'); | ||
rerender(); | ||
}) | ||
.catch((err) => { | ||
console.error(err); | ||
}); | ||
}; | ||
|
||
const onConfirm = () => { | ||
console.log(`repo: ${repo}, tag: ${tag}`); | ||
deleteTag(repo, tag); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<Button variant="outlined" onClick={handleClickOpen}> | ||
Delete tag | ||
</Button> | ||
<ConfirmDialog onClose={handleClose} open={open} title={`Delete ${repo}:${tag} ?`} 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
const hostConfig = { | ||
auto: true, | ||
auto: false, | ||
default: 'http://localhost:5000' | ||
}; | ||
|
||
|