1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
17 } from '@material-ui/core';
18 import { ArvadosTheme } from 'common/custom-theme';
19 import { CloseIcon, MoreOptionsIcon, ProcessIcon } from 'components/icon/icon';
20 import { Process, getProcessStatus, getProcessStatusColor } from 'store/processes/process';
21 import { MPVPanelProps } from 'components/multi-panel-view/multi-panel-view';
22 import { ProcessDetailsAttributes } from './process-details-attributes';
23 import { ContainerState } from 'models/container';
25 type CssRules = 'card' | 'content' | 'title' | 'header' | 'cancelButton' | 'chip' | 'avatar' | 'iconHeader';
27 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
32 paddingTop: theme.spacing.unit,
33 paddingBottom: theme.spacing.unit,
37 color: theme.customs.colors.green700,
40 alignSelf: 'flex-start',
41 paddingTop: theme.spacing.unit * 0.5
45 paddingBottom: theme.spacing.unit * 2,
50 paddingTop: theme.spacing.unit * 0.5
53 paddingRight: theme.spacing.unit * 2,
55 color: theme.customs.colors.red900,
61 height: theme.spacing.unit * 3,
62 width: theme.spacing.unit * 12,
63 color: theme.palette.common.white,
65 borderRadius: theme.spacing.unit * 0.625,
69 export interface ProcessDetailsCardDataProps {
71 cancelProcess: (uuid: string) => void;
72 onContextMenu: (event: React.MouseEvent<HTMLElement>) => void;
75 type ProcessDetailsCardProps = ProcessDetailsCardDataProps & WithStyles<CssRules, true> & MPVPanelProps;
77 export const ProcessDetailsCard = withStyles(styles, {withTheme: true})(
78 ({ theme, cancelProcess, onContextMenu, classes, process, doHidePanel, panelName }: ProcessDetailsCardProps) => {
79 return <Card className={classes.card}>
81 className={classes.header}
83 content: classes.title,
84 avatar: classes.avatar,
86 avatar={<ProcessIcon className={classes.iconHeader} />}
88 <Tooltip title={process.containerRequest.name} placement="bottom-start">
89 <Typography noWrap variant='h6' color='inherit'>
90 {process.containerRequest.name}
95 <Tooltip title={getDescription(process)} placement="bottom-start">
96 <Typography noWrap variant='body1' color='inherit'>
97 {getDescription(process)}
102 {process.container && process.container.state === ContainerState.RUNNING &&
103 <span className={classes.cancelButton} onClick={() => cancelProcess(process.containerRequest.uuid)}>Cancel</span>}
104 <Chip label={getProcessStatus(process)}
105 className={classes.chip}
106 style={{ backgroundColor: getProcessStatusColor(getProcessStatus(process), theme as ArvadosTheme) }} />
107 <Tooltip title="More options" disableFocusListener>
109 aria-label="More options"
110 onClick={event => onContextMenu(event)}>
115 <Tooltip title={`Close ${panelName || 'panel'}`} disableFocusListener>
116 <IconButton onClick={doHidePanel}><CloseIcon /></IconButton>
120 <CardContent className={classes.content}>
121 <ProcessDetailsAttributes request={process.containerRequest} twoCol />
127 const getDescription = (process: Process) =>
128 process.containerRequest.description || '(no-description)';