X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/68bcb877244747d3895212bd5b6d8fb228519ce9..0efebb152c5b21d3d1d58a2a27058c1e661342b9:/src/views/run-process-panel/run-process-second-step.tsx

diff --git a/src/views/run-process-panel/run-process-second-step.tsx b/src/views/run-process-panel/run-process-second-step.tsx
index 6582710c..0b856382 100644
--- a/src/views/run-process-panel/run-process-second-step.tsx
+++ b/src/views/run-process-panel/run-process-second-step.tsx
@@ -3,60 +3,53 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from 'react';
-import { withStyles, WithStyles, StyleRulesCallback, Grid, Button } from '@material-ui/core';
-import { ArvadosTheme } from '~/common/custom-theme';
-import { Field, reduxForm, InjectedFormProps } from 'redux-form';
-import { TextField } from '~/components/text-field/text-field';
-import { RunProcessSecondStepDataFormProps, RUN_PROCESS_SECOND_STEP_FORM_NAME } from '~/store/run-process-panel/run-process-panel-actions';
-
-type CssRules = 'root';
-
-const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
-    root: {
-
-    }
-});
-
-export interface RunProcessSecondStepDataProps {
-
+import { Grid, Button } from '@material-ui/core';
+import { RunProcessBasicForm, RUN_PROCESS_BASIC_FORM } from './run-process-basic-form';
+import { RunProcessInputsForm } from '~/views/run-process-panel/run-process-inputs-form';
+import { CommandInputParameter } from '~/models/workflow';
+import { connect } from 'react-redux';
+import { RootState } from '~/store/store';
+import { isValid } from 'redux-form';
+import { RUN_PROCESS_INPUTS_FORM } from './run-process-inputs-form';
+import { RunProcessAdvancedForm } from './run-process-advanced-form';
+import { createSelector, createStructuredSelector } from 'reselect';
+
+export interface RunProcessSecondStepFormDataProps {
+    inputs: CommandInputParameter[];
+    valid: boolean;
 }
 
-export interface RunProcessSecondStepActionProps {
-    onSetStep: (step: number) => void;
-    onRunProcess: (data: RunProcessSecondStepDataFormProps) => void;
+export interface RunProcessSecondStepFormActionProps {
+    goBack: () => void;
+    runProcess: () => void;
 }
 
-type RunProcessSecondStepProps = RunProcessSecondStepDataProps 
-    & RunProcessSecondStepActionProps 
-    & WithStyles<CssRules> 
-    & InjectedFormProps<RunProcessSecondStepDataFormProps>;
+const inputsSelector = (state: RootState) =>
+    state.runProcessPanel.inputs;
+
+const validSelector = (state: RootState) =>
+    isValid(RUN_PROCESS_BASIC_FORM)(state) && isValid(RUN_PROCESS_INPUTS_FORM)(state);
 
-const RunProcessSecondStep = withStyles(styles)(
-    ({ onSetStep, classes }: RunProcessSecondStepProps) =>
+const mapStateToProps = createStructuredSelector({
+    inputs: inputsSelector,
+    valid: validSelector,
+});
+
+export type RunProcessSecondStepFormProps = RunProcessSecondStepFormDataProps & RunProcessSecondStepFormActionProps;
+export const RunProcessSecondStepForm = connect(mapStateToProps)(
+    ({ inputs, valid, goBack, runProcess }: RunProcessSecondStepFormProps) =>
         <Grid container spacing={16}>
             <Grid item xs={12}>
-                <form>
-                    <Field
-                        name='name'
-                        component={TextField}
-                        label="Enter a new name for run process" />
-                    <Field
-                        name='description'
-                        component={TextField}
-                        label="Enter a description for run process" />
-                </form>
+                <RunProcessBasicForm />
+                <RunProcessInputsForm inputs={inputs} />
+                <RunProcessAdvancedForm />
             </Grid>
             <Grid item xs={12}>
-                <Button color="primary" onClick={() => onSetStep(0)}>
+                <Button color="primary" onClick={goBack}>
                     Back
                 </Button>
-                <Button variant="contained" color="primary">
+                <Button disabled={!valid} variant="contained" color="primary" onClick={runProcess}>
                     Run Process
                 </Button>
             </Grid>
-        </Grid>
-);
-
-export const RunProcessSecondStepForm = reduxForm<RunProcessSecondStepDataFormProps>({
-    form: RUN_PROCESS_SECOND_STEP_FORM_NAME
-})(RunProcessSecondStep);
\ No newline at end of file
+        </Grid>);
