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';
7 import { Tooltip, Typography, Card, CardHeader, CardContent, IconButton } from '@mui/material';
8 import { WithStyles } from '@mui/styles';
9 import withStyles from '@mui/styles/withStyles';
10 import { connect, DispatchProp } from "react-redux";
11 import { RouteComponentProps } from 'react-router';
12 import { ArvadosTheme } from 'common/custom-theme';
13 import { RootState } from 'store/store';
14 import { WorkflowIcon, MoreVerticalIcon } from 'components/icon/icon';
15 import { WorkflowResource } from 'models/workflow';
16 import { ProcessOutputCollectionFiles } from 'views/process-panel/process-output-collection-files';
17 import { WorkflowDetailsAttributes, RegisteredWorkflowPanelDataProps, getRegisteredWorkflowPanelData } from 'views-components/details-panel/workflow-details';
18 import { getResource } from 'store/resources/resources';
19 import { openContextMenu, resourceUuidToContextMenuKind } from 'store/context-menu/context-menu-actions';
20 import { MPVContainer, MPVPanelContent, MPVPanelState } from 'components/multi-panel-view/multi-panel-view';
21 import { ProcessIOCard, ProcessIOCardType } from 'views/process-panel/process-io-card';
22 import { NotFoundView } from 'views/not-found-panel/not-found-panel';
23 import { WorkflowProcessesPanel } from './workflow-processes-panel';
46 const styles: CustomStyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
63 color: theme.customs.colors.greyL
66 color: theme.customs.colors.greyD
69 marginRight: theme.spacing(0.5),
70 marginBottom: theme.spacing(0.5)
83 flexDirection: 'column',
86 textTransform: 'none',
91 color: theme.palette.primary.main,
97 marginLeft: theme.spacing(1),
101 paddingTop: theme.spacing(1),
102 paddingBottom: theme.spacing(1),
106 paddingTop: theme.spacing(0.5),
107 color: theme.customs.colors.green700,
110 alignSelf: 'flex-start',
111 paddingTop: theme.spacing(0.5)
114 padding: theme.spacing(1),
115 paddingTop: theme.spacing(0.5),
117 paddingBottom: theme.spacing(1),
122 type RegisteredWorkflowPanelProps = RegisteredWorkflowPanelDataProps & DispatchProp & WithStyles<CssRules>
124 export const RegisteredWorkflowPanel = withStyles(styles)(connect(
125 (state: RootState, props: RouteComponentProps<{ id: string }>) => {
126 const item = getResource<WorkflowResource>(props.match.params.id)(state.resources);
128 return getRegisteredWorkflowPanelData(item, state.auth);
130 return { item, inputParams: [], outputParams: [], workflowCollection: "", gitprops: {} };
132 class extends React.Component<RegisteredWorkflowPanelProps> {
134 const { classes, item, inputParams, outputParams, workflowCollection } = this.props;
135 const panelsData: MPVPanelState[] = [
140 { name: "Definition" },
143 ? <MPVContainer className={classes.root} spacing={1} direction="column" justifyContent="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)}
178 <CardContent className={classes.content}>
179 <WorkflowDetailsAttributes workflow={item} />
183 <MPVPanelContent forwardProps xs maxHeight="100%">
184 <WorkflowProcessesPanel />
186 <MPVPanelContent forwardProps xs data-cy="process-outputs" maxHeight="100%">
188 label={ProcessIOCardType.OUTPUT}
189 params={outputParams}
191 forceShowParams={true}
194 <MPVPanelContent forwardProps xs data-cy="process-inputs" maxHeight="100%">
196 label={ProcessIOCardType.INPUT}
199 forceShowParams={true}
202 <MPVPanelContent xs maxHeight="100%">
203 <Card className={classes.filesCard}>
204 <CardHeader title="Workflow Definition" />
205 <ProcessOutputCollectionFiles isWritable={false} currentItemUuid={workflowCollection} />
212 messages={["Workflow not found"]}
216 handleContextMenu = (event: React.MouseEvent<any>) => {
217 const { uuid, ownerUuid, name, description,
218 kind } = this.props.item;
219 const menuKind = this.props.dispatch<any>(resourceUuidToContextMenuKind(uuid));
228 // Avoid expanding/collapsing the panel
229 event.stopPropagation();
230 this.props.dispatch<any>(openContextMenu(event, resource));