Extract FileInput's parse function
authorMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Thu, 29 Nov 2018 13:22:51 +0000 (14:22 +0100)
committerMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Thu, 29 Nov 2018 13:22:51 +0000 (14:22 +0100)
Feature #14524

Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski@contractors.roche.com>

src/views/run-process-panel/inputs/file-input.tsx

index 0e567137f0a79dda6388c8bd470004178d41ab3f..e5fa9663ceeaf8e613a3ac49decaedcf0facd1d0 100644 (file)
@@ -29,11 +29,7 @@ export const FileInput = ({ input }: FileInputProps) =>
         commandInput={input}
         component={FileInputComponent}
         format={format}
-        parse={(file: CollectionFile): File => ({
-            class: CWLType.FILE,
-            location: `keep:${file.id}`,
-            basename: file.name,
-        })}
+        parse={parse}
         validate={[
             isRequiredInput(input)
                 ? (file?: File) => file ? undefined : ERROR_MESSAGE
@@ -42,6 +38,12 @@ export const FileInput = ({ input }: FileInputProps) =>
 
 const format = (value?: File) => value ? value.basename : '';
 
+const parse = (file: CollectionFile): File => ({
+    class: CWLType.FILE,
+    location: `keep:${file.id}`,
+    basename: file.name,
+});
+
 interface FileInputComponentState {
     open: boolean;
     file?: CollectionFile;