1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
18 } from '@material-ui/core';
19 import { ArvadosTheme } from 'common/custom-theme';
20 import { WorkflowIcon } from 'components/icon/icon';
21 import { DataTableDefaultView } from 'components/data-table-default-view/data-table-default-view';
22 import { WorkflowResource, parseWorkflowDefinition, getWorkflowInputs, getInputLabel, stringifyInputType } from 'models/workflow';
23 import { WorkflowGraph } from "views/workflow-panel/workflow-graph";
25 export type CssRules = 'root' | 'tab' | 'inputTab' | 'graphTab' | 'graphTabWithChosenWorkflow' | 'descriptionTab' | 'inputsTable';
27 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
37 marginTop: theme.spacing.unit
40 marginTop: theme.spacing.unit,
42 graphTabWithChosenWorkflow: {
45 marginTop: theme.spacing.unit,
50 marginTop: theme.spacing.unit,
57 interface WorkflowDetailsCardDataProps {
58 workflow?: WorkflowResource;
61 type WorkflowDetailsCardProps = WorkflowDetailsCardDataProps & WithStyles<CssRules>;
63 export const WorkflowDetailsCard = withStyles(styles)(
64 class extends React.Component<WorkflowDetailsCardProps> {
69 handleChange = (event: React.MouseEvent<HTMLElement>, value: number) => {
70 this.setState({ value });
74 const { classes, workflow } = this.props;
75 const { value } = this.state;
76 return <div className={classes.root}>
77 <Tabs value={value} onChange={this.handleChange} centered={true}>
78 <Tab className={classes.tab} label="Description" />
79 <Tab className={classes.tab} label="Inputs" />
80 <Tab className={classes.tab} label="Graph" />
82 {value === 0 && <CardContent className={classes.descriptionTab}>
84 {workflow.description}
88 messages={['Please select a workflow to see its description.']} />
91 {value === 1 && <CardContent className={classes.inputTab}>
93 ? this.renderInputsTable()
94 : <DataTableDefaultView
96 messages={['Please select a workflow to see its inputs.']} />
99 {value === 2 && <CardContent className={workflow ? classes.graphTabWithChosenWorkflow : classes.graphTab}>
101 ? <WorkflowGraph workflow={workflow} />
102 : <DataTableDefaultView
104 messages={['Please select a workflow to see its visualisation.']} />
111 if (this.props.workflow) {
112 const definition = parseWorkflowDefinition(this.props.workflow);
114 return getWorkflowInputs(definition);
120 renderInputsTable() {
121 return <Table className={this.props.classes.inputsTable}>
124 <TableCell>Label</TableCell>
125 <TableCell>Type</TableCell>
126 <TableCell>Description</TableCell>
130 {this.inputs && this.inputs.map(input =>
131 <TableRow key={input.id}>
132 <TableCell>{getInputLabel(input)}</TableCell>
133 <TableCell>{stringifyInputType(input)}</TableCell>
134 <TableCell>{input.doc}</TableCell>