Merge branch '22075-html-tag-doc' refs #22075
[arvados.git] / services / workbench2 / 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 React from 'react';
6 import { Accordion, AccordionDetails, AccordionSummary } from '@mui/material';
7 import { reduxForm, Field } from 'redux-form';
8 import { Grid } from '@mui/material';
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 { min } from 'validators/min';
13 import { optional } from 'validators/optional';
14 import { RUN_PROCESS_ADVANCED_FORM,
15          OUTPUT_FIELD,
16          RUNTIME_FIELD,
17          RAM_FIELD,
18          VCPUS_FIELD,
19          KEEP_CACHE_RAM_FIELD,
20          RUNNER_IMAGE_FIELD,
21          RunProcessAdvancedFormData
22 } from 'store/run-process-panel/run-process-panel-actions';
23
24 export const RunProcessAdvancedForm =
25     reduxForm<RunProcessAdvancedFormData>({
26         form: RUN_PROCESS_ADVANCED_FORM,
27     })(() =>
28         <form>
29             <Accordion elevation={0}>
30                 <AccordionSummary style={{ padding: 0 }} expandIcon={<ExpandIcon />}>
31                     Advanced
32                 </AccordionSummary>
33                 <AccordionDetails style={{ padding: 0 }}>
34                     <Grid container spacing={4}>
35                         <Grid item xs={12} md={6}>
36                             <Field
37                                 name={OUTPUT_FIELD}
38                                 component={TextField as any}
39                                 label="Output name" />
40                         </Grid>
41                         <Grid item xs={12} md={6}>
42                             <Field
43                                 name={RUNTIME_FIELD}
44                                 component={TextField as any}
45                                 helperText="Maximum running time (in seconds) that this container will be allowed to run before being cancelled."
46                                 label="Runtime limit"
47                                 parse={IntInput.parse}
48                                 format={IntInput.format}
49                                 type='number'
50                                 validate={runtimeValidation} />
51                         </Grid>
52                         <Grid item xs={12} md={6}>
53                             <Field
54                                 name={RAM_FIELD}
55                                 component={TextField as any}
56                                 label="RAM"
57                                 helperText="Number of ram bytes to be used to run this process."
58                                 parse={IntInput.parse}
59                                 format={IntInput.format}
60                                 type='number'
61                                 required
62                                 validate={ramValidation} />
63                         </Grid>
64                         <Grid item xs={12} md={6}>
65                             <Field
66                                 name={VCPUS_FIELD}
67                                 component={TextField as any}
68                                 label="VCPUs"
69                                 helperText="Number of cores to be used to run this process."
70                                 parse={IntInput.parse}
71                                 format={IntInput.format}
72                                 type='number'
73                                 required
74                                 validate={vcpusValidation} />
75                         </Grid>
76                         <Grid item xs={12} md={6}>
77                             <Field
78                                 name={KEEP_CACHE_RAM_FIELD}
79                                 component={TextField as any}
80                                 label="Keep cache RAM"
81                                 helperText="Number of keep cache bytes to be used to run this process."
82                                 parse={IntInput.parse}
83                                 format={IntInput.format}
84                                 type='number'
85                                 validate={keepCacheRamValidation} />
86                         </Grid>
87                         <Grid item xs={12} md={6}>
88                             <Field
89                                 name={RUNNER_IMAGE_FIELD}
90                                 component={TextField as any}
91                                 label='Runner'
92                                 required
93                                 helperText='The container image with arvados-cwl-runner that will execute this workflow.' />
94                         </Grid>
95                     </Grid>
96                 </AccordionDetails>
97             </Accordion>
98         </form >);
99
100 const ramValidation = [min(0)];
101 const vcpusValidation = [min(1)];
102 const keepCacheRamValidation = [optional(min(0))];
103 const runtimeValidation = [optional(min(1))];