1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
6 import { RootState } from '~/store/store';
7 import { connect } from 'react-redux';
8 import { getProcess, getSubprocesses } 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';
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 : '';
19 process: getProcess(uuid)(resources),
20 subprocesses: getSubprocesses(uuid)(resources)
24 const mapDispatchToProps = (dispatch: Dispatch): ProcessPanelRootActionProps => ({
25 onContextMenu: (event: React.MouseEvent<HTMLElement>) => {
26 dispatch<any>(openProcessContextMenu(event));
30 export const ProcessPanel = connect(mapStateToProps, mapDispatchToProps)(ProcessPanelRoot);