15803: INIT->INIT_USER, CONFIG->SET_CONFIG, remove config reducer
[arvados.git] / src / views-components / process-input-dialog / process-input-dialog.tsx
index edb4bc6835892e81bd7c9bebe5fdd5213da57041..a2d5940777ed4286586517732e80e42e0b807745 100644 (file)
@@ -8,6 +8,8 @@ import { WithDialogProps } from '~/store/dialog/with-dialog';
 import { withDialog } from "~/store/dialog/with-dialog";
 import { PROCESS_INPUT_DIALOG_NAME } from '~/store/processes/process-input-actions';
 import { RunProcessInputsForm } from "~/views/run-process-panel/run-process-inputs-form";
+import { MOUNT_PATH_CWL_WORKFLOW, MOUNT_PATH_CWL_INPUT } from "~/models/process";
+import { getWorkflowInputs } from "~/models/workflow";
 
 export const ProcessInputDialog = withDialog(PROCESS_INPUT_DIALOG_NAME)(
     (props: WithDialogProps<any>) =>
@@ -31,17 +33,18 @@ export const ProcessInputDialog = withDialog(PROCESS_INPUT_DIALOG_NAME)(
         </Dialog>
 );
 
-const getInputs = (data: any) =>
-    data && data.mounts.varLibCwlWorkflowJson ? data.mounts.varLibCwlWorkflowJson.content.graph.filter((a: any) => a.class === 'Workflow')[0].inputs.map((it: any) => (
-        { type: it.type, id: it.id, label: it.label, value: getInputValue(it.id, data.mounts.varLibCwlCwlInputJson.content), disabled: true }
-    )) : [];
-
-const snakeToCamel = (s: string) => {
-    const a = s.split('/');
-    return a[1].replace(/(\_\w)/g, (m: string) => m[1].toUpperCase());
+const getInputs = (data: any) => {
+    if (!data || !data.mounts || !data.mounts[MOUNT_PATH_CWL_WORKFLOW]) { return []; }
+    const inputs = getWorkflowInputs(data.mounts[MOUNT_PATH_CWL_WORKFLOW].content);
+    return inputs ? inputs.map(
+        (it: any) => (
+            {
+                type: it.type,
+                id: it.id,
+                label: it.label,
+                value: data.mounts[MOUNT_PATH_CWL_INPUT].content[it.id],
+                disabled: true
+            }
+        )
+    ) : [];
 };
-
-export const getInputValue = (id: string, data: any) => {
-    const a = snakeToCamel(id);
-    return data[a];
-};
\ No newline at end of file