JitDbAccessDeleteDialog.tsx66 lines · main
| 1 | import { |
| 2 | AlertDialog, |
| 3 | AlertDialogAction, |
| 4 | AlertDialogCancel, |
| 5 | AlertDialogContent, |
| 6 | AlertDialogDescription, |
| 7 | AlertDialogFooter, |
| 8 | AlertDialogHeader, |
| 9 | AlertDialogTitle, |
| 10 | Button, |
| 11 | } from 'ui' |
| 12 | |
| 13 | import type { JitUserRule } from './JitDbAccess.types' |
| 14 | |
| 15 | interface JitDbAccessDeleteDialogProps { |
| 16 | user: JitUserRule | null |
| 17 | isDeleting: boolean |
| 18 | onClose: () => void |
| 19 | onConfirm: () => void |
| 20 | } |
| 21 | |
| 22 | export function JitDbAccessDeleteDialog({ |
| 23 | user, |
| 24 | isDeleting = false, |
| 25 | onClose, |
| 26 | onConfirm, |
| 27 | }: JitDbAccessDeleteDialogProps) { |
| 28 | const userDisplayName = user?.name?.trim() || user?.email || 'this user' |
| 29 | |
| 30 | return ( |
| 31 | <AlertDialog open={!!user} onOpenChange={(open) => !open && !isDeleting && onClose()}> |
| 32 | <AlertDialogContent size="medium"> |
| 33 | <AlertDialogHeader> |
| 34 | <AlertDialogTitle>Delete temporary access rule</AlertDialogTitle> |
| 35 | <AlertDialogDescription asChild> |
| 36 | <div className="space-y-2 text-sm"> |
| 37 | <p> |
| 38 | Remove the temporary access rule for{' '} |
| 39 | <strong className="text-foreground">{userDisplayName}</strong>? |
| 40 | </p> |
| 41 | <p> |
| 42 | This revokes any assigned database roles for this member and removes their temporary |
| 43 | access configuration. |
| 44 | </p> |
| 45 | </div> |
| 46 | </AlertDialogDescription> |
| 47 | </AlertDialogHeader> |
| 48 | <AlertDialogFooter> |
| 49 | <AlertDialogCancel disabled={isDeleting}>Cancel</AlertDialogCancel> |
| 50 | <AlertDialogAction variant="danger" asChild> |
| 51 | <Button |
| 52 | loading={isDeleting} |
| 53 | disabled={isDeleting} |
| 54 | onClick={(e) => { |
| 55 | e.preventDefault() |
| 56 | onConfirm() |
| 57 | }} |
| 58 | > |
| 59 | Delete rule |
| 60 | </Button> |
| 61 | </AlertDialogAction> |
| 62 | </AlertDialogFooter> |
| 63 | </AlertDialogContent> |
| 64 | </AlertDialog> |
| 65 | ) |
| 66 | } |