small changes
[arvados-workbench2.git] / src / views / process-panel / process-panel.tsx
index 2c8db99479b7c0dc2c626e2f21ac9f1e7b1a0d5f..9f1d0adb7a2fae5314e2b2b55136624060519613 100644 (file)
@@ -3,68 +3,28 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from 'react';
-import { Grid } from '@material-ui/core';
-import { ProcessInformationCard } from '~/views-components/process-information-card/process-information-card';
-import { SubprocessesCard } from '~/views/process-panel/subprocesses-card';
-import { SubprocessFilterDataProps } from '~/components/subprocess-filter/subprocess-filter';
+import { RootState } from '~/store/store';
+import { connect } from 'react-redux';
+import { getProcess, getSubprocesses } 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';
 
-export class ProcessPanel extends React.Component {
-    state = {
-        filters: [
-            {
-                key: 'queued',
-                value: 1,
-                label: 'Queued',
-                checked: true
-            }, {
-                key: 'active',
-                value: 2,
-                label: 'Active',
-                checked: true
-            },
-            {
-                key: 'completed',
-                value: 2,
-                label: 'Completed',
-                checked: true
-            },
-            {
-                key: 'failed',
-                value: 2,
-                label: 'Failed',
-                checked: true
-            }
-        ]
+const mapStateToProps = ({ router, resources }: RootState): ProcessPanelRootDataProps => {
+    const pathname = router.location ? router.location.pathname : '';
+    const match = matchProcessRoute(pathname);
+    const uuid = match ? match.params.id : '';
+    return {
+        process: getProcess(uuid)(resources),
+        subprocesses: getSubprocesses(uuid)(resources)
     };
+};
 
-    onToggle = (filter: SubprocessFilterDataProps) => {
-        this.setState((prev: { filters: any[] }) => {
-            return {
-                filters: prev.filters.map((f: SubprocessFilterDataProps) => {
-                    if(f.key === filter.key) {
-                        return {
-                            ...filter,
-                            checked: !filter.checked
-                        };
-                    }
-                    return f;
-                })
-            };
-        });
+const mapDispatchToProps = (dispatch: Dispatch): ProcessPanelRootActionProps => ({
+    onContextMenu: (event: React.MouseEvent<HTMLElement>) => {
+        dispatch<any>(openProcessContextMenu(event));
     }
+});
 
-    render() {
-        return <Grid container spacing={16}>
-            <Grid item xs={7}>
-                <ProcessInformationCard />
-            </Grid>
-            <Grid item xs={5}>
-                <SubprocessesCard 
-                    subprocesses={4}
-                    filters={this.state.filters}
-                    onToggle={this.onToggle}
-                />
-            </Grid>
-        </Grid>;
-    }
-}
+export const ProcessPanel = connect(mapStateToProps, mapDispatchToProps)(ProcessPanelRoot);