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';
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;
73 type ProcessInformationCardProps = ProcessInformationCardDataProps & WithStyles<CssRules, true>;
75 export const ProcessInformationCard = withStyles(styles, { withTheme: true })(
76 ({ classes, process, onContextMenu, theme }: ProcessInformationCardProps) =>
77 <Card className={classes.card}>
80 content: classes.title,
81 avatar: classes.avatar
83 avatar={<ProcessIcon className={classes.iconHeader} />}
86 <Chip label={getProcessStatus(process)}
87 className={classes.chip}
88 style={{ backgroundColor: getProcessStatusColor(getProcessStatus(process), theme as ArvadosTheme) }} />
89 <Tooltip title="More options">
91 aria-label="More options"
92 onClick={event => onContextMenu(event)}>
99 <Tooltip title={process.containerRequest.name} placement="bottom-start">
100 <Typography noWrap variant="title" color='inherit'>
101 {process.containerRequest.name}
106 <Tooltip title={getDescription(process)} placement="bottom-start">
107 <Typography noWrap variant="body2" color='inherit'>
108 {getDescription(process)}
111 <CardContent className={classes.content}>
114 <DetailsAttribute classLabel={classes.label} classValue={classes.value}
115 label='From' value={process.container ? formatDate(process.container.startedAt!) : 'N/A'} />
116 <DetailsAttribute classLabel={classes.label} classValue={classes.value}
117 label='To' value={process.container ? formatDate(process.container.finishedAt!) : 'N/A'} />
118 <DetailsAttribute classLabel={classes.label} classValue={classes.link}
119 label='Workflow' value='???' />
122 <DetailsAttribute classLabel={classes.link} label='Outputs' />
123 <DetailsAttribute classLabel={classes.link} label='Inputs' />
130 const getDescription = (process: Process) =>
131 process.containerRequest.description || '(no-description)';