merge conflict
[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, getProcessStatusColor } from '~/store/processes/process';
14 import { getProcessStatus } from '~/store/processes/process';
15
16
17 type CssRules = 'card' | 'iconHeader' | 'label' | 'value' | 'chip' | 'link' | 'content' | 'title' | 'avatar';
18
19 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
20     card: {
21         marginBottom: theme.spacing.unit * 2
22     },
23     iconHeader: {
24         fontSize: '1.875rem',
25         color: theme.customs.colors.green700,
26     },
27     avatar: {
28         alignSelf: 'flex-start',
29         paddingTop: theme.spacing.unit * 0.5
30     },
31     label: {
32         display: 'flex',
33         justifyContent: 'flex-end',
34         fontSize: '0.875rem',
35         marginRight: theme.spacing.unit * 3,
36         paddingRight: theme.spacing.unit
37     },
38     value: {
39         textTransform: 'none',
40         fontSize: '0.875rem',
41     },
42     link: {
43         fontSize: '0.875rem',
44         color: theme.palette.primary.main,
45         '&:hover': {
46             cursor: 'pointer'
47         }
48     },
49     chip: {
50         height: theme.spacing.unit * 3,
51         width: theme.spacing.unit * 12,
52         color: theme.palette.common.white,
53         fontSize: '0.875rem',
54         borderRadius: theme.spacing.unit * 0.625,
55     },
56     content: {
57         '&:last-child': {
58             paddingBottom: theme.spacing.unit * 2,
59             paddingTop: '0px'
60         }
61     },
62     title: {
63         overflow: 'hidden',
64         paddingTop: theme.spacing.unit * 0.5
65     }
66 });
67
68 export interface ProcessInformationCardDataProps {
69     process: Process;
70     onContextMenu: (event: React.MouseEvent<HTMLElement>) => void;
71 }
72
73 type ProcessInformationCardProps = ProcessInformationCardDataProps & WithStyles<CssRules>;
74
75 export const ProcessInformationCard = withStyles(styles, { withTheme: true })(
76     ({ classes, process, onContextMenu, theme }: ProcessInformationCardProps) =>
77         <Card className={classes.card}>
78             <CardHeader
79                 classes={{
80                     content: classes.title,
81                     avatar: classes.avatar
82                 }}
83                 avatar={<ProcessIcon className={classes.iconHeader} />}
84                 action={
85                     <div>
86                         <Chip label={getProcessStatus(process)}
87                             className={classes.chip} 
88                             style={{ backgroundColor: getProcessStatusColor(getProcessStatus(process), theme as ArvadosTheme) }}/>
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} placement="bottom-start" color='inherit'>
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 );