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 { parseWorkflowDefinition, getWorkflowInputs, getInputLabel, stringifyInputType } from 'models/workflow';
23 import { WorkflowDetailsCardDataProps, WorkflowDetailsAttributes } from 'views-components/details-panel/workflow-details';
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 type WorkflowDetailsCardProps = WorkflowDetailsCardDataProps & WithStyles<CssRules>;
59 export const WorkflowDetailsCard = withStyles(styles)(
60 class extends React.Component<WorkflowDetailsCardProps> {
65 handleChange = (event: React.MouseEvent<HTMLElement>, value: number) => {
66 this.setState({ value });
70 const { classes, workflow } = this.props;
71 const { value } = this.state;
72 return <div className={classes.root}>
73 <Tabs value={value} onChange={this.handleChange} centered={true}>
74 <Tab className={classes.tab} label="Description" />
75 <Tab className={classes.tab} label="Inputs" />
76 <Tab className={classes.tab} label="Details" />
78 {value === 0 && <CardContent className={classes.descriptionTab}>
80 {workflow.description}
84 messages={['Please select a workflow to see its description.']} />
87 {value === 1 && <CardContent className={classes.inputTab}>
89 ? this.renderInputsTable()
90 : <DataTableDefaultView
92 messages={['Please select a workflow to see its inputs.']} />
95 {value === 2 && <CardContent className={classes.descriptionTab}>
97 ? <WorkflowDetailsAttributes workflow={workflow} />
98 : <DataTableDefaultView
100 messages={['Please select a workflow to see its details.']} />
107 if (this.props.workflow) {
108 const definition = parseWorkflowDefinition(this.props.workflow);
110 return getWorkflowInputs(definition);
116 renderInputsTable() {
117 return <Table className={this.props.classes.inputsTable}>
120 <TableCell>Label</TableCell>
121 <TableCell>Type</TableCell>
122 <TableCell>Description</TableCell>
126 {this.inputs && this.inputs.map(input =>
127 <TableRow key={input.id}>
128 <TableCell>{getInputLabel(input)}</TableCell>
129 <TableCell>{stringifyInputType(input)}</TableCell>
130 <TableCell>{input.doc}</TableCell>