import { FloatInput } from '~/views/run-process-panel/inputs/float-input';
import { BooleanInput } from './inputs/boolean-input';
import { FileInput } from './inputs/file-input';
+import { connect } from 'react-redux';
const RUN_PROCESS_INPUTS_FORM = 'runProcessInputsForm';
inputs: CommandInputParameter[];
}
-export const RunProcessInputsForm = reduxForm<any, RunProcessInputFormProps>({
- form: RUN_PROCESS_INPUTS_FORM
-})((props: InjectedFormProps & RunProcessInputFormProps) =>
- <form>
- {props.inputs.map(input => {
- switch (true) {
- case input.type === CWLType.BOOLEAN:
- return <BooleanInput key={input.id} input={input as BooleanCommandInputParameter} />;
- case input.type === CWLType.INT:
- case input.type === CWLType.LONG:
- return <IntInput key={input.id} input={input as IntCommandInputParameter} />;
- case input.type === CWLType.FLOAT:
- case input.type === CWLType.DOUBLE:
- return <FloatInput key={input.id} input={input as FloatCommandInputParameter} />;
- case input.type === CWLType.STRING:
- return <StringInput key={input.id} input={input as StringCommandInputParameter} />;
- case input.type === CWLType.FILE:
- return <FileInput key={input.id} input={input as FileCommandInputParameter} />;
- default:
- return null;
- }
- })}
- </form>);
\ No newline at end of file
+export const RunProcessInputsForm = connect(
+ (_: any, props: RunProcessInputFormProps) => ({
+ initialValues: props.inputs.reduce(
+ (values, input) => ({ ...values, [input.id]: input.default }),
+ {}),
+ }))(
+ reduxForm<any, RunProcessInputFormProps>({
+ form: RUN_PROCESS_INPUTS_FORM
+ })((props: InjectedFormProps & RunProcessInputFormProps) =>
+ <form>
+ {props.inputs.map(input => {
+ switch (true) {
+ case input.type === CWLType.BOOLEAN:
+ return <BooleanInput key={input.id} input={input as BooleanCommandInputParameter} />;
+ case input.type === CWLType.INT:
+ case input.type === CWLType.LONG:
+ return <IntInput key={input.id} input={input as IntCommandInputParameter} />;
+ case input.type === CWLType.FLOAT:
+ case input.type === CWLType.DOUBLE:
+ return <FloatInput key={input.id} input={input as FloatCommandInputParameter} />;
+ case input.type === CWLType.STRING:
+ return <StringInput key={input.id} input={input as StringCommandInputParameter} />;
+ case input.type === CWLType.FILE:
+ return <FileInput key={input.id} input={input as FileCommandInputParameter} />;
+ default:
+ return null;
+ }
+ })}
+ </form>));
\ No newline at end of file