diff --git a/src/components/Form/DynamicForm.tsx b/src/components/Form/DynamicForm.tsx index 58bf241e..f957e7f0 100644 --- a/src/components/Form/DynamicForm.tsx +++ b/src/components/Form/DynamicForm.tsx @@ -16,13 +16,14 @@ import { } from "react-hook-form"; interface DisabledBy { - fieldName: Path | "always"; + fieldName: Path; selector?: number; invert?: boolean; } export interface BaseFormBuilderProps { name: Path; + disabled?: boolean; disabledBy?: DisabledBy[]; label: string; description?: string; @@ -62,11 +63,14 @@ export function DynamicForm({ defaultValues: defaultValues, }); - const isDisabled = (disabledBy?: DisabledBy[]): boolean => { + const isDisabled = ( + disabledBy?: DisabledBy[], + disabled?: boolean, + ): boolean => { + if (disabled) return true; if (!disabledBy) return false; return disabledBy.some((field) => { - if (field.fieldName === "always") return true; const value = getValues(field.fieldName); if (value === "always") return true; if (typeof value === "boolean") return field.invert ? value : !value; @@ -111,7 +115,7 @@ export function DynamicForm({ ))} diff --git a/src/components/PageComponents/Config/Security.tsx b/src/components/PageComponents/Config/Security.tsx index a82ed980..2087f4b9 100644 --- a/src/components/PageComponents/Config/Security.tsx +++ b/src/components/PageComponents/Config/Security.tsx @@ -158,9 +158,9 @@ export const Security = (): JSX.Element => { type: "text", name: "publicKey", label: "Public Key", + disabled: true, description: "Sent out to other nodes on the mesh to allow them to compute a shared secret key", - disabledBy: [{ fieldName: "always" }], }, ], },