mirror of
https://github.com/fosrl/pangolin.git
synced 2026-09-10 13:06:19 +02:00
allow creating basic inference resource
This commit is contained in:
@@ -2554,6 +2554,7 @@
|
|||||||
"createInternalResourceDialogModeHttp": "HTTP",
|
"createInternalResourceDialogModeHttp": "HTTP",
|
||||||
"createInternalResourceDialogModeHttps": "HTTPS",
|
"createInternalResourceDialogModeHttps": "HTTPS",
|
||||||
"createInternalResourceDialogModeSsh": "SSH",
|
"createInternalResourceDialogModeSsh": "SSH",
|
||||||
|
"createInternalResourceDialogModeInference": "Inference",
|
||||||
"scheme": "Scheme",
|
"scheme": "Scheme",
|
||||||
"createInternalResourceDialogScheme": "Scheme",
|
"createInternalResourceDialogScheme": "Scheme",
|
||||||
"createInternalResourceDialogEnableSsl": "Enable TLS",
|
"createInternalResourceDialogEnableSsl": "Enable TLS",
|
||||||
|
|||||||
@@ -164,7 +164,10 @@ const createSiteResourceSchema = z
|
|||||||
.refine(
|
.refine(
|
||||||
(data) => {
|
(data) => {
|
||||||
// destination is only optional for ssh mode with native authDaemonMode
|
// 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 true;
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -153,7 +153,11 @@ export default function CreatePrivateResourcePage() {
|
|||||||
label: t("createInternalResourceDialogModeSsh")
|
label: t("createInternalResourceDialogModeSsh")
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
: [])
|
: []),
|
||||||
|
{
|
||||||
|
value: "inference" as const,
|
||||||
|
label: t("createInternalResourceDialogModeInference")
|
||||||
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
const submitDisabled =
|
const submitDisabled =
|
||||||
@@ -313,6 +317,25 @@ export default function CreatePrivateResourcePage() {
|
|||||||
"destinationPort",
|
"destinationPort",
|
||||||
443
|
443
|
||||||
);
|
);
|
||||||
|
} else if (
|
||||||
|
newMode ===
|
||||||
|
"inference"
|
||||||
|
) {
|
||||||
|
form.setValue(
|
||||||
|
"siteIds",
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
setSelectedSites(
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
form.setValue(
|
||||||
|
"destination",
|
||||||
|
null
|
||||||
|
);
|
||||||
|
form.setValue(
|
||||||
|
"destinationPort",
|
||||||
|
null
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
form.setValue(
|
form.setValue(
|
||||||
"destinationPort",
|
"destinationPort",
|
||||||
@@ -377,6 +400,7 @@ export default function CreatePrivateResourcePage() {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{(mode === "host" ||
|
{(mode === "host" ||
|
||||||
|
mode === "inference" ||
|
||||||
(mode === "ssh" && !isNativeSsh)) && (
|
(mode === "ssh" && !isNativeSsh)) && (
|
||||||
<SettingsFormCell span="half">
|
<SettingsFormCell span="half">
|
||||||
<PrivateResourceAliasField
|
<PrivateResourceAliasField
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export type PrivateResourceClient = {
|
|||||||
|
|
||||||
export type PrivateResourceFormValues = {
|
export type PrivateResourceFormValues = {
|
||||||
name: string;
|
name: string;
|
||||||
siteIds: number[];
|
siteIds?: number[];
|
||||||
mode: PrivateResourceMode;
|
mode: PrivateResourceMode;
|
||||||
destination: string | null;
|
destination: string | null;
|
||||||
alias?: string | null;
|
alias?: string | null;
|
||||||
@@ -163,9 +163,12 @@ export function buildCreateSiteResourcePayload(
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
name: data.name,
|
name: data.name,
|
||||||
siteIds: data.siteIds,
|
siteIds: data.siteIds ?? [],
|
||||||
mode: data.mode,
|
mode: data.mode,
|
||||||
destination: isNativeSsh ? undefined : (data.destination ?? undefined),
|
destination:
|
||||||
|
isNativeSsh || data.mode === "inference"
|
||||||
|
? undefined
|
||||||
|
: (data.destination ?? undefined),
|
||||||
...(data.mode === "http" && {
|
...(data.mode === "http" && {
|
||||||
scheme: data.scheme,
|
scheme: data.scheme,
|
||||||
ssl: data.ssl ?? false,
|
ssl: data.ssl ?? false,
|
||||||
@@ -391,10 +394,8 @@ export function createCreateFormSchema(t: TranslateFn) {
|
|||||||
.string()
|
.string()
|
||||||
.min(1, t("createInternalResourceDialogNameRequired"))
|
.min(1, t("createInternalResourceDialogNameRequired"))
|
||||||
.max(255, t("createInternalResourceDialogNameMaxLength")),
|
.max(255, t("createInternalResourceDialogNameMaxLength")),
|
||||||
siteIds: z
|
siteIds: z.array(z.number().int().positive()).optional(),
|
||||||
.array(z.number().int().positive())
|
mode: z.enum(["host", "cidr", "http", "ssh", "inference"]),
|
||||||
.min(1, t("createInternalResourceDialogPleaseSelectSite")),
|
|
||||||
mode: z.enum(["host", "cidr", "http", "ssh"]),
|
|
||||||
destination: z.string().nullish(),
|
destination: z.string().nullish(),
|
||||||
alias: z.string().nullish(),
|
alias: z.string().nullish(),
|
||||||
destinationPort: z
|
destinationPort: z
|
||||||
@@ -427,8 +428,21 @@ export function createCreateFormSchema(t: TranslateFn) {
|
|||||||
const isNativeSsh =
|
const isNativeSsh =
|
||||||
data.mode === "ssh" && data.authDaemonMode === "native";
|
data.mode === "ssh" && data.authDaemonMode === "native";
|
||||||
const trimmedDestination = data.destination?.trim();
|
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 (
|
if (
|
||||||
data.mode !== "ssh" &&
|
data.mode !== "ssh" &&
|
||||||
|
data.mode !== "inference" &&
|
||||||
(!trimmedDestination || trimmedDestination.length < 1)
|
(!trimmedDestination || trimmedDestination.length < 1)
|
||||||
) {
|
) {
|
||||||
ctx.addIssue({
|
ctx.addIssue({
|
||||||
|
|||||||
Reference in New Issue
Block a user