1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
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 import { SwitchField } from '~/components/switch-field/switch-field';
17 export const RUN_PROCESS_ADVANCED_FORM = 'runProcessAdvancedForm';
19 export const OUTPUT_FIELD = 'output';
20 export const RUNTIME_FIELD = 'runtime';
21 export const RAM_FIELD = 'ram';
22 export const VCPUS_FIELD = 'vcpus';
23 export const KEEP_CACHE_RAM_FIELD = 'keepCacheRam';
24 export const API_FIELD = 'api';
26 export interface RunProcessAdvancedFormData {
27 [OUTPUT_FIELD]?: string;
28 [RUNTIME_FIELD]?: number;
30 [VCPUS_FIELD]: number;
31 [KEEP_CACHE_RAM_FIELD]?: number;
32 [API_FIELD]?: boolean;
35 export const RunProcessAdvancedForm =
36 reduxForm<RunProcessAdvancedFormData>({
37 form: RUN_PROCESS_ADVANCED_FORM,
40 <ExpansionPanel elevation={0}>
41 <ExpansionPanelSummary style={{ padding: 0 }} expandIcon={<ExpandIcon />}>
43 </ExpansionPanelSummary>
44 <ExpansionPanelDetails style={{ padding: 0 }}>
45 <Grid container spacing={32}>
46 <Grid item xs={12} md={6}>
50 label="Output name" />
52 <Grid item xs={12} md={6}>
56 helperText="Maximum running time (in seconds) that this container will be allowed to run before being cancelled."
58 parse={IntInput.parse}
59 format={IntInput.format}
61 validate={runtimeValidation} />
63 <Grid item xs={12} md={6}>
68 helperText="Number of ram bytes to be used to run this process."
69 parse={IntInput.parse}
70 format={IntInput.format}
73 validate={ramValidation} />
75 <Grid item xs={12} md={6}>
80 helperText="Number of cores to be used to run this process."
81 parse={IntInput.parse}
82 format={IntInput.format}
85 validate={vcpusValidation} />
87 <Grid item xs={12} md={6}>
89 name={KEEP_CACHE_RAM_FIELD}
91 label="Keep cache RAM"
92 helperText="Number of keep cache bytes to be used to run this process."
93 parse={IntInput.parse}
94 format={IntInput.format}
96 validate={keepCacheRamValdation} />
98 <Grid item xs={12} md={6}>
101 component={SwitchField}
106 helperText='When set, ARVADOS_API_HOST and ARVADOS_API_TOKEN will be set, and process will have networking enabled to access the Arvados API server.' />
109 </ExpansionPanelDetails>
113 const ramValidation = [min(0)];
114 const vcpusValidation = [min(1)];
115 const keepCacheRamValdation = [optional(min(0))];
116 const runtimeValidation = [optional(min(1))];