1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { RootState } from 'store/store';
6 import { connect } from 'react-redux';
7 import { getProcess, getSubprocesses, Process, getProcessStatus } from 'store/processes/process';
8 import { Dispatch } from 'redux';
9 import { openProcessContextMenu } from 'store/context-menu/context-menu-actions';
11 ProcessPanelRootDataProps,
12 ProcessPanelRootActionProps,
14 } from './process-panel-root';
16 getProcessPanelCurrentUuid,
17 ProcessPanel as ProcessPanelState
18 } from 'store/process-panel/process-panel';
19 import { groupBy } from 'lodash';
22 loadOutputDefinitions,
24 toggleProcessPanelFilter,
27 } from 'store/process-panel/process-panel-actions';
28 import { cancelRunningWorkflow, resumeOnHoldWorkflow, startWorkflow } from 'store/processes/processes-actions';
29 import { navigateToLogCollection, pollProcessLogs, setProcessLogsPanelFilter } from 'store/process-logs-panel/process-logs-panel-actions';
30 import { snackbarActions, SnackbarKind } from 'store/snackbar/snackbar-actions';
32 const mapStateToProps = ({ router, auth, resources, processPanel, processLogsPanel }: RootState): ProcessPanelRootDataProps => {
33 const uuid = getProcessPanelCurrentUuid(router) || '';
34 const subprocesses = getSubprocesses(uuid)(resources);
36 process: getProcess(uuid)(resources),
37 subprocesses: subprocesses.filter(subprocess => processPanel.filters[getProcessStatus(subprocess)]),
38 filters: getFilters(processPanel, subprocesses),
39 processLogsPanel: processLogsPanel,
41 inputRaw: processPanel.inputRaw,
42 inputParams: processPanel.inputParams,
43 outputRaw: processPanel.outputRaw,
44 outputDefinitions: processPanel.outputDefinitions,
45 outputParams: processPanel.outputParams,
46 nodeInfo: processPanel.nodeInfo,
50 const mapDispatchToProps = (dispatch: Dispatch): ProcessPanelRootActionProps => ({
51 onCopyToClipboard: (message: string) => {
52 dispatch<any>(snackbarActions.OPEN_SNACKBAR({
55 kind: SnackbarKind.SUCCESS,
58 onContextMenu: (event, process) => {
59 dispatch<any>(openProcessContextMenu(event, process));
62 dispatch<any>(toggleProcessPanelFilter(status));
64 cancelProcess: (uuid) => dispatch<any>(cancelRunningWorkflow(uuid)),
65 startProcess: (uuid) => dispatch<any>(startWorkflow(uuid)),
66 resumeOnHoldWorkflow: (uuid) => dispatch<any>(resumeOnHoldWorkflow(uuid)),
67 onLogFilterChange: (filter) => dispatch(setProcessLogsPanelFilter(filter.value)),
68 navigateToLog: (uuid) => dispatch<any>(navigateToLogCollection(uuid)),
69 loadInputs: (containerRequest) => dispatch<any>(loadInputs(containerRequest)),
70 loadOutputs: (containerRequest) => dispatch<any>(loadOutputs(containerRequest)),
71 loadOutputDefinitions: (containerRequest) => dispatch<any>(loadOutputDefinitions(containerRequest)),
72 updateOutputParams: () => dispatch<any>(updateOutputParams()),
73 loadNodeJson: (containerRequest) => dispatch<any>(loadNodeJson(containerRequest)),
74 pollProcessLogs: (processUuid) => dispatch<any>(pollProcessLogs(processUuid)),
77 const getFilters = (processPanel: ProcessPanelState, processes: Process[]) => {
78 const grouppedProcesses = groupBy(processes, getProcessStatus);
80 .keys(processPanel.filters)
83 value: (grouppedProcesses[filter] || []).length,
84 checked: processPanel.filters[filter],
89 export const ProcessPanel = connect(mapStateToProps, mapDispatchToProps)(ProcessPanelRoot);