1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
19 } from '@material-ui/core';
20 import { ArvadosTheme } from 'common/custom-theme';
21 import { WorkflowIcon } from 'components/icon/icon';
22 import { DataTableDefaultView } from 'components/data-table-default-view/data-table-default-view';
23 import { WorkflowResource, parseWorkflowDefinition, getWorkflowInputs, getInputLabel, stringifyInputType } from 'models/workflow';
24 // import { WorkflowGraph } from "views/workflow-panel/workflow-graph";
25 import { DetailsAttribute } from 'components/details-attribute/details-attribute';
26 import { ResourceOwnerWithName } from 'views-components/data-explorer/renderers';
27 import { formatDate } from "common/formatters";
29 export type CssRules = 'root' | 'tab' | 'inputTab' | 'graphTab' | 'graphTabWithChosenWorkflow' | 'descriptionTab' | 'inputsTable';
31 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
41 marginTop: theme.spacing.unit
44 marginTop: theme.spacing.unit,
46 graphTabWithChosenWorkflow: {
49 marginTop: theme.spacing.unit,
54 marginTop: theme.spacing.unit,
61 interface WorkflowDetailsCardDataProps {
62 workflow?: WorkflowResource;
65 type WorkflowDetailsCardProps = WorkflowDetailsCardDataProps & WithStyles<CssRules>;
67 export const WorkflowDetailsCard = withStyles(styles)(
68 class extends React.Component<WorkflowDetailsCardProps> {
73 handleChange = (event: React.MouseEvent<HTMLElement>, value: number) => {
74 this.setState({ value });
78 const { classes, workflow } = this.props;
79 const { value } = this.state;
80 return <div className={classes.root}>
81 <Tabs value={value} onChange={this.handleChange} centered={true}>
82 <Tab className={classes.tab} label="Description" />
83 <Tab className={classes.tab} label="Inputs" />
84 <Tab className={classes.tab} label="Details" />
85 {/* <Tab className={classes.tab} label="Graph" /> */}
87 {value === 0 && <CardContent className={classes.descriptionTab}>
89 {workflow.description}
93 messages={['Please select a workflow to see its description.']} />
96 {value === 1 && <CardContent className={classes.inputTab}>
98 ? this.renderInputsTable()
99 : <DataTableDefaultView
101 messages={['Please select a workflow to see its inputs.']} />
104 {/* {value === 2 && <CardContent className={workflow ? classes.graphTabWithChosenWorkflow : classes.graphTab}>
106 ? <WorkflowGraph workflow={workflow} />
107 : <DataTableDefaultView
109 messages={['Please select a workflow to see its visualisation.']} />
112 {value === 2 && <CardContent className={classes.descriptionTab}>
114 ? <WorkflowDetailsAttributes workflow={workflow} />
115 : <DataTableDefaultView
117 messages={['Please select a workflow to see its details.']} />
124 if (this.props.workflow) {
125 const definition = parseWorkflowDefinition(this.props.workflow);
127 return getWorkflowInputs(definition);
133 renderInputsTable() {
134 return <Table className={this.props.classes.inputsTable}>
137 <TableCell>Label</TableCell>
138 <TableCell>Type</TableCell>
139 <TableCell>Description</TableCell>
143 {this.inputs && this.inputs.map(input =>
144 <TableRow key={input.id}>
145 <TableCell>{getInputLabel(input)}</TableCell>
146 <TableCell>{stringifyInputType(input)}</TableCell>
147 <TableCell>{input.doc}</TableCell>
154 export const WorkflowDetailsAttributes = ({ workflow }: WorkflowDetailsCardDataProps) => {
155 return <Grid container>
158 label={"Workflow UUID"}
159 linkToUuid={workflow?.uuid} />
163 label='Owner' linkToUuid={workflow?.ownerUuid}
164 uuidEnhancer={(uuid: string) => <ResourceOwnerWithName uuid={uuid} />} />
167 <DetailsAttribute label='Created at' value={formatDate(workflow?.createdAt)} />
170 <DetailsAttribute label='Last modified' value={formatDate(workflow?.modifiedAt)} />
174 label='Last modified by user' linkToUuid={workflow?.modifiedByUserUuid}
175 uuidEnhancer={(uuid: string) => <ResourceOwnerWithName uuid={uuid} />} />