ConfirmDisableReadOnlyModal.tsx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { useParams } from 'common'
  2. import { toast } from 'sonner'
  3. import { Modal } from 'ui'
  4. import { useDisableReadOnlyModeMutation } from '@/data/config/project-temp-disable-read-only-mutation'
  5. interface ConfirmDisableReadOnlyModeModalProps {
  6. visible: boolean
  7. onClose: () => void
  8. }
  9. const ConfirmDisableReadOnlyModeModal = ({
  10. visible,
  11. onClose,
  12. }: ConfirmDisableReadOnlyModeModalProps) => {
  13. const { ref } = useParams()
  14. const { mutate: disableReadOnlyMode, isPending } = useDisableReadOnlyModeMutation({
  15. onSuccess: () => {
  16. toast.success('Successfully disabled read-only mode for 15 minutes')
  17. onClose()
  18. },
  19. })
  20. return (
  21. <Modal
  22. alignFooter="right"
  23. visible={visible}
  24. onCancel={onClose}
  25. loading={isPending}
  26. confirmText="Disable read-only mode"
  27. header="Confirm to temporarily disable read-only mode"
  28. onConfirm={() => {
  29. if (!ref) return console.error('Project ref is required')
  30. disableReadOnlyMode({ projectRef: ref })
  31. }}
  32. >
  33. <Modal.Content className="space-y-2">
  34. <p className="text-sm">
  35. This will temporarily allow writes to your database for the{' '}
  36. <span className="text-amber-900">next 15 minutes</span>, during which you can reduce your
  37. database size. After deleting data, you should run a vacuum to reclaim as much space as
  38. possible.
  39. </p>
  40. <p className="text-sm">
  41. If your database size has not been sufficiently reduced after 15 minutes, read-only mode
  42. will be toggled back on. Otherwise, it will stay disabled.
  43. </p>
  44. </Modal.Content>
  45. </Modal>
  46. )
  47. }
  48. export default ConfirmDisableReadOnlyModeModal