X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/8a85c509e4f2100082cfed6157d31c8651b861c9..35d6c5a870aeff7bb2cbf6ec80d306debad872c1:/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 2585136e6e..a2ed9a21f1 100644
--- a/src/views/run-process-panel/run-process-second-step.tsx
+++ b/src/views/run-process-panel/run-process-second-step.tsx
@@ -6,34 +6,66 @@ import * as React from 'react';
 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 { CommandInputParameter, WorkflowResource } 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 { RunProcessAdvancedForm, RUN_PROCESS_ADVANCED_FORM } from './run-process-advanced-form';
+import { createStructuredSelector } from 'reselect';
+import { WorkflowPresetSelect } from '~/views/run-process-panel/workflow-preset-select';
+import { selectPreset } from '~/store/run-process-panel/run-process-panel-actions';
 
 export interface RunProcessSecondStepFormDataProps {
     inputs: CommandInputParameter[];
+    workflow?: WorkflowResource;
+    presets?: WorkflowResource[];
+    selectedPreset?: WorkflowResource;
     valid: boolean;
 }
 
 export interface RunProcessSecondStepFormActionProps {
     goBack: () => void;
     runProcess: () => void;
+    onPresetChange: (preset: WorkflowResource) => void;
 }
 
-const mapStateToProps = (state: RootState): RunProcessSecondStepFormDataProps => ({
-    inputs: state.runProcessPanel.inputs,
-    valid: isValid(RUN_PROCESS_BASIC_FORM)(state) &&
-        isValid(RUN_PROCESS_INPUTS_FORM)(state),
+const selectedWorkflowSelector = (state: RootState) =>
+    state.runProcessPanel.selectedWorkflow;
+
+const presetsSelector = (state: RootState) =>
+    state.runProcessPanel.presets;
+
+const selectedPresetSelector = (state: RootState) =>
+    state.runProcessPanel.selectedPreset;
+
+const inputsSelector = (state: RootState) =>
+    state.runProcessPanel.inputs;
+
+const validSelector = (state: RootState) =>
+    isValid(RUN_PROCESS_BASIC_FORM)(state) && isValid(RUN_PROCESS_INPUTS_FORM)(state) && isValid(RUN_PROCESS_ADVANCED_FORM)(state);
+
+const mapStateToProps = createStructuredSelector({
+    inputs: inputsSelector,
+    valid: validSelector,
+    workflow: selectedWorkflowSelector,
+    presets: presetsSelector,
+    selectedPreset: selectedPresetSelector,
 });
 
 export type RunProcessSecondStepFormProps = RunProcessSecondStepFormDataProps & RunProcessSecondStepFormActionProps;
-export const RunProcessSecondStepForm = connect(mapStateToProps)(
-    ({ inputs, valid, goBack, runProcess }: RunProcessSecondStepFormProps) =>
+export const RunProcessSecondStepForm = connect(mapStateToProps, { onPresetChange: selectPreset })(
+    ({ inputs, workflow, selectedPreset, presets, onPresetChange, valid, goBack, runProcess }: RunProcessSecondStepFormProps) =>
         <Grid container spacing={16}>
             <Grid item xs={12}>
+                <Grid container spacing={32}>
+                    <Grid item xs={12} md={6}>
+                        {workflow && selectedPreset && presets &&
+                            < WorkflowPresetSelect
+                                {...{ workflow, selectedPreset, presets, onChange: onPresetChange }} />
+                        }
+                    </Grid>
+                </Grid>
                 <RunProcessBasicForm />
                 <RunProcessInputsForm inputs={inputs} />
                 <RunProcessAdvancedForm />
