X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/fc3d9ac09fbb1cdc4fb4b00f2f704795ad365110..465a61ffcf1a815bf68daeb7bcbf31dd9721cdf4:/src/views/process-panel/process-panel.tsx

diff --git a/src/views/process-panel/process-panel.tsx b/src/views/process-panel/process-panel.tsx
index 9f1d0adb7a..6e2d75c6cb 100644
--- a/src/views/process-panel/process-panel.tsx
+++ b/src/views/process-panel/process-panel.tsx
@@ -2,29 +2,82 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import * as React from 'react';
-import { RootState } from '~/store/store';
+import { RootState } from 'store/store';
 import { connect } from 'react-redux';
-import { getProcess, getSubprocesses } from '~/store/processes/process';
+import { getProcess, getSubprocesses, Process, getProcessStatus } from 'store/processes/process';
 import { Dispatch } from 'redux';
-import { openProcessContextMenu } from '~/store/context-menu/context-menu-actions';
-import { matchProcessRoute } from '~/routes/routes';
-import { ProcessPanelRootDataProps, ProcessPanelRootActionProps, ProcessPanelRoot } from './process-panel-root';
+import { openProcessContextMenu } from 'store/context-menu/context-menu-actions';
+import {
+    ProcessPanelRootDataProps,
+    ProcessPanelRootActionProps,
+    ProcessPanelRoot
+} from './process-panel-root';
+import {
+    getProcessPanelCurrentUuid,
+    ProcessPanel as ProcessPanelState
+} from 'store/process-panel/process-panel';
+import { groupBy } from 'lodash';
+import {
+    loadInputs,
+    loadOutputDefinitions,
+    loadOutputs,
+    toggleProcessPanelFilter,
+    updateOutputParams,
+} from 'store/process-panel/process-panel-actions';
+import { cancelRunningWorkflow } from 'store/processes/processes-actions';
+import { navigateToLogCollection, setProcessLogsPanelFilter } from 'store/process-logs-panel/process-logs-panel-actions';
+import { snackbarActions, SnackbarKind } from 'store/snackbar/snackbar-actions';
 
-const mapStateToProps = ({ router, resources }: RootState): ProcessPanelRootDataProps => {
-    const pathname = router.location ? router.location.pathname : '';
-    const match = matchProcessRoute(pathname);
-    const uuid = match ? match.params.id : '';
+const mapStateToProps = ({ router, auth, resources, processPanel, processLogsPanel }: RootState): ProcessPanelRootDataProps => {
+    const uuid = getProcessPanelCurrentUuid(router) || '';
+    const subprocesses = getSubprocesses(uuid)(resources);
     return {
         process: getProcess(uuid)(resources),
-        subprocesses: getSubprocesses(uuid)(resources)
+        subprocesses: subprocesses.filter(subprocess => processPanel.filters[getProcessStatus(subprocess)]),
+        filters: getFilters(processPanel, subprocesses),
+        processLogsPanel: processLogsPanel,
+        auth: auth,
+        inputRaw: processPanel.inputRaw,
+        inputParams: processPanel.inputParams,
+        outputRaw: processPanel.outputRaw,
+        outputDefinitions: processPanel.outputDefinitions,
+        outputParams: processPanel.outputParams,
     };
 };
 
 const mapDispatchToProps = (dispatch: Dispatch): ProcessPanelRootActionProps => ({
-    onContextMenu: (event: React.MouseEvent<HTMLElement>) => {
-        dispatch<any>(openProcessContextMenu(event));
-    }
+    onCopyToClipboard: (message: string) => {
+        dispatch<any>(snackbarActions.OPEN_SNACKBAR({
+            message,
+            hideDuration: 2000,
+            kind: SnackbarKind.SUCCESS,
+        }));
+    },
+    onContextMenu: (event, process) => {
+        dispatch<any>(openProcessContextMenu(event, process));
+    },
+    onToggle: status => {
+        dispatch<any>(toggleProcessPanelFilter(status));
+    },
+    cancelProcess: (uuid) => dispatch<any>(cancelRunningWorkflow(uuid)),
+    onLogFilterChange: (filter) => dispatch(setProcessLogsPanelFilter(filter.value)),
+    navigateToLog: (uuid) => dispatch<any>(navigateToLogCollection(uuid)),
+    loadInputs: (containerRequest) => dispatch<any>(loadInputs(containerRequest)),
+    loadOutputs: (containerRequest) => dispatch<any>(loadOutputs(containerRequest)),
+    loadOutputDefinitions: (containerRequest) => dispatch<any>(loadOutputDefinitions(containerRequest)),
+    updateOutputParams: () => dispatch<any>(updateOutputParams())
 });
 
+const getFilters = (processPanel: ProcessPanelState, processes: Process[]) => {
+    const grouppedProcesses = groupBy(processes, getProcessStatus);
+    return Object
+        .keys(processPanel.filters)
+        .map(filter => ({
+            label: filter,
+            value: (grouppedProcesses[filter] || []).length,
+            checked: processPanel.filters[filter],
+            key: filter,
+        }));
+    };
+
 export const ProcessPanel = connect(mapStateToProps, mapDispatchToProps)(ProcessPanelRoot);
