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 { DetailsAttribute } from 'components/details-attribute/details-attribute';
25 import { ResourceOwnerWithName } from 'views-components/data-explorer/renderers';
26 import { formatDate } from "common/formatters";
28 export type CssRules = 'root' | 'tab' | 'inputTab' | 'graphTab' | 'graphTabWithChosenWorkflow' | 'descriptionTab' | 'inputsTable';
30 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
40 marginTop: theme.spacing.unit
43 marginTop: theme.spacing.unit,
45 graphTabWithChosenWorkflow: {
48 marginTop: theme.spacing.unit,
53 marginTop: theme.spacing.unit,
60 interface WorkflowDetailsCardDataProps {
61 workflow?: WorkflowResource;
64 type WorkflowDetailsCardProps = WorkflowDetailsCardDataProps & WithStyles<CssRules>;
66 export const WorkflowDetailsCard = withStyles(styles)(
67 class extends React.Component<WorkflowDetailsCardProps> {
72 handleChange = (event: React.MouseEvent<HTMLElement>, value: number) => {
73 this.setState({ value });
77 const { classes, workflow } = this.props;
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="Details" />
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={classes.descriptionTab}>
104 ? <WorkflowDetailsAttributes workflow={workflow} />
105 : <DataTableDefaultView
107 messages={['Please select a workflow to see its details.']} />
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>
144 export const WorkflowDetailsAttributes = ({ workflow }: WorkflowDetailsCardDataProps) => {
145 return <Grid container>
148 label={"Workflow UUID"}
149 linkToUuid={workflow?.uuid} />
153 label='Owner' linkToUuid={workflow?.ownerUuid}
154 uuidEnhancer={(uuid: string) => <ResourceOwnerWithName uuid={uuid} />} />
157 <DetailsAttribute label='Created at' value={formatDate(workflow?.createdAt)} />
160 <DetailsAttribute label='Last modified' value={formatDate(workflow?.modifiedAt)} />
164 label='Last modified by user' linkToUuid={workflow?.modifiedByUserUuid}
165 uuidEnhancer={(uuid: string) => <ResourceOwnerWithName uuid={uuid} />} />