import { Field, useFormikContext } from 'formik'; import { string, boolean } from 'yup'; import { FormControl } from '@@/form-components/FormControl'; import { SwitchField } from '@@/form-components/SwitchField'; import { Input } from '@@/form-components/Input'; import { ScriptFormValues } from './types'; export function NomadTokenField() { const { values, setFieldValue, errors } = useFormikContext(); return ( <>
{ if (!value) { setFieldValue('nomadToken', ''); } setFieldValue('authEnabled', value); }} label="Nomad Authentication Enabled" tooltip="Nomad authentication is only required if you have ACL enabled" />
{values.authEnabled && ( )} ); } export function validation() { return { nomadToken: string().when('authEnabled', { is: true, then: string().required('Token is required'), }), authEnabled: boolean(), }; }