X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/c8d7659860af3b12d87ef29478bc1b825a9b3d2f..2a7fd99c212c33a1ec9911f8529fa5afc59a7bb2:/src/store/process-panel/process-panel-actions.ts diff --git a/src/store/process-panel/process-panel-actions.ts b/src/store/process-panel/process-panel-actions.ts index 64fc493fb2..d8042ba5ef 100644 --- a/src/store/process-panel/process-panel-actions.ts +++ b/src/store/process-panel/process-panel-actions.ts @@ -12,14 +12,14 @@ import { navigateTo, navigateToWorkflows } from 'store/navigation/navigation-act import { snackbarActions } from 'store/snackbar/snackbar-actions'; import { SnackbarKind } from '../snackbar/snackbar-actions'; import { showWorkflowDetails } from 'store/workflow-panel/workflow-panel-actions'; -import { loadSubprocessPanel } from "../subprocess-panel/subprocess-panel-actions"; +import { loadSubprocessPanel, subprocessPanelActions } from "../subprocess-panel/subprocess-panel-actions"; import { initProcessLogsPanel, processLogsPanelActions } from "store/process-logs-panel/process-logs-panel-actions"; 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(), SET_PROCESS_PANEL_FILTERS: ofType(), TOGGLE_PROCESS_PANEL_FILTER: ofType(), - SET_INPUT_RAW: ofType(), + SET_INPUT_RAW: ofType(), SET_INPUT_PARAMS: ofType(), SET_OUTPUT_RAW: ofType(), SET_OUTPUT_DEFINITIONS: ofType(), SET_OUTPUT_PARAMS: ofType(), + SET_NODE_INFO: ofType(), }); export type ProcessPanelAction = UnionOf; @@ -39,7 +40,12 @@ export type ProcessPanelAction = UnionOf; export const toggleProcessPanelFilter = processPanelActions.TOGGLE_PROCESS_PANEL_FILTER; export const loadProcessPanel = (uuid: string) => - async (dispatch: Dispatch) => { + async (dispatch: Dispatch, getState: () => RootState) => { + // Reset subprocess data explorer if navigating to new process + // Avoids resetting pagination when refreshing same process + if (getState().processPanel.containerRequestUuid !== uuid) { + dispatch(subprocessPanelActions.CLEAR()); + } dispatch(processPanelActions.RESET_PROCESS_PANEL()); dispatch(processLogsPanelActions.RESET_PROCESS_LOGS_PANEL()); dispatch(processPanelActions.SET_PROCESS_PANEL_CONTAINER_REQUEST_UUID(uuid)); @@ -67,7 +73,7 @@ export const loadInputs = (containerRequest: ContainerRequestResource) => export const loadOutputs = (containerRequest: ContainerRequestResource) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { - const noOutputs = {rawOutputs: {}}; + const noOutputs = { rawOutputs: {} }; if (!containerRequest.outputUuid) { dispatch(processPanelActions.SET_OUTPUT_RAW(noOutputs)); return; @@ -102,6 +108,34 @@ export const loadOutputs = (containerRequest: ContainerRequestResource) => } }; + +export const loadNodeJson = (containerRequest: ContainerRequestResource) => + async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { + const noLog = { nodeInfo: null }; + if (!containerRequest.logUuid) { + dispatch(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(processPanelActions.SET_NODE_INFO({ + nodeInfo: nodeData as NodeInstanceType + })); + } else { + dispatch(processPanelActions.SET_NODE_INFO(noLog)); + } + } catch { + dispatch(processPanelActions.SET_NODE_INFO(noLog)); + } + }; + export const loadOutputDefinitions = (containerRequest: ContainerRequestResource) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { if (containerRequest && containerRequest.mounts) { @@ -136,7 +170,7 @@ export const initProcessPanelFilters = processPanelActions.SET_PROCESS_PANEL_FIL ProcessStatus.CANCELLED ]); -const formatInputData = (inputs: CommandInputParameter[], auth: AuthState): ProcessIOParameter[] => { +export const formatInputData = (inputs: CommandInputParameter[], auth: AuthState): ProcessIOParameter[] => { return inputs.map(input => { return { id: getIOParamId(input), @@ -146,7 +180,7 @@ const formatInputData = (inputs: CommandInputParameter[], auth: AuthState): Proc }); }; -const formatOutputData = (definitions: CommandOutputParameter[], values: any, pdh: string | undefined, auth: AuthState): ProcessIOParameter[] => { +export const formatOutputData = (definitions: CommandOutputParameter[], values: any, pdh: string | undefined, auth: AuthState): ProcessIOParameter[] => { return definitions.map(output => { return { id: getIOParamId(output),