JitDbAccessDeleteDialog.tsx 1.9 KB

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