Setup routing for process panel
[arvados-workbench2.git] / src / views / process-panel / process-information-card.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import * as React from 'react';
6 import {
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 } from '../../store/processes/process';
15
16 type CssRules = 'card' | 'iconHeader' | 'label' | 'value' | 'chip' | 'headerText' | 'link' | 'content' | 'title' | 'avatar';
17
18 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
19     card: {
20         marginBottom: theme.spacing.unit * 2
21     },
22     iconHeader: {
23         fontSize: '1.875rem',
24         color: theme.customs.colors.green700,
25     },
26     avatar: {
27         alignSelf: 'flex-start'
28     },
29     label: {
30         display: 'flex',
31         justifyContent: 'flex-end',
32         fontSize: '0.875rem',
33         marginRight: theme.spacing.unit * 3,
34         paddingRight: theme.spacing.unit
35     },
36     value: {
37         textTransform: 'none',
38         fontSize: '0.875rem',
39     },
40     link: {
41         fontSize: '0.875rem',
42         color: theme.palette.primary.main,
43         '&:hover': {
44             cursor: 'pointer'
45         }
46     },
47     chip: {
48         height: theme.spacing.unit * 3,
49         width: theme.spacing.unit * 12,
50         backgroundColor: theme.customs.colors.green700,
51         color: theme.palette.common.white,
52         fontSize: '0.875rem',
53         borderRadius: theme.spacing.unit * 0.625,
54     },
55     headerText: {
56         fontSize: '0.875rem',
57         marginLeft: theme.spacing.unit * 3,
58     },
59     content: {
60         '&:last-child': {
61             paddingBottom: theme.spacing.unit * 2,
62             paddingTop: '0px'
63         }
64     },
65     title: {
66         overflow: 'hidden'
67     }
68 });
69
70 export interface ProcessInformationCardDataProps {
71     process: Process;
72     onContextMenu: (event: React.MouseEvent<HTMLElement>) => void;
73 }
74
75 type ProcessInformationCardProps = ProcessInformationCardDataProps & WithStyles<CssRules>;
76
77 export const ProcessInformationCard = withStyles(styles)(
78     ({ classes, process, onContextMenu }: ProcessInformationCardProps) =>
79         <Card className={classes.card}>
80             <CardHeader
81                 classes={{
82                     content: classes.title,
83                     avatar: classes.avatar
84                 }}
85                 avatar={<ProcessIcon className={classes.iconHeader} />}
86                 action={
87                     <div>
88                         <Chip label={getProcessStatus(process)} className={classes.chip} />
89                         <IconButton
90                             aria-label="More options"
91                             onClick={event => onContextMenu(event)}>
92                             <MoreOptionsIcon />
93                         </IconButton>
94                     </div>
95                 }
96                 title={
97                     <Tooltip title={process.containerRequest.name}>
98                         <Typography noWrap variant="title">
99                            {process.containerRequest.name}
100                         </Typography>
101                     </Tooltip>
102                 }
103                 subheader={process.containerRequest.description} />
104             <CardContent className={classes.content}>
105                 <Grid container>
106                     <Grid item xs={6}>
107                         <DetailsAttribute classLabel={classes.label} classValue={classes.value}
108                             label='From' value={process.container ? process.container.startedAt : 'N/A'} />
109                         <DetailsAttribute classLabel={classes.label} classValue={classes.value}
110                             label='To' value={process.container ? process.container.finishedAt : 'N/A'} />
111                         <DetailsAttribute classLabel={classes.label} classValue={classes.link}
112                             label='Workflow' value='???' />
113                     </Grid>
114                     <Grid item xs={6}>
115                         <DetailsAttribute classLabel={classes.link} label='Outputs' />
116                         <DetailsAttribute classLabel={classes.link} label='Inputs' />
117                     </Grid>
118                 </Grid>
119             </CardContent>
120         </Card>
121 );