// Copyright (C) The Arvados Authors. All rights reserved. // // SPDX-License-Identifier: AGPL-3.0 import React from 'react'; import { reduxForm, InjectedFormProps } from 'redux-form'; import { CommandInputParameter, CWLType, IntCommandInputParameter, BooleanCommandInputParameter, FileCommandInputParameter, DirectoryCommandInputParameter, DirectoryArrayCommandInputParameter, FloatArrayCommandInputParameter, IntArrayCommandInputParameter } from 'models/workflow'; import { IntInput } from 'views/run-process-panel/inputs/int-input'; import { StringInput } from 'views/run-process-panel/inputs/string-input'; import { StringCommandInputParameter, FloatCommandInputParameter, isPrimitiveOfType, WorkflowInputsData, EnumCommandInputParameter, isArrayOfType, StringArrayCommandInputParameter, FileArrayCommandInputParameter, getEnumType } from '../../models/workflow'; 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'; import { compose } from 'redux'; import { CustomStyleRulesCallback } from 'common/custom-theme'; import { Grid } from '@mui/material'; import { WithStyles } from '@mui/styles'; import withStyles from '@mui/styles/withStyles'; import { EnumInput } from './inputs/enum-input'; import { DirectoryInput } from './inputs/directory-input'; import { StringArrayInput } from './inputs/string-array-input'; import { createStructuredSelector, createSelector } from 'reselect'; import { FileArrayInput } from './inputs/file-array-input'; import { DirectoryArrayInput } from './inputs/directory-array-input'; import { FloatArrayInput } from './inputs/float-array-input'; import { IntArrayInput } from './inputs/int-array-input'; export const RUN_PROCESS_INPUTS_FORM = 'runProcessInputsForm'; export interface RunProcessInputFormProps { inputs: CommandInputParameter[]; } const inputsSelector = (props: RunProcessInputFormProps) => props.inputs; const initialValuesSelector = createSelector( inputsSelector, inputs => inputs.reduce( (values, input) => ({ ...values, [input.id]: input.value || input.default }), {})); const propsSelector = createStructuredSelector({ initialValues: initialValuesSelector, }); const mapStateToProps = (_: any, props: RunProcessInputFormProps) => propsSelector(props); export const RunProcessInputsForm = compose( connect(mapStateToProps), reduxForm({ form: RUN_PROCESS_INPUTS_FORM }))( (props: InjectedFormProps & RunProcessInputFormProps) =>
{props.inputs.map(input => )}
); type CssRules = 'inputItem'; const styles: CustomStyleRulesCallback = theme => ({ inputItem: { marginBottom: theme.spacing(2), } }); const InputItem = withStyles(styles)( (props: WithStyles & { input: CommandInputParameter }) => {getInputComponent(props.input)} ); const getInputComponent = (input: CommandInputParameter) => { switch (true) { case isPrimitiveOfType(input, CWLType.BOOLEAN): return ; case isPrimitiveOfType(input, CWLType.INT): case isPrimitiveOfType(input, CWLType.LONG): return ; case isPrimitiveOfType(input, CWLType.FLOAT): case isPrimitiveOfType(input, CWLType.DOUBLE): return ; case isPrimitiveOfType(input, CWLType.STRING): return ; case isPrimitiveOfType(input, CWLType.FILE): return ; case isPrimitiveOfType(input, CWLType.DIRECTORY): return ; case getEnumType(input) !== null: return ; case isArrayOfType(input, CWLType.STRING): return ; case isArrayOfType(input, CWLType.INT): case isArrayOfType(input, CWLType.LONG): return ; case isArrayOfType(input, CWLType.FLOAT): case isArrayOfType(input, CWLType.DOUBLE): return ; case isArrayOfType(input, CWLType.FILE): return ; case isArrayOfType(input, CWLType.DIRECTORY): return ; default: return null; } };