1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as 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;
76 console.log(workflow.definition);
78 const { value } = this.state;
79 return <div className={classes.root}>
80 <Tabs value={value} onChange={this.handleChange} centered={true}>
81 <Tab className={classes.tab} label="Description" />
82 <Tab className={classes.tab} label="Inputs" />
83 <Tab className={classes.tab} label="Graph" />
85 {value === 0 && <CardContent className={classes.descriptionTab}>
87 {workflow.description}
91 messages={['Please select a workflow to see its description.']} />
94 {value === 1 && <CardContent className={classes.inputTab}>
96 ? this.renderInputsTable()
97 : <DataTableDefaultView
99 messages={['Please select a workflow to see its inputs.']} />
102 {value === 2 && <CardContent className={workflow ? classes.graphTabWithChosenWorkflow : classes.graphTab}>
104 ? <WorkflowGraph workflow={workflow} />
105 : <DataTableDefaultView
107 messages={['Please select a workflow to see its visualisation.']} />
114 if (this.props.workflow) {
115 const definition = parseWorkflowDefinition(this.props.workflow);
117 return getWorkflowInputs(definition);
123 renderInputsTable() {
124 return <Table className={this.props.classes.inputsTable}>
127 <TableCell>Label</TableCell>
128 <TableCell>Type</TableCell>
129 <TableCell>Description</TableCell>
133 {this.inputs && this.inputs.map(input =>
134 <TableRow key={input.id}>
135 <TableCell>{getInputLabel(input)}</TableCell>
136 <TableCell>{stringifyInputType(input)}</TableCell>
137 <TableCell>{input.doc}</TableCell>