// SPDX-License-Identifier: AGPL-3.0
import { RunProcessPanelAction, runProcessPanelActions } from '~/store/run-process-panel/run-process-panel-actions';
-import { WorkflowResource } from '~/models/workflow';
+import { WorkflowResource, CommandInputParameter, getWorkflowInputs, parseWorkflowDefinition } from '~/models/workflow';
interface RunProcessPanel {
currentStep: number;
workflows: WorkflowResource[];
selectedWorkflow: WorkflowResource | undefined;
+ inputs: CommandInputParameter[];
}
const initialState: RunProcessPanel = {
currentStep: 0,
workflows: [],
- selectedWorkflow: undefined
+ selectedWorkflow: undefined,
+ inputs: [],
};
export const runProcessPanelReducer = (state = initialState, action: RunProcessPanelAction): RunProcessPanel =>
runProcessPanelActions.match(action, {
SET_CURRENT_STEP: currentStep => ({ ...state, currentStep }),
- SET_WORKFLOWS: workflows => ({ ...state, workflows }),
- SET_SELECTED_WORKFLOW: selectedWorkflow => ({ ...state, selectedWorkflow }),
+ SET_WORKFLOWS: workflows => ({ ...state, workflows }),
+ SET_SELECTED_WORKFLOW: selectedWorkflow => ({
+ ...state,
+ selectedWorkflow,
+ inputs: getWorkflowInputs(parseWorkflowDefinition(selectedWorkflow)) || [],
+ }),
default: () => state
});
\ No newline at end of file
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from 'react';
+import { reduxForm, Field } from 'redux-form';
+import { Grid } from '@material-ui/core';
+import { TextField } from '~/components/text-field/text-field';
+
+export const RUN_PROCESS_BASIC_FORM = 'runProcessBasicForm';
+
+export interface RunProcessBasicFormData {
+ name: string;
+ description: string;
+}
+export const RunProcessBasicForm =
+ reduxForm<RunProcessBasicFormData>({
+ form: RUN_PROCESS_BASIC_FORM
+ })(() =>
+ <form>
+ <Grid container spacing={16}>
+ <Grid item xs={12} md={6}>
+ <Field
+ name='name'
+ component={TextField}
+ label="Enter a new name for run process" />
+ </Grid>
+ <Grid item xs={12} md={6}>
+ <Field
+ name='description'
+ component={TextField}
+ label="Enter a description for run process" />
+ </Grid>
+ </Grid>
+ </form>);
import { compose } from 'redux';
import { Grid, StyleRulesCallback, withStyles, WithStyles } from '@material-ui/core';
-const RUN_PROCESS_INPUTS_FORM = 'runProcessInputsForm';
+export const RUN_PROCESS_INPUTS_FORM = 'runProcessInputsForm';
export interface RunProcessInputFormProps {
inputs: CommandInputParameter[];
}))(
(props: InjectedFormProps & RunProcessInputFormProps) =>
<form>
- <Grid container>
+ <Grid container spacing={16}>
{props.inputs.map(input =>
<InputItem input={input} key={input.id} />)}
</Grid>
const InputItem = withStyles(styles)(
(props: WithStyles<CssRules> & { input: CommandInputParameter }) =>
- <Grid item xs={12} className={props.classes.inputItem}>
+ <Grid item xs={12} md={6} className={props.classes.inputItem}>
{getInputComponent(props.input)}
</Grid>);
import * as React from 'react';
import { Stepper, Step, StepLabel, StepContent } from '@material-ui/core';
import { RunProcessFirstStepDataProps, RunProcessFirstStepActionProps, RunProcessFirstStep } from '~/views/run-process-panel/run-process-first-step';
-import { RunProcessSecondStepDataProps, RunProcessSecondStepActionProps, RunProcessSecondStepForm } from '~/views/run-process-panel/run-process-second-step';
+import { RunProcessSecondStepForm } from './run-process-second-step';
export type RunProcessPanelRootDataProps = {
currentStep: number;
-} & RunProcessFirstStepDataProps & RunProcessSecondStepDataProps;
+} & RunProcessFirstStepDataProps;
-export type RunProcessPanelRootActionProps = RunProcessFirstStepActionProps & RunProcessSecondStepActionProps;
+export type RunProcessPanelRootActionProps = RunProcessFirstStepActionProps & {
+ runProcess: () => void;
+};
type RunProcessPanelRootProps = RunProcessPanelRootDataProps & RunProcessPanelRootActionProps;
-export const RunProcessPanelRoot = ({ currentStep, onSetStep, onRunProcess, onSetWorkflow, workflows, selectedWorkflow }: RunProcessPanelRootProps) =>
+export const RunProcessPanelRoot = ({ runProcess, currentStep, onSetStep, onSetWorkflow, workflows, selectedWorkflow }: RunProcessPanelRootProps) =>
<Stepper activeStep={currentStep} orientation="vertical" elevation={2}>
<Step>
<StepLabel>Choose a workflow</StepLabel>
<StepContent>
- <RunProcessFirstStep
+ <RunProcessFirstStep
workflows={workflows}
selectedWorkflow={selectedWorkflow}
- onSetStep={onSetStep}
+ onSetStep={onSetStep}
onSetWorkflow={onSetWorkflow} />
</StepContent>
</Step>
<Step>
<StepLabel>Select inputs</StepLabel>
<StepContent>
- <RunProcessSecondStepForm />
- {/* <RunProcessSecondStep onSetStep={onSetStep} onRunProcess={onRunProcess} /> */}
+ <RunProcessSecondStepForm
+ goBack={() => onSetStep(0)}
+ runProcess={runProcess} />
</StepContent>
</Step>
</Stepper>;
\ No newline at end of file
onSetWorkflow: (workflow: WorkflowResource) => {
dispatch<any>(setWorkflow(workflow));
},
- onRunProcess: () => {
-
+ runProcess: () => {
+ console.log('run process!');
}
});
// 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';
+
+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 mapStateToProps = (state: RootState): RunProcessSecondStepFormDataProps => ({
+ inputs: state.runProcessPanel.inputs,
+ valid: isValid(RUN_PROCESS_BASIC_FORM)(state.form) &&
+ isValid(RUN_PROCESS_INPUTS_FORM)(state.form),
+});
-const RunProcessSecondStep = withStyles(styles)(
- ({ onSetStep, classes }: RunProcessSecondStepProps) =>
+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} />
</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>);