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 { connect, DispatchProp } from "react-redux";
18 import { RouteComponentProps } from 'react-router';
19 import { ArvadosTheme } from 'common/custom-theme';
20 import { RootState } from 'store/store';
21 import { WorkflowIcon, MoreVerticalIcon } from 'components/icon/icon';
22 import { WorkflowResource } from 'models/workflow';
23 import { ProcessOutputCollectionFiles } from 'views/process-panel/process-output-collection-files';
24 import { WorkflowDetailsAttributes, RegisteredWorkflowPanelDataProps, getRegisteredWorkflowPanelData } from 'views-components/details-panel/workflow-details';
25 import { getResource } from 'store/resources/resources';
26 import { openContextMenu, resourceUuidToContextMenuKind } from 'store/context-menu/context-menu-actions';
27 import { MPVContainer, MPVPanelContent, MPVPanelState } from 'components/multi-panel-view/multi-panel-view';
28 import { ProcessIOCard, ProcessIOCardType } from 'views/process-panel/process-io-card';
29 import { NotFoundView } from 'views/not-found-panel/not-found-panel';
31 type CssRules = 'root'
50 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
67 color: theme.customs.colors.greyL
70 marginRight: theme.spacing.unit / 2,
71 marginBottom: theme.spacing.unit / 2
84 flexDirection: 'column',
87 textTransform: 'none',
92 color: theme.palette.primary.main,
98 marginLeft: theme.spacing.unit,
102 paddingTop: theme.spacing.unit,
103 paddingBottom: theme.spacing.unit,
107 paddingTop: theme.spacing.unit * 0.5,
108 color: theme.customs.colors.green700,
111 alignSelf: 'flex-start',
112 paddingTop: theme.spacing.unit * 0.5
115 padding: theme.spacing.unit * 1.0,
116 paddingTop: theme.spacing.unit * 0.5,
118 paddingBottom: theme.spacing.unit * 1,
123 type RegisteredWorkflowPanelProps = RegisteredWorkflowPanelDataProps & DispatchProp & WithStyles<CssRules>
125 export const RegisteredWorkflowPanel = withStyles(styles)(connect(
126 (state: RootState, props: RouteComponentProps<{ id: string }>) => {
127 const item = getResource<WorkflowResource>(props.match.params.id)(state.resources);
129 return getRegisteredWorkflowPanelData(item, state.auth);
131 return { item, inputParams: [], outputParams: [], workflowCollection: "", gitprops: {} };
133 class extends React.Component<RegisteredWorkflowPanelProps> {
135 const { classes, item, inputParams, outputParams, workflowCollection } = this.props;
136 const panelsData: MPVPanelState[] = [
143 ? <MPVContainer className={classes.root} spacing={8} direction="column" justify-content="flex-start" wrap="nowrap" panelStates={panelsData}>
144 <MPVPanelContent xs="auto" data-cy='registered-workflow-info-panel'>
145 <Card className={classes.infoCard}>
147 className={classes.header}
149 content: classes.title,
150 avatar: classes.avatar,
152 avatar={<WorkflowIcon className={classes.iconHeader} />}
154 <Tooltip title={item.name} placement="bottom-start">
155 <Typography noWrap variant='h6'>
161 <Tooltip title={item.description || '(no-description)'} placement="bottom-start">
162 <Typography noWrap variant='body1' color='inherit'>
163 {item.description || '(no-description)'}
167 <Tooltip title="More options" disableFocusListener>
169 aria-label="More options"
170 onClick={event => this.handleContextMenu(event)}>
177 <CardContent className={classes.content}>
178 <WorkflowDetailsAttributes workflow={item} />
182 <MPVPanelContent forwardProps xs data-cy="process-inputs">
184 label={ProcessIOCardType.INPUT}
190 <MPVPanelContent forwardProps xs data-cy="process-outputs">
192 label={ProcessIOCardType.OUTPUT}
193 params={outputParams}
199 <Card className={classes.filesCard}>
200 <ProcessOutputCollectionFiles isWritable={false} currentItemUuid={workflowCollection} />
207 messages={["Workflow not found"]}
211 handleContextMenu = (event: React.MouseEvent<any>) => {
212 const { uuid, ownerUuid, name, description,
213 kind } = this.props.item;
214 const menuKind = this.props.dispatch<any>(resourceUuidToContextMenuKind(uuid));
223 // Avoid expanding/collapsing the panel
224 event.stopPropagation();
225 this.props.dispatch<any>(openContextMenu(event, resource));