1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import { CustomStyleRulesCallback } from 'common/custom-theme';
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';
30 import { WorkflowProcessesPanel } from './workflow-processes-panel';
32 type CssRules = 'root'
51 const styles: CustomStyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
68 color: theme.customs.colors.greyL
71 marginRight: theme.spacing(1) /2,
72 marginBottom: theme.spacing(1) /2
85 flexDirection: 'column',
88 textTransform: 'none',
93 color: theme.palette.primary.main,
99 marginLeft: theme.spacing(1),
103 paddingTop: theme.spacing(1),
104 paddingBottom: theme.spacing(1),
108 paddingTop: theme.spacing(0.5),
109 color: theme.customs.colors.green700,
112 alignSelf: 'flex-start',
113 paddingTop: theme.spacing(0.5)
116 padding: theme.spacing(1),
117 paddingTop: theme.spacing(0.5),
119 paddingBottom: theme.spacing(1),
124 type RegisteredWorkflowPanelProps = RegisteredWorkflowPanelDataProps & DispatchProp & WithStyles<CssRules>
126 export const RegisteredWorkflowPanel = withStyles(styles)(connect(
127 (state: RootState, props: RouteComponentProps<{ id: string }>) => {
128 const item = getResource<WorkflowResource>(props.match.params.id)(state.resources);
130 return getRegisteredWorkflowPanelData(item, state.auth);
132 return { item, inputParams: [], outputParams: [], workflowCollection: "", gitprops: {} };
134 class extends React.Component<RegisteredWorkflowPanelProps> {
136 const { classes, item, inputParams, outputParams, workflowCollection } = this.props;
137 const panelsData: MPVPanelState[] = [
142 { name: "Definition" },
145 ? <MPVContainer className={classes.root} spacing={1} direction="column" justify-content="flex-start" wrap="nowrap" panelStates={panelsData}>
146 <MPVPanelContent xs="auto" data-cy='registered-workflow-info-panel'>
147 <Card className={classes.infoCard}>
149 className={classes.header}
151 content: classes.title,
152 avatar: classes.avatar,
154 avatar={<WorkflowIcon className={classes.iconHeader} />}
156 <Tooltip title={item.name} placement="bottom-start">
157 <Typography noWrap variant='h6'>
163 <Tooltip title={item.description || '(no-description)'} placement="bottom-start">
164 <Typography noWrap variant='body1' color='inherit'>
165 {item.description || '(no-description)'}
169 <Tooltip title="More options" disableFocusListener>
171 aria-label="More options"
172 onClick={event => this.handleContextMenu(event)}>
179 <CardContent className={classes.content}>
180 <WorkflowDetailsAttributes workflow={item} />
184 <MPVPanelContent forwardProps xs maxHeight="100%">
185 <WorkflowProcessesPanel />
187 <MPVPanelContent forwardProps xs data-cy="process-outputs" maxHeight="100%">
189 label={ProcessIOCardType.OUTPUT}
190 params={outputParams}
192 forceShowParams={true}
195 <MPVPanelContent forwardProps xs data-cy="process-inputs" maxHeight="100%">
197 label={ProcessIOCardType.INPUT}
200 forceShowParams={true}
203 <MPVPanelContent xs maxHeight="100%">
204 <Card className={classes.filesCard}>
205 <CardHeader title="Workflow Definition" />
206 <ProcessOutputCollectionFiles isWritable={false} currentItemUuid={workflowCollection} />
213 messages={["Workflow not found"]}
217 handleContextMenu = (event: React.MouseEvent<any>) => {
218 const { uuid, ownerUuid, name, description,
219 kind } = this.props.item;
220 const menuKind = this.props.dispatch<any>(resourceUuidToContextMenuKind(uuid));
229 // Avoid expanding/collapsing the panel
230 event.stopPropagation();
231 this.props.dispatch<any>(openContextMenu(event, resource));