fix resource domain not required

This commit is contained in:
miloschwartz
2025-07-28 12:52:44 -07:00
parent 67bae76048
commit 80aa7502af
5 changed files with 27 additions and 23 deletions

View File

@@ -1093,7 +1093,7 @@
"sidebarAllUsers": "All Users", "sidebarAllUsers": "All Users",
"sidebarIdentityProviders": "Identity Providers", "sidebarIdentityProviders": "Identity Providers",
"sidebarLicense": "License", "sidebarLicense": "License",
"sidebarClients": "Clients (beta)", "sidebarClients": "Clients (Beta)",
"sidebarDomains": "Domains", "sidebarDomains": "Domains",
"enableDockerSocket": "Enable Docker Socket", "enableDockerSocket": "Enable Docker Socket",
"enableDockerSocketDescription": "Enable Docker Socket discovery for populating container information. Socket path must be provided to Newt.", "enableDockerSocketDescription": "Enable Docker Socket discovery for populating container information. Socket path must be provided to Newt.",
@@ -1319,4 +1319,4 @@
"resourceEnableProxy": "Enable Public Proxy", "resourceEnableProxy": "Enable Public Proxy",
"resourceEnableProxyDescription": "Enable public proxying to this resource. This allows access to the resource from outside the network through the cloud on an open port. Requires Traefik config.", "resourceEnableProxyDescription": "Enable public proxying to this resource. This allows access to the resource from outside the network through the cloud on an open port. Requires Traefik config.",
"externalProxyEnabled": "External Proxy Enabled" "externalProxyEnabled": "External Proxy Enabled"
} }

View File

@@ -636,6 +636,7 @@ export default function GeneralForm() {
<CredenzaBody> <CredenzaBody>
<DomainPicker <DomainPicker
orgId={orgId as string} orgId={orgId as string}
cols={1}
onDomainChange={(res) => { onDomainChange={(res) => {
const selected = { const selected = {
domainId: res.domainId, domainId: res.domainId,

View File

@@ -74,7 +74,7 @@ const baseResourceFormSchema = z.object({
}); });
const httpResourceFormSchema = z.object({ const httpResourceFormSchema = z.object({
domainId: z.string().optional(), domainId: z.string().nonempty(),
subdomain: z.string().optional() subdomain: z.string().optional()
}); });
@@ -277,9 +277,9 @@ export default function Page() {
if (res?.status === 200) { if (res?.status === 200) {
const domains = res.data.data.domains; const domains = res.data.data.domains;
setBaseDomains(domains); setBaseDomains(domains);
if (domains.length) { // if (domains.length) {
httpForm.setValue("domainId", domains[0].domainId); // httpForm.setValue("domainId", domains[0].domainId);
} // }
} }
}; };
@@ -684,6 +684,8 @@ export default function Page() {
? await httpForm.trigger() ? await httpForm.trigger()
: await tcpUdpForm.trigger(); : await tcpUdpForm.trigger();
console.log(httpForm.getValues());
if (baseValid && settingsValid) { if (baseValid && settingsValid) {
onSubmit(); onSubmit();
} }

View File

@@ -134,4 +134,4 @@ export const adminNavSections: SidebarNavSection[] = [
: []) : [])
] ]
} }
]; ];

View File

@@ -49,6 +49,7 @@ type DomainOption = {
interface DomainPickerProps { interface DomainPickerProps {
orgId: string; orgId: string;
cols?: number;
onDomainChange?: (domainInfo: { onDomainChange?: (domainInfo: {
domainId: string; domainId: string;
domainNamespaceId?: string; domainNamespaceId?: string;
@@ -61,6 +62,7 @@ interface DomainPickerProps {
export default function DomainPicker({ export default function DomainPicker({
orgId, orgId,
cols,
onDomainChange onDomainChange
}: DomainPickerProps) { }: DomainPickerProps) {
const { env } = useEnvContext(); const { env } = useEnvContext();
@@ -309,6 +311,7 @@ export default function DomainPicker({
<Input <Input
id="domain-input" id="domain-input"
value={userInput} value={userInput}
className="max-w-xl"
onChange={(e) => { onChange={(e) => {
// Only allow letters, numbers, hyphens, and periods // Only allow letters, numbers, hyphens, and periods
const validInput = e.target.value.replace( const validInput = e.target.value.replace(
@@ -393,23 +396,25 @@ export default function DomainPicker({
{/* Organization Domains */} {/* Organization Domains */}
{organizationOptions.length > 0 && ( {organizationOptions.length > 0 && (
<div className="space-y-3"> <div className="space-y-3">
<div className="flex items-center space-x-2"> {build !== "oss" && (
<Building2 className="h-4 w-4" /> <div className="flex items-center space-x-2">
<h4 className="text-sm font-medium"> <Building2 className="h-4 w-4" />
{t("domainPickerOrganizationDomains")} <h4 className="text-sm font-medium">
</h4> {t("domainPickerOrganizationDomains")}
</div> </h4>
<div className="grid gap-2"> </div>
)}
<div className={`grid gap-2 ${cols ? `grid-cols-${cols}` : 'grid-cols-1 sm:grid-cols-2'}`}>
{organizationOptions.map((option) => ( {organizationOptions.map((option) => (
<div <div
key={option.id} key={option.id}
className={cn( className={cn(
"transition-all p-3 rounded-lg border", "transition-all p-3 rounded-lg border",
selectedOption?.id === option.id selectedOption?.id === option.id
? "border-primary bg-primary/5" ? "border-primary bg-primary/10"
: "border-input", : "border-input hover:bg-accent",
option.verified option.verified
? "cursor-pointer hover:bg-accent" ? "cursor-pointer"
: "cursor-not-allowed opacity-60" : "cursor-not-allowed opacity-60"
)} )}
onClick={() => onClick={() =>
@@ -456,10 +461,6 @@ export default function DomainPicker({
</p> </p>
)} )}
</div> </div>
{selectedOption?.id ===
option.id && (
<CheckCircle2 className="h-4 w-4 text-primary" />
)}
</div> </div>
</div> </div>
))} ))}
@@ -476,14 +477,14 @@ export default function DomainPicker({
{t("domainPickerProvidedDomains")} {t("domainPickerProvidedDomains")}
</div> </div>
</div> </div>
<div className="grid gap-2"> <div className={`grid gap-2 ${cols ? `grid-cols-${cols}` : 'grid-cols-1 sm:grid-cols-2'}`}>
{providedOptions.map((option) => ( {providedOptions.map((option) => (
<div <div
key={option.id} key={option.id}
className={cn( className={cn(
"transition-all p-3 rounded-lg border", "transition-all p-3 rounded-lg border",
selectedOption?.id === option.id selectedOption?.id === option.id
? "border-primary bg-primary/5" ? "border-primary bg-primary/10"
: "border-input", : "border-input",
"cursor-pointer hover:bg-accent" "cursor-pointer hover:bg-accent"
)} )}