DisableExternalReplicationDialog.tsx 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import { useParams } from 'common'
  2. import { toast } from 'sonner'
  3. import {
  4. AlertDialog,
  5. AlertDialogAction,
  6. AlertDialogCancel,
  7. AlertDialogContent,
  8. AlertDialogDescription,
  9. AlertDialogFooter,
  10. AlertDialogHeader,
  11. AlertDialogTitle,
  12. Button,
  13. } from 'ui'
  14. import { useDeleteReplicationTenantMutation } from '@/data/replication/delete-tenant-mutation'
  15. interface DisableExternalReplicationDialogProps {
  16. open: boolean
  17. setOpen: (value: boolean) => void
  18. }
  19. export const DisableExternalReplicationDialog = ({
  20. open,
  21. setOpen,
  22. }: DisableExternalReplicationDialogProps) => {
  23. const { ref: projectRef } = useParams()
  24. const { mutateAsync: deleteReplicationTenant, isPending: isSubmitting } =
  25. useDeleteReplicationTenantMutation({
  26. onSuccess: () => {
  27. toast.success('External replication has been disabled')
  28. setOpen(false)
  29. },
  30. })
  31. const onConfirm = async () => {
  32. if (!projectRef) return console.error('Project ref is required')
  33. await deleteReplicationTenant({ projectRef })
  34. }
  35. return (
  36. <AlertDialog open={open} onOpenChange={(open) => !isSubmitting && setOpen(open)}>
  37. <AlertDialogContent size="medium">
  38. <AlertDialogHeader>
  39. <AlertDialogTitle>Confirm to disable external replication</AlertDialogTitle>
  40. <AlertDialogDescription className="space-y-2 text-sm">
  41. <p>
  42. This will remove the <code className="text-code-inline">etl</code> schema and all
  43. connected resources from your database. Any active pipelines sending changes to
  44. external destinations will stop.
  45. </p>
  46. <p>Read replicas are not affected.</p>
  47. </AlertDialogDescription>
  48. </AlertDialogHeader>
  49. <AlertDialogFooter>
  50. <AlertDialogCancel disabled={isSubmitting}>Cancel</AlertDialogCancel>
  51. <AlertDialogAction variant="danger" asChild>
  52. <Button
  53. type="danger"
  54. loading={isSubmitting}
  55. disabled={isSubmitting}
  56. onClick={(e) => {
  57. e.preventDefault()
  58. onConfirm()
  59. }}
  60. >
  61. Disable external replication
  62. </Button>
  63. </AlertDialogAction>
  64. </AlertDialogFooter>
  65. </AlertDialogContent>
  66. </AlertDialog>
  67. )
  68. }