X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/4476731a9ec985c5abd97da453978af0dfa4406b..56529b81cf7b67cfea510652f07e1778cc82922e:/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 1ae8747069..2ad7e2a37b 100644 --- a/src/views/process-panel/process-panel.tsx +++ b/src/views/process-panel/process-panel.tsx @@ -2,127 +2,86 @@ // // SPDX-License-Identifier: AGPL-3.0 -import * as React from 'react'; +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 { - StyleRulesCallback, WithStyles, withStyles, Card, - CardHeader, IconButton, CardContent, Grid, Chip -} from '@material-ui/core'; -import { ArvadosTheme } from '~/common/custom-theme'; -import { ProcessResource } from '~/models/process'; -import { DispatchProp, connect } from 'react-redux'; -import { RouteComponentProps } from 'react-router'; -import { MoreOptionsIcon, ProcessIcon } from '~/components/icon/icon'; -import { DetailsAttribute } from '~/components/details-attribute/details-attribute'; -import { RootState } from '~/store/store'; + 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, startWorkflow } from 'store/processes/processes-actions'; +import { navigateToLogCollection, setProcessLogsPanelFilter } from 'store/process-logs-panel/process-logs-panel-actions'; +import { snackbarActions, SnackbarKind } from 'store/snackbar/snackbar-actions'; -type CssRules = 'card' | 'iconHeader' | 'label' | 'value' | 'content' | 'chip' | 'headerText'; +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, + }; +}; -const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ - card: { - marginBottom: theme.spacing.unit * 2, - width: '60%' - }, - iconHeader: { - fontSize: '1.875rem', - color: theme.customs.colors.green700 - }, - label: { - fontSize: '0.875rem' +const mapDispatchToProps = (dispatch: Dispatch): ProcessPanelRootActionProps => ({ + onCopyToClipboard: (message: string) => { + dispatch(snackbarActions.OPEN_SNACKBAR({ + message, + hideDuration: 2000, + kind: SnackbarKind.SUCCESS, + })); }, - value: { - textTransform: 'none', - fontSize: '0.875rem' + onContextMenu: (event, process) => { + dispatch(openProcessContextMenu(event, process)); }, - content: { - display: 'flex', - paddingBottom: '0px ', - paddingTop: '0px', - '&:last-child': { - paddingBottom: '0px ', - } + onToggle: status => { + dispatch(toggleProcessPanelFilter(status)); }, - chip: { - height: theme.spacing.unit * 2.5, - width: theme.spacing.unit * 12, - backgroundColor: theme.customs.colors.green700, - color: theme.palette.common.white, - fontSize: '0.875rem', - borderRadius: theme.spacing.unit * 0.625 - }, - headerText: { - fontSize: '0.875rem', - display: 'flex', - position: 'relative', - justifyContent: 'flex-end', - top: -theme.spacing.unit * 4.5, - right: theme.spacing.unit * 2, - } + cancelProcess: (uuid) => dispatch(cancelRunningWorkflow(uuid)), + startProcess: (uuid) => dispatch(startWorkflow(uuid)), + onLogFilterChange: (filter) => dispatch(setProcessLogsPanelFilter(filter.value)), + navigateToLog: (uuid) => dispatch(navigateToLogCollection(uuid)), + loadInputs: (containerRequest) => dispatch(loadInputs(containerRequest)), + loadOutputs: (containerRequest) => dispatch(loadOutputs(containerRequest)), + loadOutputDefinitions: (containerRequest) => dispatch(loadOutputDefinitions(containerRequest)), + updateOutputParams: () => dispatch(updateOutputParams()), + loadNodeJson: (containerRequest) => dispatch(loadNodeJson(containerRequest)), }); -interface ProcessPanelDataProps { - item: ProcessResource; -} - -interface ProcessPanelActionProps { - onItemRouteChange: (processId: string) => void; - onContextMenu: (event: React.MouseEvent, item: ProcessResource) => void; -} - -type ProcessPanelProps = ProcessPanelDataProps & ProcessPanelActionProps & DispatchProp & WithStyles & RouteComponentProps<{ id: string }>; - -export const ProcessPanel = withStyles(styles)( - connect((state: RootState) => ({ - item: state.collectionPanel.item, - tags: state.collectionPanel.tags - }))( - class extends React.Component { - render() { - const { classes, onContextMenu, item } = this.props; +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, + })); +}; - return
- - } - action={ - onContextMenu(event, item)}> - - - } - title="Pipeline template that generates a config file from a template" - /> - - - - } /> - - - - - - - - - - - - - This container request was created from the workflow FastQC MultiQC - -
; - } - componentWillReceiveProps({ match, item, onItemRouteChange }: ProcessPanelProps) { - if (!item || match.params.id !== item.uuid) { - onItemRouteChange(match.params.id); - } - } - } - ) -); \ No newline at end of file +export const ProcessPanel = connect(mapStateToProps, mapDispatchToProps)(ProcessPanelRoot);