Merge branch 'master' of git.curoverse.com:arvados-workbench2 into 13862-get-current...
[arvados-workbench2.git] / src / views / run-process-panel / run-process-second-step.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 { Grid, Button } from '@material-ui/core';
7 import { RunProcessBasicForm, RUN_PROCESS_BASIC_FORM } from './run-process-basic-form';
8 import { RunProcessInputsForm } from '~/views/run-process-panel/run-process-inputs-form';
9 import { CommandInputParameter } from '~/models/workflow';
10 import { connect } from 'react-redux';
11 import { RootState } from '~/store/store';
12 import { isValid } from 'redux-form';
13 import { RUN_PROCESS_INPUTS_FORM } from './run-process-inputs-form';
14 import { RunProcessAdvancedForm } from './run-process-advanced-form';
15
16 export interface RunProcessSecondStepFormDataProps {
17     inputs: CommandInputParameter[];
18     valid: boolean;
19 }
20
21 export interface RunProcessSecondStepFormActionProps {
22     goBack: () => void;
23     runProcess: () => void;
24 }
25
26 const mapStateToProps = (state: RootState): RunProcessSecondStepFormDataProps => ({
27     inputs: state.runProcessPanel.inputs,
28     valid: isValid(RUN_PROCESS_BASIC_FORM)(state) &&
29         isValid(RUN_PROCESS_INPUTS_FORM)(state),
30 });
31
32 export type RunProcessSecondStepFormProps = RunProcessSecondStepFormDataProps & RunProcessSecondStepFormActionProps;
33 export const RunProcessSecondStepForm = connect(mapStateToProps)(
34     ({ inputs, valid, goBack, runProcess }: RunProcessSecondStepFormProps) =>
35         <Grid container spacing={16}>
36             <Grid item xs={12}>
37                 <RunProcessBasicForm />
38                 <RunProcessInputsForm inputs={inputs} />
39                 <RunProcessAdvancedForm />
40             </Grid>
41             <Grid item xs={12}>
42                 <Button color="primary" onClick={goBack}>
43                     Back
44                 </Button>
45                 <Button disabled={!valid} variant="contained" color="primary" onClick={runProcess}>
46                     Run Process
47                 </Button>
48             </Grid>
49         </Grid>);