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 { CardContent, Tab, Tabs, Table, TableHead, TableCell, TableBody, TableRow } from '@mui/material';
8 import { WithStyles } from '@mui/styles';
9 import withStyles from '@mui/styles/withStyles';
10 import { ArvadosTheme } from 'common/custom-theme';
11 import { WorkflowIcon } from 'components/icon/icon';
12 import { DataTableDefaultView } from 'components/data-table-default-view/data-table-default-view';
13 import { parseWorkflowDefinition, getWorkflowInputs, getInputLabel, stringifyInputType } from 'models/workflow';
14 import { WorkflowDetailsCardDataProps, WorkflowDetailsAttributes } from 'views-components/details-panel/workflow-details';
16 export type CssRules = 'root' | 'tab' | 'inputTab' | 'graphTab' | 'graphTabWithChosenWorkflow' | 'descriptionTab' | 'inputsTable';
18 const styles: CustomStyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
28 marginTop: theme.spacing(1)
31 marginTop: theme.spacing(1),
33 graphTabWithChosenWorkflow: {
36 marginTop: theme.spacing(1),
41 marginTop: theme.spacing(1),
48 type WorkflowDetailsCardProps = WorkflowDetailsCardDataProps & WithStyles<CssRules>;
50 export const WorkflowDetailsCard = withStyles(styles)(
51 class extends React.Component<WorkflowDetailsCardProps> {
56 handleChange = (event: React.MouseEvent<HTMLElement>, value: number) => {
57 this.setState({ value });
61 const { classes, workflow } = this.props;
62 const { value } = this.state;
63 return <div className={classes.root}>
64 <Tabs value={value} onChange={this.handleChange} centered={true}>
65 <Tab className={classes.tab} label="Description" />
66 <Tab className={classes.tab} label="Inputs" />
67 <Tab className={classes.tab} label="Details" />
69 {value === 0 && <CardContent className={classes.descriptionTab}>
71 {workflow.description}
75 messages={['Please select a workflow to see its description.']} />
78 {value === 1 && <CardContent className={classes.inputTab}>
80 ? this.renderInputsTable()
81 : <DataTableDefaultView
83 messages={['Please select a workflow to see its inputs.']} />
86 {value === 2 && <CardContent className={classes.descriptionTab}>
88 ? <WorkflowDetailsAttributes workflow={workflow} />
89 : <DataTableDefaultView
91 messages={['Please select a workflow to see its details.']} />
98 if (this.props.workflow) {
99 const definition = parseWorkflowDefinition(this.props.workflow);
101 return getWorkflowInputs(definition);
107 renderInputsTable() {
108 return <Table className={this.props.classes.inputsTable}>
111 <TableCell>Label</TableCell>
112 <TableCell>Type</TableCell>
113 <TableCell>Description</TableCell>
117 {this.inputs && this.inputs.map(input =>
118 <TableRow key={input.id}>
119 <TableCell>{getInputLabel(input)}</TableCell>
120 <TableCell>{stringifyInputType(input)}</TableCell>
121 <TableCell>{input.doc}</TableCell>