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, Typography, Tooltip
9 } from '@material-ui/core';
10 import { ArvadosTheme } from '~/common/custom-theme';
11 import { MoreOptionsIcon } from '~/components/icon/icon';
12 import { DetailsAttribute } from '~/components/details-attribute/details-attribute';
13 import { Process, getProcessStatus, getProcessRuntime } from '~/store/processes/process';
14 import { formatTime } from '~/common/formatters';
15 import { getProcessStatusColor } from '~/store/processes/process';
17 export type CssRules = 'label' | 'value' | 'title' | 'content' | 'action' | 'options' | 'status' | 'rightSideHeader' | 'titleHeader'
18 | 'header' | 'headerActive' | 'headerCompleted' | 'headerQueued' | 'headerFailed' | 'headerCanceled';
20 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
25 textTransform: 'none',
32 paddingTop: theme.spacing.unit * 0.5,
41 width: theme.spacing.unit * 4,
42 height: theme.spacing.unit * 4,
43 color: theme.palette.common.white,
46 paddingTop: theme.spacing.unit * 0.5,
47 color: theme.palette.common.white,
53 color: theme.palette.common.white,
61 backgroundColor: theme.customs.colors.blue500,
64 backgroundColor: theme.customs.colors.green700,
67 backgroundColor: theme.customs.colors.grey500,
70 backgroundColor: theme.customs.colors.red900,
73 backgroundColor: theme.customs.colors.red900,
77 export enum SubprocessesStatus {
79 COMPLETED = 'Completed',
85 export interface SubprocessItemProps {
91 export interface ProcessSubprocessesCardDataProps {
92 onContextMenu: (event: React.MouseEvent<HTMLElement>) => void;
96 type ProcessSubprocessesCardProps = ProcessSubprocessesCardDataProps & WithStyles<CssRules>;
98 export const ProcessSubprocessesCard = withStyles(styles, { withTheme: true })(
99 ({ classes, onContextMenu, subprocess, theme }: ProcessSubprocessesCardProps) => {
102 className={classes.header}
103 style={{ backgroundColor: getProcessStatusColor(getProcessStatus(subprocess), theme as ArvadosTheme) }}
104 classes={{ content: classes.title, action: classes.action }}
106 <div className={classes.rightSideHeader}>
107 <Typography noWrap variant="body2" className={classes.status}>
108 {getProcessStatus(subprocess)}
111 className={classes.options}
112 aria-label="More options"
113 onClick={onContextMenu}>
119 <Tooltip title={subprocess.containerRequest.name}>
120 <Typography noWrap variant="body2" className={classes.titleHeader}>
121 {subprocess.containerRequest.name}
125 <CardContent className={classes.content}>
126 <DetailsAttribute classLabel={classes.label} classValue={classes.value}
127 label="Runtime" value={formatTime(getProcessRuntime(subprocess))} />