import type { AppForm } from '@/components/form'; import { type AdminLocation, useAllAdminLocations } from '@/api/admin/locations/queries'; import { type NodeFormValues, nodeNumberValidators, validateNodeName } from '@/components/admin/nodes/nodeForm'; import TitledGreyBox from '@/components/elements/TitledGreyBox'; interface Props { form: AppForm; prefix?: string; requiresSslScheme?: boolean; } type LocationOption = AdminLocation; interface FormFieldsProps { form: AppForm; prefix: string; } interface IdentityFieldsProps extends FormFieldsProps { locations: LocationOption[]; } interface NetworkFieldsProps extends FormFieldsProps { requiresSslScheme: boolean; } const IdentityFields = ({ form, locations, prefix }: IdentityFieldsProps) => (
validateNodeName(value), }} > {(field) => ( )} {(field) => ( )} (value >= 1 ? undefined : 'A location must be selected.'), }} > {(field) => ( ({ value: location.attributes.id, label: location.attributes.short, }))} /> )}
); const NetworkFields = ({ form, prefix, requiresSslScheme }: NetworkFieldsProps) => { const schemeDescription = requiresSslScheme ? 'This Panel is using HTTPS, so browsers require node connections to use SSL.' : 'In most cases you should use SSL. Use HTTP only for non-SSL nodes.'; return (
(value.length >= 1 ? undefined : 'An FQDN must be provided.'), }} > {(field) => ( )} requiresSslScheme && value === 'http' ? 'HTTP node connections cannot be used when the Panel is loaded over HTTPS.' : undefined, }} > {(field) => ( )}
{(field) => ( )} {(field) => ( )} {(field) => ( )}
); }; const ResourceFields = ({ form, prefix }: FormFieldsProps) => (
{(field) => } {(field) => ( )} {(field) => } {(field) => }
); const DaemonFields = ({ form, prefix }: FormFieldsProps) => (
{(field) => } {(field) => } {(field) => } {(field) => }
); export default function NodeFormFields({ form, prefix = '', requiresSslScheme = false }: Props) { const { data: locations = [] } = useAllAdminLocations(); return (
); }