Delete initialValues since they are not working
[arvados.git] / src / views / run-process-panel / run-process-advanced-form.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import * as React from 'react';
6 import { ExpansionPanel, ExpansionPanelDetails, ExpansionPanelSummary } from '@material-ui/core';
7 import { reduxForm, Field } from 'redux-form';
8 import { Grid } from '@material-ui/core';
9 import { TextField } from '~/components/text-field/text-field';
10 import { ExpandIcon } from '~/components/icon/icon';
11 import * as IntInput from './inputs/int-input';
12 import { require } from '~/validators/require';
13 import { min } from '~/validators/min';
14 import { optional } from '~/validators/optional';
15
16 export const RUN_PROCESS_ADVANCED_FORM = 'runProcessAdvancedForm';
17
18 export const OUTPUT_FIELD = 'output';
19 export const RUNTIME_FIELD = 'runtime';
20 export const RAM_FIELD = 'ram';
21 export const VCPUS_FIELD = 'vcpus';
22 export const KEEP_CACHE_RAM_FIELD = 'keepCacheRam';
23
24 export interface RunProcessAdvancedFormData {
25     [OUTPUT_FIELD]?: string;
26     [RUNTIME_FIELD]?: number;
27     [RAM_FIELD]: number;
28     [VCPUS_FIELD]: number;
29     [KEEP_CACHE_RAM_FIELD]?: number;
30 }
31
32 export const RunProcessAdvancedForm =
33     reduxForm<RunProcessAdvancedFormData>({
34         form: RUN_PROCESS_ADVANCED_FORM,
35     })(() =>
36         <form>
37             <ExpansionPanel elevation={0}>
38                 <ExpansionPanelSummary style={{ padding: 0 }} expandIcon={<ExpandIcon />}>
39                     Advanced
40                 </ExpansionPanelSummary>
41                 <ExpansionPanelDetails style={{ padding: 0 }}>
42                     <Grid container spacing={32}>
43                         <Grid item xs={12} md={6}>
44                             <Field
45                                 name={OUTPUT_FIELD}
46                                 component={TextField}
47                                 label="Output name" />
48                         </Grid>
49                         <Grid item xs={12} md={6}>
50                             <Field
51                                 name={RUNTIME_FIELD}
52                                 component={TextField}
53                                 label="Runtime limit (hh)" />
54                         </Grid>
55                         <Grid item xs={12} md={6}>
56                             <Field
57                                 name={RAM_FIELD}
58                                 component={TextField}
59                                 label="RAM"
60                                 helperText="Number of ram bytes to be used to run this process."
61                                 parse={IntInput.parse}
62                                 format={IntInput.format}
63                                 type='number'
64                                 required
65                                 validate={ramValidation} />
66                         </Grid>
67                         <Grid item xs={12} md={6}>
68                             <Field
69                                 name={VCPUS_FIELD}
70                                 component={TextField}
71                                 label="VCPUs"
72                                 helperText="Number of cores to be used to run this process."
73                                 parse={IntInput.parse}
74                                 format={IntInput.format}
75                                 type='number'
76                                 required
77                                 validate={vcpusValidation} />
78                         </Grid>
79                         <Grid item xs={12} md={6}>
80                             <Field
81                                 name={KEEP_CACHE_RAM_FIELD}
82                                 component={TextField}
83                                 label="Keep cache RAM"
84                                 helperText="Number of keep cache bytes to be used to run this process."
85                                 parse={IntInput.parse}
86                                 format={IntInput.format}
87                                 type='number'
88                                 validate={keepCacheRamValdation} />
89                         </Grid>
90                     </Grid>
91                 </ExpansionPanelDetails>
92             </ExpansionPanel>
93         </form >);
94
95 const ramValidation = [min(0)];
96 const vcpusValidation = [min(1)];
97 const keepCacheRamValdation = [optional(min(0))];