1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
16 } from '@material-ui/core';
17 import { Dispatch } from "redux";
18 import { connect, DispatchProp } from "react-redux";
19 import { RouteComponentProps } from 'react-router';
20 import { ArvadosTheme } from 'common/custom-theme';
21 import { RootState } from 'store/store';
22 import { WorkflowIcon, MoreOptionsIcon } from 'components/icon/icon';
23 import { WorkflowResource } from 'models/workflow';
24 import { ProcessOutputCollectionFiles } from 'views/process-panel/process-output-collection-files';
25 import { WorkflowDetailsAttributes, RegisteredWorkflowPanelDataProps, getRegisteredWorkflowPanelData } from 'views-components/details-panel/workflow-details';
26 import { getResource } from 'store/resources/resources';
27 import { openContextMenu, resourceUuidToContextMenuKind } from 'store/context-menu/context-menu-actions';
28 import { MPVContainer, MPVPanelContent, MPVPanelState } from 'components/multi-panel-view/multi-panel-view';
29 import { ProcessIOCard, ProcessIOCardType } from 'views/process-panel/process-io-card';
31 type CssRules = 'root'
49 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
57 paddingLeft: theme.spacing.unit * 2,
58 paddingRight: theme.spacing.unit * 2,
59 paddingBottom: theme.spacing.unit * 2,
69 color: theme.customs.colors.greyL
72 marginRight: theme.spacing.unit / 2,
73 marginBottom: theme.spacing.unit / 2
86 flexDirection: 'column',
89 textTransform: 'none',
94 color: theme.palette.primary.main,
100 marginLeft: theme.spacing.unit,
104 paddingTop: theme.spacing.unit,
105 paddingBottom: theme.spacing.unit,
109 paddingTop: theme.spacing.unit * 0.5,
110 color: theme.customs.colors.green700,
113 alignSelf: 'flex-start',
114 paddingTop: theme.spacing.unit * 0.5
118 type RegisteredWorkflowPanelProps = RegisteredWorkflowPanelDataProps & DispatchProp & WithStyles<CssRules>
120 export const RegisteredWorkflowPanel = withStyles(styles)(connect(
121 (state: RootState, props: RouteComponentProps<{ id: string }>) => {
122 const item = getResource<WorkflowResource>(props.match.params.id)(state.resources);
124 return getRegisteredWorkflowPanelData(item, state.auth);
126 return { item, inputParams: [], outputParams: [], workflowCollection: "", gitprops: {} };
128 class extends React.Component<RegisteredWorkflowPanelProps> {
130 const { classes, item, inputParams, outputParams, workflowCollection } = this.props;
131 const panelsData: MPVPanelState[] = [
138 ? <MPVContainer className={classes.root} spacing={8} direction="column" justify-content="flex-start" wrap="nowrap" panelStates={panelsData}>
139 <MPVPanelContent xs="auto" data-cy='registered-workflow-info-panel'>
140 <Card className={classes.infoCard}>
142 className={classes.header}
144 content: classes.title,
145 avatar: classes.avatar,
147 avatar={<WorkflowIcon className={classes.iconHeader} />}
149 <Tooltip title={item.name} placement="bottom-start">
150 <Typography noWrap variant='h6'>
156 <Tooltip title={item.description || '(no-description)'} placement="bottom-start">
157 <Typography noWrap variant='body1' color='inherit'>
158 {item.description || '(no-description)'}
162 <Tooltip title="More options" disableFocusListener>
164 aria-label="More options"
165 onClick={event => this.handleContextMenu(event)}>
172 <Grid container justify="space-between">
174 <WorkflowDetailsAttributes workflow={item} />
179 <MPVPanelContent forwardProps xs data-cy="process-inputs">
181 label={ProcessIOCardType.INPUT}
187 <MPVPanelContent forwardProps xs data-cy="process-outputs">
189 label={ProcessIOCardType.OUTPUT}
190 params={outputParams}
196 <Card className={classes.filesCard}>
197 <ProcessOutputCollectionFiles isWritable={false} currentItemUuid={workflowCollection} />
204 handleContextMenu = (event: React.MouseEvent<any>) => {
205 const { uuid, ownerUuid, name, description,
206 kind } = this.props.item;
207 const menuKind = this.props.dispatch<any>(resourceUuidToContextMenuKind(uuid));
216 // Avoid expanding/collapsing the panel
217 event.stopPropagation();
218 this.props.dispatch<any>(openContextMenu(event, resource));