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 * as classnames from "classnames";
11 import { ArvadosTheme } from '~/common/custom-theme';
12 import { MoreOptionsIcon } from '~/components/icon/icon';
13 import { DetailsAttribute } from '~/components/details-attribute/details-attribute';
14 import { getBackgroundColorStatus } from '~/views/process-panel/process-panel-root';
15 import { Process, getProcessStatus, getProcessRuntime } from '~/store/processes/process';
16 import { msToTime } from '~/common/formatters';
18 export type CssRules = 'label' | 'value' | 'title' | 'content' | 'action' | 'options' | 'status' | 'rightSideHeader' | 'titleHeader'
19 | 'header' | 'headerActive' | 'headerCompleted' | 'headerQueued' | 'headerFailed' | 'headerCanceled';
21 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
26 textTransform: 'none',
33 paddingTop: theme.spacing.unit * 0.5,
42 width: theme.spacing.unit * 4,
43 height: theme.spacing.unit * 4,
44 color: theme.palette.common.white,
47 paddingTop: theme.spacing.unit * 0.5,
48 color: theme.palette.common.white,
54 color: theme.palette.common.white,
62 backgroundColor: theme.customs.colors.blue500,
65 backgroundColor: theme.customs.colors.green700,
68 backgroundColor: theme.customs.colors.grey500,
71 backgroundColor: theme.customs.colors.red900,
74 backgroundColor: theme.customs.colors.red900,
78 export enum SubprocessesStatus {
80 COMPLETED = 'Completed',
86 export interface SubprocessItemProps {
92 export interface ProcessSubprocessesCardDataProps {
93 onContextMenu: (event: React.MouseEvent<HTMLElement>) => void;
97 type ProcessSubprocessesCardProps = ProcessSubprocessesCardDataProps & WithStyles<CssRules>;
99 export const ProcessSubprocessesCard = withStyles(styles)(
100 ({ classes, onContextMenu, subprocess }: ProcessSubprocessesCardProps) => {
103 className={classnames([classes.header, getBackgroundColorStatus(getProcessStatus(subprocess), classes)])}
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={event => onContextMenu(event)}>
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={msToTime(getProcessRuntime(subprocess))} />