process-view-subprocesses
[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 * 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 { getBackgroundColorStatus } from '~/views/process-panel/process-panel';
15 import { SubprocessesStatus } from '~/views/process-panel/process-subprocesses';
16
17 type CssRules = 'card' | 'iconHeader' | 'label' | 'value' | 'chip' | 'link' | 'content' | 'title' | 'avatar'
18     | 'headerActive' | 'headerCompleted' | 'headerQueued' | 'headerFailed' | 'headerCanceled';
19
20 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
21     card: {
22         marginBottom: theme.spacing.unit * 2
23     },
24     iconHeader: {
25         fontSize: '1.875rem',
26         color: theme.customs.colors.green700,
27     },
28     avatar: {
29         alignSelf: 'flex-start',
30         paddingTop: theme.spacing.unit * 0.5
31     },
32     label: {
33         display: 'flex',
34         justifyContent: 'flex-end',
35         fontSize: '0.875rem',
36         marginRight: theme.spacing.unit * 3,
37         paddingRight: theme.spacing.unit
38     },
39     value: {
40         textTransform: 'none',
41         fontSize: '0.875rem',
42     },
43     link: {
44         fontSize: '0.875rem',
45         color: theme.palette.primary.main,
46         '&:hover': {
47             cursor: 'pointer'
48         }
49     },
50     chip: {
51         height: theme.spacing.unit * 3,
52         width: theme.spacing.unit * 12,
53         color: theme.palette.common.white,
54         fontSize: '0.875rem',
55         borderRadius: theme.spacing.unit * 0.625,
56     },
57     content: {
58         '&:last-child': {
59             paddingBottom: theme.spacing.unit * 2,
60             paddingTop: '0px'
61         }
62     },
63     title: {
64         overflow: 'hidden',
65         paddingTop: theme.spacing.unit * 0.5
66     },
67     headerActive: {
68         backgroundColor: theme.customs.colors.blue500,
69     },
70     headerCompleted: {
71         backgroundColor: theme.customs.colors.green700,
72     },
73     headerQueued: {
74         backgroundColor: theme.customs.colors.grey500,
75     },
76     headerFailed: {
77         backgroundColor: theme.customs.colors.red900,
78     },
79     headerCanceled: {
80         backgroundColor: theme.customs.colors.red900,
81     },
82 });
83
84 export interface ProcessInformationCardDataProps {
85     item: any;
86     onContextMenu: (event: React.MouseEvent<HTMLElement>) => void;
87 }
88
89 type ProcessInformationCardProps = ProcessInformationCardDataProps & WithStyles<CssRules>;
90
91 export const ProcessInformationCard = withStyles(styles)(
92     ({ classes, onContextMenu }: ProcessInformationCardProps) =>
93         <Card className={classes.card}>
94             <CardHeader
95                 classes={{
96                     content: classes.title,
97                     avatar: classes.avatar
98                 }}
99                 avatar={<ProcessIcon className={classes.iconHeader} />}
100                 action={
101                     <div>
102                         <Chip label={SubprocessesStatus.ACTIVE}
103                             className={classnames([classes.chip, getBackgroundColorStatus(SubprocessesStatus.ACTIVE, classes)])} />
104                         <IconButton
105                             aria-label="More options"
106                             onClick={event => onContextMenu(event)}>
107                             <MoreOptionsIcon />
108                         </IconButton>
109                     </div>
110                 }
111                 title={
112                     <Tooltip title="Pipeline template that generates a config file from a template">
113                         <Typography noWrap variant="title">
114                             Pipeline template that generates a config file from a template
115                         </Typography>
116                     </Tooltip>
117                 }
118                 subheader="(no-description)" />
119             <CardContent className={classes.content}>
120                 <Grid container>
121                     <Grid item xs={6}>
122                         <DetailsAttribute classLabel={classes.label} classValue={classes.value}
123                             label='From' value="1:25 PM 3/23/2018" />
124                         <DetailsAttribute classLabel={classes.label} classValue={classes.value}
125                             label='To' value='1:25 PM 3/23/2018' />
126                         <DetailsAttribute classLabel={classes.label} classValue={classes.link}
127                             label='Workflow' value='FastQC MultiQC' />
128                     </Grid>
129                     <Grid item xs={6}>
130                         <DetailsAttribute classLabel={classes.link} label='Outputs' />
131                         <DetailsAttribute classLabel={classes.link} label='Inputs' />
132                     </Grid>
133                 </Grid>
134             </CardContent>
135         </Card>
136 );