import React from 'react' ; import { APMPolicyForm } from '.' ; import { NewPackagePolicy , PackagePolicy , PackagePolicyEditExtensionComponentProps , PackagePolicyVars , } from './typings' ; import { POLICY_ELASTIC_AGENT_ON_CLOUD } from '../../../../common/fleet' ; interface Props { policy : PackagePolicy ; newPolicy : NewPackagePolicy ; onChange : PackagePolicyEditExtensionComponentProps [ 'onChange' ] ; } export function EditAPMPolicyForm ( { newPolicy , onChange } ) { const [ firstInput , ... restInputs ] = newPolicy ?. inputs ; const vars = firstInput ?. vars ; function updateAPMPolicy ( newVars , isValid ) { onChange ( { isValid , updatedPolicy : { inputs : [ { ... firstInput , vars : newVars } , ... restInputs ] , } , } ) ; } return ( < APMPolicyForm vars = { vars } updateAPMPolicy = { updateAPMPolicy } isCloudPolicy = { newPolicy . policy_id === POLICY_ELASTIC_AGENT_ON_CLOUD } / > ) ; }