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 * as classnames from "classnames";
11 import { ArvadosTheme } from '~/common/custom-theme';
12 import { MoreOptionsIcon, ProcessIcon } from '~/components/icon/icon';
13 import { DetailsAttribute } from '~/components/details-attribute/details-attribute';
14 import { Process } from '~/store/processes/process';
15 import { getProcessStatus } from '~/store/processes/process';
16 import { getBackgroundColorStatus } from '~/views/process-panel/process-panel-root';
18 type CssRules = 'card' | 'iconHeader' | 'label' | 'value' | 'chip' | 'link' | 'content' | 'title' | 'avatar'
19 | 'headerActive' | 'headerCompleted' | 'headerQueued' | 'headerFailed' | 'headerCanceled';
21 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
23 marginBottom: theme.spacing.unit * 2
27 color: theme.customs.colors.green700,
30 alignSelf: 'flex-start',
31 paddingTop: theme.spacing.unit * 0.5
35 justifyContent: 'flex-end',
37 marginRight: theme.spacing.unit * 3,
38 paddingRight: theme.spacing.unit
41 textTransform: 'none',
46 color: theme.palette.primary.main,
52 height: theme.spacing.unit * 3,
53 width: theme.spacing.unit * 12,
54 color: theme.palette.common.white,
56 borderRadius: theme.spacing.unit * 0.625,
60 paddingBottom: theme.spacing.unit * 2,
66 paddingTop: theme.spacing.unit * 0.5
69 backgroundColor: theme.customs.colors.blue500,
72 backgroundColor: theme.customs.colors.green700,
75 backgroundColor: theme.customs.colors.grey500,
78 backgroundColor: theme.customs.colors.red900,
81 backgroundColor: theme.customs.colors.red900,
85 export interface ProcessInformationCardDataProps {
87 onContextMenu: (event: React.MouseEvent<HTMLElement>) => void;
90 type ProcessInformationCardProps = ProcessInformationCardDataProps & WithStyles<CssRules>;
92 export const ProcessInformationCard = withStyles(styles)(
93 ({ classes, process, onContextMenu }: ProcessInformationCardProps) =>
94 <Card className={classes.card}>
97 content: classes.title,
98 avatar: classes.avatar
100 avatar={<ProcessIcon className={classes.iconHeader} />}
103 <Chip label={getProcessStatus(process)}
104 className={classnames([classes.chip, getBackgroundColorStatus(getProcessStatus(process), classes)])} />
106 aria-label="More options"
107 onClick={event => onContextMenu(event)}>
113 <Tooltip title={process.containerRequest.name}>
114 <Typography noWrap variant="title">
115 {process.containerRequest.name}
119 subheader={process.containerRequest.description} />
120 <CardContent className={classes.content}>
123 <DetailsAttribute classLabel={classes.label} classValue={classes.value}
124 label='From' value={process.container ? process.container.startedAt : 'N/A'} />
125 <DetailsAttribute classLabel={classes.label} classValue={classes.value}
126 label='To' value={process.container ? process.container.finishedAt : 'N/A'} />
127 <DetailsAttribute classLabel={classes.label} classValue={classes.link}
128 label='Workflow' value='???' />
131 <DetailsAttribute classLabel={classes.link} label='Outputs' />
132 <DetailsAttribute classLabel={classes.link} label='Inputs' />