import { Formik } from 'formik'; import { PropsWithChildren } from 'react'; 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, tlsEnabled: false, edgeGroupsIds: [], group: 0, tagsIds: [], }; interface Props { edgeInfo: EdgeInfo; commands: CommandTab[] | Partial>; isNomadTokenVisible?: boolean; asyncMode?: boolean; showMetaFields?: boolean; } export function EdgeScriptForm({ edgeInfo, commands, isNomadTokenVisible, asyncMode, showMetaFields, children, }: PropsWithChildren) { const showOsSelector = !(commands instanceof Array); return (
validationSchema(isNomadTokenVisible)} onSubmit={() => {}} > {({ values, setFieldValue }) => ( <> {children}
{showOsSelector && ( setFieldValue('os', value)} /> )} setFieldValue('platform', platform) } asyncMode={asyncMode} />
)}
); }