Canvas: Check if network supports auto
Change-Id: I19e06b70e3e1a59f6549fcf01b565bad8a7f5695
diff --git a/apps/canvas/front/src/components/node-gateway-https.tsx b/apps/canvas/front/src/components/node-gateway-https.tsx
index e88902d..81c40c3 100644
--- a/apps/canvas/front/src/components/node-gateway-https.tsx
+++ b/apps/canvas/front/src/components/node-gateway-https.tsx
@@ -122,6 +122,12 @@
);
return () => sub.unsubscribe();
}, [id, data, form, store]);
+ const network = useMemo(() => {
+ if (data.network === undefined) {
+ return null;
+ }
+ return env.networks.find((n) => n.domain === data.network)!;
+ }, [data, env]);
const connectedToForm = useForm<z.infer<typeof connectedToSchema>>({
resolver: zodResolver(connectedToSchema),
mode: "onChange",
@@ -394,107 +400,114 @@
/>
</form>
</Form>
- Auth
- <Form {...authEnabledForm}>
- <form className="space-y-2">
- <FormField
- control={authEnabledForm.control}
- name="enabled"
- render={({ field }) => (
- <FormItem>
- <div className="flex flex-row gap-1 items-center">
- <Checkbox
- id="authEnabled"
- onCheckedChange={field.onChange}
- checked={field.value}
- disabled={disabled}
- />
- <Label htmlFor="authEnabled">Enabled</Label>
- </div>
- <FormMessage />
- </FormItem>
- )}
- />
- </form>
- </Form>
- {data && data.auth && data.auth.enabled ? (
+ {network?.hasAuth && (
<>
- Authorized Groups
- <ul>
- {(data.auth.groups || []).map((p) => (
- <li key={p} className="flex flex-row gap-1 items-center">
- <Button
- size={"icon"}
- variant={"ghost"}
- onClick={() => removeGroup(p)}
- disabled={disabled}
- >
- <XIcon />
- </Button>
- <div>{p}</div>
- </li>
- ))}
- </ul>
- <Form {...authGroupForm}>
- <form className="flex flex-row space-x-1" onSubmit={authGroupForm.handleSubmit(onGroupSubmit)}>
+ Auth
+ <Form {...authEnabledForm}>
+ <form className="space-y-2">
<FormField
- control={authGroupForm.control}
- name="group"
+ control={authEnabledForm.control}
+ name="enabled"
render={({ field }) => (
<FormItem>
- <FormControl>
- <Input placeholder="group" {...field} disabled={disabled} />
- </FormControl>
+ <div className="flex flex-row gap-1 items-center">
+ <Checkbox
+ id="authEnabled"
+ onCheckedChange={field.onChange}
+ checked={field.value}
+ disabled={disabled}
+ />
+ <Label htmlFor="authEnabled">Enabled</Label>
+ </div>
<FormMessage />
</FormItem>
)}
/>
- <Button type="submit" disabled={disabled}>
- Add Group
- </Button>
</form>
</Form>
- Auth optional path patterns
- <ul>
- {(data.auth.noAuthPathPatterns || []).map((p) => (
- <li key={p} className="flex flex-row gap-1 items-center">
- <Button
- size={"icon"}
- variant={"ghost"}
- onClick={() => removeNoAuthPathPattern(p)}
- disabled={disabled}
+ {data && data.auth && data.auth.enabled ? (
+ <>
+ Authorized Groups
+ <ul>
+ {(data.auth.groups || []).map((p) => (
+ <li key={p} className="flex flex-row gap-1 items-center">
+ <Button
+ size={"icon"}
+ variant={"ghost"}
+ onClick={() => removeGroup(p)}
+ disabled={disabled}
+ >
+ <XIcon />
+ </Button>
+ <div>{p}</div>
+ </li>
+ ))}
+ </ul>
+ <Form {...authGroupForm}>
+ <form
+ className="flex flex-row space-x-1"
+ onSubmit={authGroupForm.handleSubmit(onGroupSubmit)}
>
- <XIcon />
- </Button>
- <div>{p}</div>
- </li>
- ))}
- </ul>
- <Form {...authNoAuthPatternFrom}>
- <form
- className="flex flex-row space-x-1"
- onSubmit={authNoAuthPatternFrom.handleSubmit(onNoAuthPathPatternSubmit)}
- >
- <FormField
- control={authNoAuthPatternFrom.control}
- name="noAuthPathPattern"
- render={({ field }) => (
- <FormItem>
- <FormControl>
- <Input placeholder="group" {...field} disabled={disabled} />
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
- <Button type="submit" disabled={disabled}>
- Add
- </Button>
- </form>
- </Form>
+ <FormField
+ control={authGroupForm.control}
+ name="group"
+ render={({ field }) => (
+ <FormItem>
+ <FormControl>
+ <Input placeholder="group" {...field} disabled={disabled} />
+ </FormControl>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ <Button type="submit" disabled={disabled}>
+ Add Group
+ </Button>
+ </form>
+ </Form>
+ Auth optional path patterns
+ <ul>
+ {(data.auth.noAuthPathPatterns || []).map((p) => (
+ <li key={p} className="flex flex-row gap-1 items-center">
+ <Button
+ size={"icon"}
+ variant={"ghost"}
+ onClick={() => removeNoAuthPathPattern(p)}
+ disabled={disabled}
+ >
+ <XIcon />
+ </Button>
+ <div>{p}</div>
+ </li>
+ ))}
+ </ul>
+ <Form {...authNoAuthPatternFrom}>
+ <form
+ className="flex flex-row space-x-1"
+ onSubmit={authNoAuthPatternFrom.handleSubmit(onNoAuthPathPatternSubmit)}
+ >
+ <FormField
+ control={authNoAuthPatternFrom.control}
+ name="noAuthPathPattern"
+ render={({ field }) => (
+ <FormItem>
+ <FormControl>
+ <Input placeholder="group" {...field} disabled={disabled} />
+ </FormControl>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ <Button type="submit" disabled={disabled}>
+ Add
+ </Button>
+ </form>
+ </Form>
+ </>
+ ) : (
+ <></>
+ )}
</>
- ) : (
- <></>
)}
</>
);