remove SshKey interface and change object type
[arvados-workbench2.git] / src / views / run-process-panel / inputs / file-input.tsx
index 140a9d031cb7f7f90dcc6f02166cf50dd756883b..7e0925e8e9e175481887c1c9988be0eee329f82e 100644 (file)
@@ -10,7 +10,7 @@ import {
     CWLType
 } from '~/models/workflow';
 import { Field } from 'redux-form';
-import { require } from '~/validators/require';
+import { ERROR_MESSAGE } from '~/validators/require';
 import { Input, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@material-ui/core';
 import { GenericInputProps, GenericInput } from './generic-input';
 import { ProjectsTreePicker } from '~/views-components/projects-tree-picker/projects-tree-picker';
@@ -19,7 +19,6 @@ import { initProjectsTreePicker } from '~/store/tree-picker/tree-picker-actions'
 import { TreeItem } from '~/components/tree/tree';
 import { ProjectsTreePickerItem } from '~/views-components/projects-tree-picker/generic-projects-tree-picker';
 import { CollectionFile, CollectionFileType } from '~/models/collection-file';
-import { getFileFullPath } from '~/services/collection-service/collection-service-files-response';
 
 export interface FileInputProps {
     input: FileCommandInputParameter;
@@ -29,15 +28,15 @@ export const FileInput = ({ input }: FileInputProps) =>
         name={input.id}
         commandInput={input}
         component={FileInputComponent}
-        format={(value?: File) => value ? value.location : ''}
+        format={(value?: File) => value ? value.basename : ''}
         parse={(file: CollectionFile): File => ({
             class: CWLType.FILE,
-            location: `keep:${getFileFullPath(file)}`,
+            location: `keep:${file.id}`,
             basename: file.name,
         })}
         validate={[
             isRequiredInput(input)
-                ? require
+                ? (file?: File) => file ? undefined : ERROR_MESSAGE
                 : () => undefined,
         ]} />;
 
@@ -92,10 +91,11 @@ const FileInputComponent = connect()(
                     <Input
                         readOnly
                         fullWidth
+                        disabled={props.commandInput.disabled}
                         value={props.input.value}
                         error={props.meta.touched && !!props.meta.error}
-                        onClick={this.openDialog}
-                        onKeyPress={this.openDialog} />}
+                        onClick={!props.commandInput.disabled ? this.openDialog : undefined}
+                        onKeyPress={!props.commandInput.disabled ? this.openDialog : undefined} />}
                 {...this.props} />;
         }