X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/a54f5270f980d4c2c6143b6654fb96a57b7bf46c..61cd8fe9d4fe4dfeab443f31bbbc5effa5176765:/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 f416f7b2..b3895280 100644 --- a/src/views/process-panel/process-panel.tsx +++ b/src/views/process-panel/process-panel.tsx @@ -2,18 +2,53 @@ // // SPDX-License-Identifier: AGPL-3.0 -import * as React from 'react'; -import { ProcessInformationCard } from '~/views-components/process-information-card/process-information-card'; -import { Grid } from '@material-ui/core'; +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 { matchProcessRoute } from '~/routes/routes'; +import { ProcessPanelRootDataProps, ProcessPanelRootActionProps, ProcessPanelRoot } from './process-panel-root'; +import { ProcessPanel as ProcessPanelState} from '~/store/process-panel/process-panel'; +import { groupBy } from 'lodash'; +import { toggleProcessPanelFilter, navigateToOutput, openWorkflow } from '~/store/process-panel/process-panel-actions'; +import { openProcessInputDialog } from '~/store/processes/process-input-actions'; -export class ProcessPanel extends React.Component { - render() { - return
- - - - - -
; - } -} \ No newline at end of file +const mapStateToProps = ({ router, resources, processPanel }: RootState): ProcessPanelRootDataProps => { + const pathname = router.location ? router.location.pathname : ''; + const match = matchProcessRoute(pathname); + const uuid = match ? match.params.id : ''; + const subprocesses = getSubprocesses(uuid)(resources); + return { + process: getProcess(uuid)(resources), + subprocesses: subprocesses.filter(subprocess => processPanel.filters[getProcessStatus(subprocess)]), + filters: getFilters(processPanel, subprocesses), + totalSubprocessesLength: subprocesses.length, + }; +}; + +const mapDispatchToProps = (dispatch: Dispatch): ProcessPanelRootActionProps => ({ + onContextMenu: (event, process) => { + dispatch(openProcessContextMenu(event, process)); + }, + onToggle: status => { + dispatch(toggleProcessPanelFilter(status)); + }, + openProcessInputDialog: (uuid) => dispatch(openProcessInputDialog(uuid)), + navigateToOutput: (uuid) => dispatch(navigateToOutput(uuid)), + navigateToWorkflow: (uuid) => dispatch(openWorkflow(uuid)) +}); + +export const ProcessPanel = connect(mapStateToProps, mapDispatchToProps)(ProcessPanelRoot); + +export 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, + })); + }; \ No newline at end of file