X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/909ee82b3c7c7fd033c6ab2e82b4fb92f383e191..cba2e466c8708c1a89ae2d766d31fa9d04d6f3be:/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 5829a0cd..575c6591 100644
--- a/src/views/process-panel/process-panel.tsx
+++ b/src/views/process-panel/process-panel.tsx
@@ -2,41 +2,88 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import * as React from 'react';
-import { } from '@material-ui/core';
-import { Grid } from '@material-ui/core';
-import { ProcessInformationCard } from '~/views-components/process-information-card/process-information-card';
-import { ProcessSubprocesses } from '~/views-components/process-subprocesses/process-subprocesses';
-import { SubprocessesStatus } from '~/views/process-panel/process-subprocesses';
+import { RootState } from 'store/store';
+import { connect } from 'react-redux';
+import { getProcess, getSubprocesses, Process, getProcessStatus } from 'store/processes/process';
+import { Dispatch } from 'redux';
+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,
+    loadNodeJson
+} from 'store/process-panel/process-panel-actions';
+import { cancelRunningWorkflow, resumeOnHoldWorkflow, startWorkflow } from 'store/processes/processes-actions';
+import { navigateToLogCollection, pollProcessLogs, setProcessLogsPanelFilter } from 'store/process-logs-panel/process-logs-panel-actions';
+import { snackbarActions, SnackbarKind } from 'store/snackbar/snackbar-actions';
 
-export type CssRules = 'headerActive' | 'headerCompleted' | 'headerQueued' | 'headerFailed' | 'headerCanceled';
+const mapStateToProps = ({ router, auth, resources, processPanel, processLogsPanel }: RootState): ProcessPanelRootDataProps => {
+    const uuid = getProcessPanelCurrentUuid(router) || '';
+    const subprocesses = getSubprocesses(uuid)(resources);
+    return {
+        process: getProcess(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,
+        nodeInfo: processPanel.nodeInfo,
+    };
+};
 
-export class ProcessPanel extends React.Component {
-    render() {
-        return <div>
-            <Grid container>
-                <Grid item xs={7}>
-                    <ProcessInformationCard />
-                </Grid>
-            </Grid>
-            <ProcessSubprocesses />
-        </div>;
-    }
-}
+const mapDispatchToProps = (dispatch: Dispatch): ProcessPanelRootActionProps => ({
+    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)),
+    startProcess: (uuid) => dispatch<any>(startWorkflow(uuid)),
+    resumeOnHoldWorkflow: (uuid) => dispatch<any>(resumeOnHoldWorkflow(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()),
+    loadNodeJson: (containerRequest) => dispatch<any>(loadNodeJson(containerRequest)),
+    pollProcessLogs: (processUuid) => dispatch<any>(pollProcessLogs(processUuid)),
+});
 
-export const getBackgroundColorStatus = (status: SubprocessesStatus, classes: Record<CssRules, string>) => {
-    switch (status) {
-        case SubprocessesStatus.COMPLETED:
-            return classes.headerCompleted;
-        case SubprocessesStatus.CANCELED:
-            return classes.headerCanceled;
-        case SubprocessesStatus.QUEUED:
-            return classes.headerQueued;
-        case SubprocessesStatus.FAILED:
-            return classes.headerFailed;
-        case SubprocessesStatus.ACTIVE:
-            return classes.headerActive;
-        default:
-            return classes.headerQueued;
-    }
-};
\ No newline at end of file
+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);
