mirror of
https://github.com/portainer/portainer.git
synced 2025-07-20 05:49:40 +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
70
app/react/edge/components/EdgeScriptForm/EdgeScriptForm.tsx
Normal file
70
app/react/edge/components/EdgeScriptForm/EdgeScriptForm.tsx
Normal file
|
@ -0,0 +1,70 @@
|
|||
import { Formik } from 'formik';
|
||||
|
||||
import { OsSelector } from './OsSelector';
|
||||
import { CommandTab } from './scripts';
|
||||
import { ScriptTabs } from './ScriptTabs';
|
||||
import { EdgeScriptSettingsFieldset } from './EdgeScriptSettingsFieldset';
|
||||
import { validationSchema } from './EdgeScriptForm.validation';
|
||||
import { ScriptFormValues, OS, Platform, EdgeInfo } from './types';
|
||||
|
||||
const edgePropertiesFormInitialValues: ScriptFormValues = {
|
||||
allowSelfSignedCertificates: true,
|
||||
envVars: '',
|
||||
os: 'linux' as OS,
|
||||
platform: 'k8s' as Platform,
|
||||
nomadToken: '',
|
||||
authEnabled: true,
|
||||
};
|
||||
|
||||
interface Props {
|
||||
edgeInfo: EdgeInfo;
|
||||
commands: CommandTab[] | Partial<Record<OS, CommandTab[]>>;
|
||||
isNomadTokenVisible?: boolean;
|
||||
}
|
||||
|
||||
export function EdgeScriptForm({
|
||||
edgeInfo,
|
||||
commands,
|
||||
isNomadTokenVisible,
|
||||
}: Props) {
|
||||
const showOsSelector = !(commands instanceof Array);
|
||||
|
||||
return (
|
||||
<div className="form-horizontal">
|
||||
<Formik
|
||||
initialValues={edgePropertiesFormInitialValues}
|
||||
validationSchema={() => validationSchema(isNomadTokenVisible)}
|
||||
onSubmit={() => {}}
|
||||
>
|
||||
{({ values, setFieldValue }) => (
|
||||
<>
|
||||
<EdgeScriptSettingsFieldset
|
||||
isNomadTokenVisible={
|
||||
isNomadTokenVisible && values.platform === 'nomad'
|
||||
}
|
||||
hideIdGetter={edgeInfo.id !== undefined}
|
||||
/>
|
||||
<div className="mt-8">
|
||||
{showOsSelector && (
|
||||
<OsSelector
|
||||
value={values.os}
|
||||
onChange={(value) => setFieldValue('os', value)}
|
||||
/>
|
||||
)}
|
||||
<ScriptTabs
|
||||
edgeId={edgeInfo.id}
|
||||
edgeKey={edgeInfo.key}
|
||||
values={values}
|
||||
commands={showOsSelector ? commands[values.os] || [] : commands}
|
||||
platform={values.platform}
|
||||
onPlatformChange={(platform) =>
|
||||
setFieldValue('platform', platform)
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</Formik>
|
||||
</div>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue