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:
parent
e686d64011
commit
ac096dda46
48 changed files with 793 additions and 316 deletions
53
app/react/edge/components/EdgeScriptForm/NomadTokenField.tsx
Normal file
53
app/react/edge/components/EdgeScriptForm/NomadTokenField.tsx
Normal 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(),
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue