1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-21 22:39:41 +02:00

feat(wizard): add edge form [EE-3000] (#6979)

This commit is contained in:
Chaim Lev-Ari 2022-06-01 07:28:31 +03:00 committed by GitHub
parent e686d64011
commit ac096dda46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
48 changed files with 793 additions and 316 deletions

View file

@ -0,0 +1,53 @@
import { Field, useFormikContext } from 'formik';
import { string, boolean } from 'yup';
import { FormControl } from '@/portainer/components/form-components/FormControl';
import { SwitchField } from '@/portainer/components/form-components/SwitchField';
import { Input } from '@/portainer/components/form-components/Input';
import { ScriptFormValues } from './types';
export function NomadTokenField() {
const { values, setFieldValue, errors } =
useFormikContext<ScriptFormValues>();
return (
<>
<div className="form-group">
<div className="col-sm-12">
<SwitchField
checked={values.authEnabled}
onChange={(value) => {
if (!value) {
setFieldValue('nomadToken', '');
}
setFieldValue('authEnabled', value);
}}
label="Nomad Authentication Enabled"
tooltip="Nomad authentication is only required if you have ACL enabled"
/>
</div>
</div>
{values.authEnabled && (
<FormControl
label="Nomad Token"
inputId="nomad-token-input"
errors={errors.nomadToken}
>
<Field name="nomadToken" as={Input} id="nomad-token-input" />
</FormControl>
)}
</>
);
}
export function validation() {
return {
nomadToken: string().when('authEnabled', {
is: true,
then: string().required('Token is required'),
}),
authEnabled: boolean(),
};
}