From d3d5a1c204314c2f25fc85200a0d8b52035c96b7 Mon Sep 17 00:00:00 2001 From: Fred KISSIE Date: Wed, 17 Dec 2025 05:22:04 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20trigger=20`null`=20domain=20chan?= =?UTF-8?q?ge=20if=20the=20user=20switches=20from=20another=20domain=20typ?= =?UTF-8?q?e=20to=20`free=20domain=20option`=20to=20prevent=20the=20modal?= =?UTF-8?q?=20from=20registering=20it=20as=20a=20valid=20value?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/proxy/[niceId]/general/page.tsx | 18 +++++--- .../settings/resources/proxy/create/page.tsx | 2 + src/components/DomainPicker.tsx | 43 +++++++++++-------- src/components/private/AuthPageSettings.tsx | 15 ++++--- 4 files changed, 47 insertions(+), 31 deletions(-) diff --git a/src/app/[orgId]/settings/resources/proxy/[niceId]/general/page.tsx b/src/app/[orgId]/settings/resources/proxy/[niceId]/general/page.tsx index e846ec6c..db783fda 100644 --- a/src/app/[orgId]/settings/resources/proxy/[niceId]/general/page.tsx +++ b/src/app/[orgId]/settings/resources/proxy/[niceId]/general/page.tsx @@ -506,13 +506,17 @@ export default function GeneralForm() { } defaultFullDomain={resourceFullDomainName} onDomainChange={(res) => { - const selected = { - domainId: res.domainId, - subdomain: res.subdomain, - fullDomain: res.fullDomain, - baseDomain: res.baseDomain, - domainNamespaceId: res.domainNamespaceId - }; + const selected = + res === null + ? null + : { + domainId: res.domainId, + subdomain: res.subdomain, + fullDomain: res.fullDomain, + baseDomain: res.baseDomain, + domainNamespaceId: + res.domainNamespaceId + }; setSelectedDomain(selected); }} /> diff --git a/src/app/[orgId]/settings/resources/proxy/create/page.tsx b/src/app/[orgId]/settings/resources/proxy/create/page.tsx index 04f5ad04..a7219210 100644 --- a/src/app/[orgId]/settings/resources/proxy/create/page.tsx +++ b/src/app/[orgId]/settings/resources/proxy/create/page.tsx @@ -1396,6 +1396,8 @@ export default function Page() { { + if (!res) return; + httpForm.setValue( "subdomain", res.subdomain diff --git a/src/components/DomainPicker.tsx b/src/components/DomainPicker.tsx index ba29c029..1dbe97c9 100644 --- a/src/components/DomainPicker.tsx +++ b/src/components/DomainPicker.tsx @@ -64,14 +64,16 @@ type DomainOption = { interface DomainPickerProps { orgId: string; - onDomainChange?: (domainInfo: { - domainId: string; - domainNamespaceId?: string; - type: "organization" | "provided"; - subdomain?: string; - fullDomain: string; - baseDomain: string; - }) => void; + onDomainChange?: ( + domainInfo: { + domainId: string; + domainNamespaceId?: string; + type: "organization" | "provided"; + subdomain?: string; + fullDomain: string; + baseDomain: string; + } | null + ) => void; cols?: number; hideFreeDomain?: boolean; defaultFullDomain?: string | null; @@ -374,16 +376,21 @@ export default function DomainPicker({ const fullDomain = sub ? `${sub}.${option.domain}` : option.domain; - onDomainChange?.({ - domainId: option.domainId || "", - domainNamespaceId: option.domainNamespaceId, - type: - option.type === "provided-search" ? "provided" : "organization", - subdomain: - option.domainType !== "cname" ? sub || undefined : undefined, - fullDomain, - baseDomain: option.domain - }); + if (option.type === "provided-search") { + onDomainChange?.(null); // prevent the modal from closing with `.Free Provided domain` + } else { + onDomainChange?.({ + domainId: option.domainId || "", + domainNamespaceId: option.domainNamespaceId, + type: "organization", + subdomain: + option.domainType !== "cname" + ? sub || undefined + : undefined, + fullDomain, + baseDomain: option.domain + }); + } }; const handleProvidedDomainSelect = (option: AvailableOption) => { diff --git a/src/components/private/AuthPageSettings.tsx b/src/components/private/AuthPageSettings.tsx index 3453d7c8..ba368dca 100644 --- a/src/components/private/AuthPageSettings.tsx +++ b/src/components/private/AuthPageSettings.tsx @@ -519,12 +519,15 @@ const AuthPageSettings = forwardRef( loginPage?.subdomain } onDomainChange={(res) => { - const selected = { - domainId: res.domainId, - subdomain: res.subdomain, - fullDomain: res.fullDomain, - baseDomain: res.baseDomain - }; + const selected = + res === null + ? null + : { + domainId: res.domainId, + subdomain: res.subdomain, + fullDomain: res.fullDomain, + baseDomain: res.baseDomain + }; setSelectedDomain(selected); }} />