| 1 | "use client"; |
| 2 | |
| 3 | import { Trash2 } from |
| 4 | import { useAction } |
| 5 | |
| 6 | import { |
| 7 | AlertDialog, |
| 8 | AlertDialogCancel, |
| 9 | AlertDialogContent, |
| 10 | AlertDialogDescription, |
| 11 | AlertDialogFooter, |
| 12 | AlertDialogHeader, |
| 13 | AlertDialogTitle, |
| 14 | AlertDialogTrigger, |
| 15 | } from "@/components/ui/alert-dialog"; |
| 16 | import { Button } |
| 17 | import { FieldError } |
| 18 | import { Spinner } |
| 19 | |
| 20 | import { deleteRelease } |
| 21 | |
| 22 | export function DeleteReleaseButton({ |
| 23 | username, |
| 24 | repo, |
| 25 | id, |
| 26 | title, |
| 27 | }: { |
| 28 | username: string |
| 29 | repo: string |
| 30 | id: string |
| 31 | title: string |
| 32 | }) { |
| 33 | const { execute, |
| 34 | |
| 35 | return ( |
| 36 | <AlertDialog> |
| 37 | <AlertDialogTrigger asChild> |
| 38 | <Button variant=" |
| 39 | <Trash2 /> |
| 40 | </Button> |
| 41 | </AlertDialogTrigger> |
| 42 | <AlertDialogContent> |
| 43 | <AlertDialogHeader> |
| 44 | <AlertDialogTitle>Delete {title |
| 45 | <AlertDialogDescription> |
| 46 | The release notes are deleted. The tag stays in the repository. |
| 47 | </AlertDialogDescription> |
| 48 | </AlertDialogHeader> |
| 49 | {result.serverError && |
| 50 | <AlertDialogFooter> |
| 51 | <AlertDialogCancel>Cancel</AlertDialogCancel |
| 52 | <Button |
| 53 | variant="destructive" |
| 54 | disabled={isExecuting} |
| 55 | onClick={() => |
| 56 | > |
| 57 | {isExecuting && <Spinner |
| 58 | Delete release |
| 59 | </Button> |
| 60 | </AlertDialogFooter> |
| 61 | </AlertDialogContent> |
| 62 | </AlertDialog> |
| 63 | ); |
| 64 | } |