Files
supabase/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/AllowAllModal.tsx
T
Jonathan Summers-Muir 972773ca87 [Dashboard] Chore: update Modal component to use new components (#26844)
* init

* add more examples

* update modal

* update modals

* more modals updated

* update modal

* Update NewAccessTokenButton.tsx

* Update NewAccessTokenButton.tsx

* fix: issue with scale on dialog opening. chore: added bg-dialog color

* fix modals

* add deprecation notices

* revert bg

* revert

* Update Modal.tsx

* Update PITRSelection.tsx

* update dialog docs

* fix: issue with payment method modal

* update terminal instructions

* update padding defaults
2024-06-05 10:06:55 +00:00

55 lines
1.5 KiB
TypeScript

import { Button, Modal } from 'ui'
import { useParams } from 'common/hooks'
import { useNetworkRestrictionsApplyMutation } from 'data/network-restrictions/network-retrictions-apply-mutation'
interface AllowAllModalProps {
visible: boolean
onClose: () => void
}
const AllowAllModal = ({ visible, onClose }: AllowAllModalProps) => {
const { ref } = useParams()
const { mutate: applyNetworkRestrictions, isLoading: isApplying } =
useNetworkRestrictionsApplyMutation({
onSuccess: () => onClose(),
})
const onSubmit = async () => {
if (!ref) return console.error('Project ref is required')
applyNetworkRestrictions({
projectRef: ref,
dbAllowedCidrs: ['0.0.0.0/0'],
dbAllowedCidrsV6: ['::/0'],
})
}
return (
<Modal
closable
hideFooter
size="small"
visible={visible}
onCancel={onClose}
header="Allow access from all IP addresses"
>
<Modal.Content className="space-y-4">
<p className="text-sm text-foreground-light">
This will allow any IP address to access your project's database. Are you sure?
</p>
</Modal.Content>
<Modal.Separator />
<Modal.Content className="flex items-center justify-end space-x-2">
<Button type="default" disabled={isApplying} onClick={() => onClose()}>
Cancel
</Button>
<Button loading={isApplying} disabled={isApplying} onClick={() => onSubmit()}>
Confirm
</Button>
</Modal.Content>
</Modal>
)
}
export default AllowAllModal