github.com/argoproj/argo-cd@v1.8.7/ui/src/app/settings/components/project-sync-windows-edit-panel/project-sync-windows-edit-panel.tsx (about) 1 import {FormField, FormSelect} from 'argo-ui'; 2 import * as React from 'react'; 3 import {Form, FormApi, Text} from 'react-form'; 4 5 import {CheckboxField} from '../../../shared/components'; 6 7 import * as models from '../../../shared/models'; 8 9 import {ProjectSyncWindowsParams} from '../../../shared/services/projects-service'; 10 import { 11 ProjectSyncWindowApplicationsEdit, 12 ProjectSyncWindowClusterEdit, 13 ProjectSyncWindowNamespaceEdit, 14 ProjectSyncWindowScheduleEdit 15 } from '../project-sync-windows-edit/project-sync-windows-edit'; 16 17 interface ProjectSyncWindowsDefaultParams { 18 projName: string; 19 window: models.SyncWindow; 20 newWindow: boolean; 21 id: number; 22 } 23 24 interface ProjectSyncWindowsEditPanelProps { 25 submit: (params: ProjectSyncWindowsParams) => any; 26 getApi?: (formApi: FormApi) => void; 27 defaultParams: ProjectSyncWindowsDefaultParams; 28 } 29 30 export const ProjectSyncWindowsEditPanel = (props: ProjectSyncWindowsEditPanelProps) => { 31 if (props.defaultParams.window === undefined) { 32 const w = { 33 schedule: '* * * * *' 34 } as models.SyncWindow; 35 props.defaultParams.window = w; 36 } 37 return ( 38 <div className='project-sync-windows-edit-panel'> 39 <Form 40 onSubmit={props.submit} 41 getApi={props.getApi} 42 defaultValues={{ 43 projName: props.defaultParams.projName, 44 window: props.defaultParams.window 45 }} 46 validateError={(params: ProjectSyncWindowsParams) => ({ 47 projName: !params.projName && 'Project name is required', 48 window: !params.window && 'Window is required' 49 })}> 50 {api => ( 51 <form onSubmit={api.submitForm} role='form' className='width-control'> 52 <div className='argo-form-row'> 53 <FormField formApi={api} label='Kind' componentProps={{options: ['allow', 'deny']}} field='window.kind' component={FormSelect} /> 54 </div> 55 <ProjectSyncWindowScheduleEdit projName={api.values.projName} window={api.values.window} formApi={api} /> 56 <div className='argo-form-row'> 57 <FormField formApi={api} label='Duration (e.g. "30m" or "1h")' field='window.duration' component={Text} /> 58 </div> 59 <div className='argo-form-row'> 60 <FormField formApi={api} label='Enable manual sync' field='window.manualSync' component={CheckboxField} /> 61 </div> 62 <ProjectSyncWindowApplicationsEdit projName={api.values.projName} window={api.values.window} formApi={api} /> 63 <ProjectSyncWindowNamespaceEdit projName={api.values.projName} window={api.values.window} formApi={api} /> 64 <ProjectSyncWindowClusterEdit projName={api.values.projName} window={api.values.window} formApi={api} /> 65 </form> 66 )} 67 </Form> 68 </div> 69 ); 70 };