1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
7 StyleRulesCallback, WithStyles, withStyles, Card,
8 CardHeader, IconButton, CardContent, Grid, Chip, Typography, Tooltip
9 } from '@material-ui/core';
10 import { ArvadosTheme } from '~/common/custom-theme';
11 import { MoreOptionsIcon, ProcessIcon } from '~/components/icon/icon';
12 import { DetailsAttribute } from '~/components/details-attribute/details-attribute';
13 import { Process } from '~/store/processes/process';
14 import { getProcessStatus, getProcessStatusColor } from '~/store/processes/process';
15 import { formatDate } from '~/common/formatters';
16 import { openWorkflow } from "~/store/process-panel/process-panel-actions";
18 type CssRules = 'card' | 'iconHeader' | 'label' | 'value' | 'chip' | 'link' | 'content' | 'title' | 'avatar';
20 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
26 color: theme.customs.colors.green700,
29 alignSelf: 'flex-start',
30 paddingTop: theme.spacing.unit * 0.5
34 justifyContent: 'flex-end',
36 marginRight: theme.spacing.unit * 3,
37 paddingRight: theme.spacing.unit
40 textTransform: 'none',
45 color: theme.palette.primary.main,
51 height: theme.spacing.unit * 3,
52 width: theme.spacing.unit * 12,
53 color: theme.palette.common.white,
55 borderRadius: theme.spacing.unit * 0.625,
59 paddingBottom: theme.spacing.unit * 2,
64 paddingTop: theme.spacing.unit * 0.5
68 export interface ProcessInformationCardDataProps {
70 onContextMenu: (event: React.MouseEvent<HTMLElement>) => void;
71 openProcessInputDialog: (uuid: string) => void;
72 navigateToOutput: (uuid: string) => void;
73 navigateToWorkflow: (uuid: string) => void;
76 type ProcessInformationCardProps = ProcessInformationCardDataProps & WithStyles<CssRules, true>;
78 export const ProcessInformationCard = withStyles(styles, { withTheme: true })(
79 ({ classes, process, onContextMenu, theme, openProcessInputDialog, navigateToOutput, navigateToWorkflow }: ProcessInformationCardProps) => {
80 const { container } = process;
81 const startedAt = container ? formatDate(container.startedAt) : 'N/A';
82 const finishedAt = container ? formatDate(container.finishedAt) : 'N/A';
83 return <Card className={classes.card}>
86 content: classes.title,
87 avatar: classes.avatar
89 avatar={<ProcessIcon className={classes.iconHeader}/>}
92 <Chip label={getProcessStatus(process)}
93 className={classes.chip}
94 style={{backgroundColor: getProcessStatusColor(getProcessStatus(process), theme as ArvadosTheme)}}/>
95 <Tooltip title="More options" disableFocusListener>
97 aria-label="More options"
98 onClick={event => onContextMenu(event)}>
105 <Tooltip title={process.containerRequest.name} placement="bottom-start">
106 <Typography noWrap variant="title" color='inherit'>
107 {process.containerRequest.name}
112 <Tooltip title={getDescription(process)} placement="bottom-start">
113 <Typography noWrap variant="body2" color='inherit'>
114 {getDescription(process)}
117 <CardContent className={classes.content}>
120 <DetailsAttribute classLabel={classes.label} classValue={classes.value}
122 value={process.container ? formatDate(startedAt) : 'N/A'}/>
123 <DetailsAttribute classLabel={classes.label} classValue={classes.value}
125 value={process.container ? formatDate(finishedAt) : 'N/A'}/>
126 {process.containerRequest.properties.templateUuid &&
127 <DetailsAttribute label='Workflow' classLabel={classes.label} classValue={classes.link}
128 value={process.containerRequest.properties.templateUuid}
129 onValueClick={() => navigateToWorkflow(process.containerRequest.properties.templateUuid)}
133 <span onClick={() => navigateToOutput(process.containerRequest.outputUuid!)}>
134 <DetailsAttribute classLabel={classes.link} label='Outputs'/>
136 <span onClick={() => openProcessInputDialog(process.containerRequest.uuid)}>
137 <DetailsAttribute classLabel={classes.link} label='Inputs'/>
146 const getDescription = (process: Process) =>
147 process.containerRequest.description || '(no-description)';