input.type.type === 'array' &&
input.type.items === type);
+export const getEnumType = (input: GenericCommandInputParameter<any, any>) => {
+ if (input.type instanceof Array) {
+ const f = input.type.filter(t => typeof t === 'object' &&
+ !(t instanceof Array) &&
+ t.type === 'enum');
+ if (f.length > 0) {
+ return f[0];
+ }
+ } else {
+ if ((typeof input.type === 'object' &&
+ !(input.type instanceof Array) &&
+ input.type.type === 'enum')) {
+ return input.type;
+ }
+ }
+ return null;
+};
+
export const stringifyInputType = ({ type }: CommandInputParameter) => {
if (typeof type === 'string') {
return type;
isPrimitiveOfType,
StringArrayCommandInputParameter,
StringCommandInputParameter,
+ getEnumType
} from "models/workflow";
import { CommandOutputParameter } from 'cwlts/mappings/v1.0/CommandOutputParameter';
import { File } from 'models/workflow';
<CircularProgress />
</Grid>}
{/* Once loaded, either raw or params may still be empty
- * Raw when all params are empty
- * Params when raw is provided by containerRequest properties but workflow mount is absent for preview
- */}
+ * Raw when all params are empty
+ * Params when raw is provided by containerRequest properties but workflow mount is absent for preview
+ */}
{(!loading && (hasRaw || hasParams)) &&
<>
<Tabs value={mainProcTabState} onChange={handleMainProcTabChange} variant="fullWidth" className={classes.symmetricTabs}>
[directoryToProcessIOValue(directory, auth, pdh)] :
[{ display: <EmptyValue /> }];
- case typeof input.type === 'object' &&
- !(input.type instanceof Array) &&
- input.type.type === 'enum':
+ case getEnumType(input) !== null:
const enumValue = (input as EnumCommandInputParameter).value;
return enumValue !== undefined && enumValue ?
[{ display: <pre>{enumValue}</pre> }] :
// Convert each main and secondaryFiles into array of ProcessIOValue preserving ordering
let fileArrayValues: ProcessIOValue[] = [];
- for(let i = 0; i < fileArrayMainFiles.length; i++) {
+ for (let i = 0; i < fileArrayMainFiles.length; i++) {
const secondaryFiles = ((fileArrayMainFiles[i] as unknown) as FileWithSecondaryFiles)?.secondaryFiles || [];
fileArrayValues.push(
// Pass firstMainFilePdh to secondary files and every main file besides the first to hide pdh if equal
import React from 'react';
import { Field } from 'redux-form';
+import { memoize } from 'lodash/fp';
+import { require } from 'validators/require';
import { Select, MenuItem } from '@material-ui/core';
-import { EnumCommandInputParameter, CommandInputEnumSchema } from 'models/workflow';
+import { EnumCommandInputParameter, CommandInputEnumSchema, isRequiredInput, getEnumType } from 'models/workflow';
import { GenericInputProps, GenericInput } from './generic-input';
export interface EnumInputProps {
input: EnumCommandInputParameter;
}
+
+const getValidation = memoize(
+ (input: EnumCommandInputParameter) => ([
+ isRequiredInput(input)
+ ? require
+ : () => undefined,
+ ]));
+
export const EnumInput = ({ input }: EnumInputProps) =>
<Field
name={input.id}
commandInput={input}
component={EnumInputComponent}
+ validate={getValidation(input)}
/>;
const EnumInputComponent = (props: GenericInputProps) =>
{...props} />;
const Input = (props: GenericInputProps) => {
- const type = props.commandInput.type as CommandInputEnumSchema;
+ const type = getEnumType(props.commandInput) as CommandInputEnumSchema;
return <Select
value={props.input.value}
onChange={props.input.onChange}
};
/**
- * Values in workflow definition have an absolute form, for example:
- *
+ * Values in workflow definition have an absolute form, for example:
+ *
* ```#input_collector.cwl/enum_type/Pathway table```
- *
+ *
* We want a value that is in form accepted by backend.
* According to the example above, the correct value is:
- *
+ *
* ```Pathway table```
*/
const extractValue = (symbol: string) => symbol.split('/').pop();
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 } from '../../models/workflow';
+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';
case isPrimitiveOfType(input, CWLType.DIRECTORY):
return <DirectoryInput options={{ showOnlyOwned: false, showOnlyWritable: false }} input={input as DirectoryCommandInputParameter} />;
- case typeof input.type === 'object' &&
- !(input.type instanceof Array) &&
- input.type.type === 'enum':
+ case getEnumType(input) !== null:
return <EnumInput input={input as EnumCommandInputParameter} />;
case isArrayOfType(input, CWLType.STRING):