17119: Merge branch 'master' into 17119-support-filter-groups
[arvados-workbench2.git] / src / views / run-process-panel / inputs / file-array-input.tsx
index be58eee21262a008b2eeccb9953a279bf098e4df..14d16824966cfaa6fcd4e4d8ee67753e5e4619d3 100644 (file)
@@ -11,7 +11,7 @@ import {
 } from '~/models/workflow';
 import { Field } from 'redux-form';
 import { ERROR_MESSAGE } from '~/validators/require';
-import { Input, Dialog, DialogTitle, DialogContent, DialogActions, Button, Divider, Grid, WithStyles, Typography } from '@material-ui/core';
+import { Input, Dialog, DialogTitle, DialogContent, DialogActions, Button, Divider, WithStyles, Typography } from '@material-ui/core';
 import { GenericInputProps, GenericInput } from './generic-input';
 import { ProjectsTreePicker } from '~/views-components/projects-tree-picker/projects-tree-picker';
 import { connect, DispatchProp } from 'react-redux';
@@ -39,10 +39,10 @@ export const FileArrayInput = ({ input }: FileArrayInputProps) =>
         format={formatFiles}
         validate={validationSelector(input)} />;
 
-const parseFiles = (files: CollectionFile[]) =>
-    files.length > 0
-        ? files.map(parse)
-        : undefined;
+const parseFiles = (files: CollectionFile[] | string) =>
+    typeof files === 'string'
+        ? undefined
+        : files.map(parse);
 
 const parse = (file: CollectionFile): File => ({
     class: CWLType.FILE,
@@ -51,7 +51,8 @@ const parse = (file: CollectionFile): File => ({
     path: file.path,
 });
 
-const formatFiles = (files: File[] = []) => files.map(format);
+const formatFiles = (files: File[] = []) =>
+    files.map(format);
 
 const format = (file: File): CollectionFile => ({
     id: file.location
@@ -116,7 +117,6 @@ const FileArrayInputComponent = connect(mapStateToProps)(
             this.setState({ open: true });
         }
 
-
         closeDialog = () => {
             this.setState({ open: false });
         }
@@ -193,7 +193,8 @@ const FileArrayInputComponent = connect(mapStateToProps)(
 
         chipsInput = () =>
             <ChipsInput
-                value={this.props.input.value}
+                values={this.props.input.value}
+                disabled={this.props.commandInput.disabled}
                 onChange={noop}
                 createNewValue={identity}
                 getLabel={(file: CollectionFile) => file.name}
@@ -204,8 +205,9 @@ const FileArrayInputComponent = connect(mapStateToProps)(
                 {...props}
                 error={this.props.meta.touched && !!this.props.meta.error}
                 readOnly
-                onClick={this.openDialog}
-                onKeyPress={this.openDialog}
+                disabled={this.props.commandInput.disabled}
+                onClick={!this.props.commandInput.disabled ? this.openDialog : undefined}
+                onKeyPress={!this.props.commandInput.disabled ? this.openDialog : undefined}
                 onBlur={this.props.input.onBlur} />
 
         dialog = () =>
@@ -261,7 +263,7 @@ const FileArrayInputComponent = connect(mapStateToProps)(
                     </div>
                     <Divider />
                     <div className={classes.chips}>
-                        <Typography variant='subheading'>Selected files ({this.state.files.length}):</Typography>
+                        <Typography variant='subtitle1'>Selected files ({this.state.files.length}):</Typography>
                         <Chips
                             orderable
                             deletable