Merge branch 'master'
[arvados-workbench2.git] / src / views / process-panel / process-panel.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import * as React from 'react';
6 import { RootState } from '~/store/store';
7 import { connect } from 'react-redux';
8 import { getProcess } from '~/store/processes/process';
9 import { Dispatch } from 'redux';
10 import { openProcessContextMenu } from '~/store/context-menu/context-menu-actions';
11 import { matchProcessRoute } from '~/routes/routes';
12 import { ProcessPanelRootDataProps, ProcessPanelRootActionProps, ProcessPanelRoot } from './process-panel-root';
13
14 const mapStateToProps = ({ router, resources }: RootState): ProcessPanelRootDataProps => {
15     const pathname = router.location ? router.location.pathname : '';
16     const match = matchProcessRoute(pathname);
17     const uuid = match ? match.params.id : '';
18     return {
19         process: getProcess(uuid)(resources)
20     };
21 };
22
23 const mapDispatchToProps = (dispatch: Dispatch): ProcessPanelRootActionProps => ({
24     onContextMenu: (event: React.MouseEvent<HTMLElement>) => {
25         dispatch<any>(openProcessContextMenu(event));
26     }
27 });
28
29 export const ProcessPanel = connect(mapStateToProps, mapDispatchToProps)(ProcessPanelRoot);