Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Add validation for existing restriction

Joshen Limb34d8992f7b4
diff --git a/studio/components/interfaces/Settings/Database/NetworkRestrictions/AddRestrictionModal.tsx b/studio/components/interfaces/Settings/Database/NetworkRestrictions/AddRestrictionModal.tsx
index 3aa1a87a3eb..1187bcc8a3b 100644
--- a/studio/components/interfaces/Settings/Database/NetworkRestrictions/AddRestrictionModal.tsx
+++ b/studio/components/interfaces/Settings/Database/NetworkRestrictions/AddRestrictionModal.tsx
@@ -53,6 +53,14 @@ const AddRestrictionModal: FC<Props> = ({
setSubmitting(true)
const cidr = `${values.ipAddress}/${values.cidrBlockSize}`
+ const alreadyExists = restrictedIps.includes(cidr)
+ if (alreadyExists) {
+ return ui.setNotification({
+ category: 'info',
+ message: `The address ${cidr} is already restricted`,
+ })
+ }
+
const dbAllowedCidrs = hasOverachingRestriction ? [cidr] : [...restrictedIps, cidr]
try {
@@ -172,7 +180,7 @@ const AddRestrictionModal: FC<Props> = ({
</div>
</div>
<p
- className="!mt-2 text-xs transition text-brand-900 opacity-50 hover:opacity-100 cursor-pointer"
+ className="w-fit !mt-2 text-xs transition text-brand-900 opacity-50 hover:opacity-100 cursor-pointer"
onClick={() => getClientIpAddress()}
>
Use my IP address