1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
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 import { createSelector, createStructuredSelector } from 'reselect';
17 export interface RunProcessSecondStepFormDataProps {
18 inputs: CommandInputParameter[];
22 export interface RunProcessSecondStepFormActionProps {
24 runProcess: () => void;
27 const inputsSelector = (state: RootState) =>
28 state.runProcessPanel.inputs;
30 const validSelector = (state: RootState) =>
31 isValid(RUN_PROCESS_BASIC_FORM)(state) && isValid(RUN_PROCESS_INPUTS_FORM)(state);
33 const mapStateToProps = createStructuredSelector({
34 inputs: inputsSelector,
38 export type RunProcessSecondStepFormProps = RunProcessSecondStepFormDataProps & RunProcessSecondStepFormActionProps;
39 export const RunProcessSecondStepForm = connect(mapStateToProps)(
40 ({ inputs, valid, goBack, runProcess }: RunProcessSecondStepFormProps) =>
41 <Grid container spacing={16}>
43 <RunProcessBasicForm />
44 <RunProcessInputsForm inputs={inputs} />
45 <RunProcessAdvancedForm />
48 <Button color="primary" onClick={goBack}>
51 <Button disabled={!valid} variant="contained" color="primary" onClick={runProcess}>