allow creating basic inference resource

This commit is contained in:
Owen
2026-08-04 14:22:36 -04:00
parent 0b30cfc341
commit 973925b35d
4 changed files with 51 additions and 9 deletions
+1
View File
@@ -2554,6 +2554,7 @@
"createInternalResourceDialogModeHttp": "HTTP",
"createInternalResourceDialogModeHttps": "HTTPS",
"createInternalResourceDialogModeSsh": "SSH",
"createInternalResourceDialogModeInference": "Inference",
"scheme": "Scheme",
"createInternalResourceDialogScheme": "Scheme",
"createInternalResourceDialogEnableSsl": "Enable TLS",
@@ -164,7 +164,10 @@ const createSiteResourceSchema = z
.refine(
(data) => {
// destination is only optional for ssh mode with native authDaemonMode
if (data.mode === "ssh" && data.authDaemonMode === "native") {
if (
(data.mode === "ssh" && data.authDaemonMode === "native") ||
data.mode == "inference"
) {
return true;
}
return (
@@ -153,7 +153,11 @@ export default function CreatePrivateResourcePage() {
label: t("createInternalResourceDialogModeSsh")
}
]
: [])
: []),
{
value: "inference" as const,
label: t("createInternalResourceDialogModeInference")
}
];
const submitDisabled =
@@ -313,6 +317,25 @@ export default function CreatePrivateResourcePage() {
"destinationPort",
443
);
} else if (
newMode ===
"inference"
) {
form.setValue(
"siteIds",
[]
);
setSelectedSites(
[]
);
form.setValue(
"destination",
null
);
form.setValue(
"destinationPort",
null
);
} else {
form.setValue(
"destinationPort",
@@ -377,6 +400,7 @@ export default function CreatePrivateResourcePage() {
)}
{(mode === "host" ||
mode === "inference" ||
(mode === "ssh" && !isNativeSsh)) && (
<SettingsFormCell span="half">
<PrivateResourceAliasField
+21 -7
View File
@@ -21,7 +21,7 @@ export type PrivateResourceClient = {
export type PrivateResourceFormValues = {
name: string;
siteIds: number[];
siteIds?: number[];
mode: PrivateResourceMode;
destination: string | null;
alias?: string | null;
@@ -163,9 +163,12 @@ export function buildCreateSiteResourcePayload(
return {
name: data.name,
siteIds: data.siteIds,
siteIds: data.siteIds ?? [],
mode: data.mode,
destination: isNativeSsh ? undefined : (data.destination ?? undefined),
destination:
isNativeSsh || data.mode === "inference"
? undefined
: (data.destination ?? undefined),
...(data.mode === "http" && {
scheme: data.scheme,
ssl: data.ssl ?? false,
@@ -391,10 +394,8 @@ export function createCreateFormSchema(t: TranslateFn) {
.string()
.min(1, t("createInternalResourceDialogNameRequired"))
.max(255, t("createInternalResourceDialogNameMaxLength")),
siteIds: z
.array(z.number().int().positive())
.min(1, t("createInternalResourceDialogPleaseSelectSite")),
mode: z.enum(["host", "cidr", "http", "ssh"]),
siteIds: z.array(z.number().int().positive()).optional(),
mode: z.enum(["host", "cidr", "http", "ssh", "inference"]),
destination: z.string().nullish(),
alias: z.string().nullish(),
destinationPort: z
@@ -427,8 +428,21 @@ export function createCreateFormSchema(t: TranslateFn) {
const isNativeSsh =
data.mode === "ssh" && data.authDaemonMode === "native";
const trimmedDestination = data.destination?.trim();
if (
data.mode !== "inference" &&
(!data.siteIds || data.siteIds.length < 1)
) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: t(
"createInternalResourceDialogPleaseSelectSite"
),
path: ["siteIds"]
});
}
if (
data.mode !== "ssh" &&
data.mode !== "inference" &&
(!trimmedDestination || trimmedDestination.length < 1)
) {
ctx.addIssue({