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 f7de28c56..0bbe42878 100644 --- a/src/app/[orgId]/settings/resources/proxy/[niceId]/general/page.tsx +++ b/src/app/[orgId]/settings/resources/proxy/[niceId]/general/page.tsx @@ -13,16 +13,6 @@ import { import { Input } from "@/components/ui/input"; import { Textarea } from "@/components/ui/textarea"; import { useResourceContext } from "@app/hooks/useResourceContext"; -import { - Credenza, - CredenzaBody, - CredenzaClose, - CredenzaContent, - CredenzaDescription, - CredenzaFooter, - CredenzaHeader, - CredenzaTitle -} from "@app/components/Credenza"; import DomainPicker from "@app/components/DomainPicker"; import { SettingsContainer, @@ -39,10 +29,9 @@ import { Label } from "@app/components/ui/label"; import { useEnvContext } from "@app/hooks/useEnvContext"; import { toast } from "@app/hooks/useToast"; import { createApiClient, formatAxiosError } from "@app/lib/api"; -import { finalizeSubdomainSanitize } from "@app/lib/subdomain-utils"; import { UpdateResourceResponse } from "@server/routers/resource"; import { AxiosResponse } from "axios"; -import { AlertCircle, Globe } from "lucide-react"; +import { AlertCircle } from "lucide-react"; import { useTranslations } from "next-intl"; import { useParams, useRouter } from "next/navigation"; import { toASCII, toUnicode } from "punycode"; @@ -442,7 +431,6 @@ export default function GeneralForm() { const { resource, updateResource } = useResourceContext(); const router = useRouter(); const t = useTranslations(); - const [editDomainOpen, setEditDomainOpen] = useState(false); const { env } = useEnvContext(); @@ -455,24 +443,13 @@ export default function GeneralForm() { ); const resourceFullDomainName = useMemo(() => { - if (!resource.fullDomain) { - return ""; - } try { const url = new URL(resourceFullDomain); return url.hostname; } catch { return ""; } - }, [resourceFullDomain, resource.fullDomain]); - - const [selectedDomain, setSelectedDomain] = useState<{ - domainId: string; - domainNamespaceId?: string; - subdomain?: string; - fullDomain: string; - baseDomain: string; - } | null>(null); + }, [resourceFullDomain]); const GeneralFormSchema = z .object({ @@ -604,37 +581,6 @@ export default function GeneralForm() { className="space-y-4" id="general-settings-form" > - ( - -
- - - form.setValue( - "enabled", - val - ) - } - /> - -
- -
- )} - /> - - -
- - - {resourceFullDomain} - - + defaultDomainId={ + form.watch( + "domainId" + ) ?? undefined + } + defaultFullDomain={ + resourceFullDomainName || + undefined + } + onDomainChange={(res) => { + if (res === null) { + form.setValue( + "domainId", + undefined + ); + form.setValue( + "subdomain", + undefined + ); + setResourceFullDomain( + `${resource.ssl ? "https" : "http"}://` + ); + return; + } + form.setValue( + "domainId", + res.domainId + ); + form.setValue( + "subdomain", + res.subdomain ?? + undefined + ); + setResourceFullDomain( + `${resource.ssl ? "https" : "http"}://${toUnicode(res.fullDomain)}` + ); + }} + />
)} + + ( + +
+ + + form.setValue( + "enabled", + val + ) + } + /> + +
+ +
+ )} + /> @@ -767,86 +776,6 @@ export default function GeneralForm() { /> )} - - setEditDomainOpen(setOpen)} - > - - - Edit Domain - - Select a domain for your resource - - - - { - const selected = - res === null - ? null - : { - domainId: res.domainId, - subdomain: res.subdomain, - fullDomain: res.fullDomain, - baseDomain: res.baseDomain, - domainNamespaceId: - res.domainNamespaceId - }; - - setSelectedDomain(selected); - }} - /> - - - - - - - - - ); }