Merge branch '19865-search-clearing-fix'. Closes #19865.
[arvados-workbench2.git] / src / store / process-panel / process-panel-actions.ts
index 64fc493fb2ea4f5b41a207cfecf63fb294f0d51c..b361f7acae0cbd8478fc7ed4896be92467863601 100644 (file)
@@ -17,9 +17,9 @@ import { initProcessLogsPanel, processLogsPanelActions } from "store/process-log
 import { CollectionFile } from "models/collection-file";
 import { ContainerRequestResource } from "models/container-request";
 import { CommandOutputParameter } from 'cwlts/mappings/v1.0/CommandOutputParameter';
-import { CommandInputParameter, getIOParamId } from 'models/workflow';
+import { CommandInputParameter, getIOParamId, WorkflowInputsData } from 'models/workflow';
 import { getIOParamDisplayValue, ProcessIOParameter } from "views/process-panel/process-io-card";
-import { OutputDetails } from "./process-panel";
+import { OutputDetails, NodeInstanceType, NodeInfo } from "./process-panel";
 import { AuthState } from "store/auth/auth-reducer";
 
 export const processPanelActions = unionize({
@@ -27,11 +27,12 @@ export const processPanelActions = unionize({
     SET_PROCESS_PANEL_CONTAINER_REQUEST_UUID: ofType<string>(),
     SET_PROCESS_PANEL_FILTERS: ofType<string[]>(),
     TOGGLE_PROCESS_PANEL_FILTER: ofType<string>(),
-    SET_INPUT_RAW: ofType<CommandInputParameter[] | null>(),
+    SET_INPUT_RAW: ofType<WorkflowInputsData | null>(),
     SET_INPUT_PARAMS: ofType<ProcessIOParameter[] | null>(),
     SET_OUTPUT_RAW: ofType<OutputDetails | null>(),
     SET_OUTPUT_DEFINITIONS: ofType<CommandOutputParameter[]>(),
     SET_OUTPUT_PARAMS: ofType<ProcessIOParameter[] | null>(),
+    SET_NODE_INFO: ofType<NodeInfo>(),
 });
 
 export type ProcessPanelAction = UnionOf<typeof processPanelActions>;
@@ -67,7 +68,7 @@ export const loadInputs = (containerRequest: ContainerRequestResource) =>
 
 export const loadOutputs = (containerRequest: ContainerRequestResource) =>
     async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
-        const noOutputs = {rawOutputs: {}};
+        const noOutputs = { rawOutputs: {} };
         if (!containerRequest.outputUuid) {
             dispatch<ProcessPanelAction>(processPanelActions.SET_OUTPUT_RAW(noOutputs));
             return;
@@ -102,6 +103,34 @@ export const loadOutputs = (containerRequest: ContainerRequestResource) =>
         }
     };
 
+
+export const loadNodeJson = (containerRequest: ContainerRequestResource) =>
+    async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
+        const noLog = { nodeInfo: null };
+        if (!containerRequest.logUuid) {
+            dispatch<ProcessPanelAction>(processPanelActions.SET_NODE_INFO(noLog));
+            return;
+        };
+        try {
+            const filesPromise = services.collectionService.files(containerRequest.logUuid);
+            const collectionPromise = services.collectionService.get(containerRequest.logUuid);
+            const [files] = await Promise.all([filesPromise, collectionPromise]);
+
+            // Fetch node.json from keep
+            const nodeFile = files.find((file) => file.name === 'node.json') as CollectionFile | undefined;
+            let nodeData = nodeFile ? await services.collectionService.getFileContents(nodeFile) : undefined;
+            if (nodeData && (nodeData = JSON.parse(nodeData))) {
+                dispatch<ProcessPanelAction>(processPanelActions.SET_NODE_INFO({
+                    nodeInfo: nodeData as NodeInstanceType
+                }));
+            } else {
+                dispatch<ProcessPanelAction>(processPanelActions.SET_NODE_INFO(noLog));
+            }
+        } catch {
+            dispatch<ProcessPanelAction>(processPanelActions.SET_NODE_INFO(noLog));
+        }
+    };
+
 export const loadOutputDefinitions = (containerRequest: ContainerRequestResource) =>
     async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
         if (containerRequest && containerRequest.mounts) {