1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
16 } from '@material-ui/core';
17 import { ArvadosTheme } from 'common/custom-theme';
18 import { CloseIcon, MoreOptionsIcon, ProcessIcon } from 'components/icon/icon';
19 import { Process } from 'store/processes/process';
20 import { MPVPanelProps } from 'components/multi-panel-view/multi-panel-view';
21 import { ProcessDetailsAttributes } from './process-details-attributes';
22 import { ProcessStatus } from 'views-components/data-explorer/renderers';
23 import { ContainerState } from 'models/container';
25 type CssRules = 'card' | 'content' | 'title' | 'header' | 'cancelButton' | '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
44 padding: theme.spacing.unit * 1.0,
45 paddingTop: theme.spacing.unit * 0.5,
47 paddingBottom: theme.spacing.unit * 1,
52 paddingTop: theme.spacing.unit * 0.5
55 paddingRight: theme.spacing.unit * 2,
57 color: theme.customs.colors.red900,
64 export interface ProcessDetailsCardDataProps {
66 cancelProcess: (uuid: string) => void;
67 onContextMenu: (event: React.MouseEvent<HTMLElement>) => void;
70 type ProcessDetailsCardProps = ProcessDetailsCardDataProps & WithStyles<CssRules> & MPVPanelProps;
72 export const ProcessDetailsCard = withStyles(styles)(
73 ({ cancelProcess, onContextMenu, classes, process, doHidePanel, panelName }: ProcessDetailsCardProps) => {
74 return <Card className={classes.card}>
76 className={classes.header}
78 content: classes.title,
79 avatar: classes.avatar,
81 avatar={<ProcessIcon className={classes.iconHeader} />}
83 <Tooltip title={process.containerRequest.name} placement="bottom-start">
84 <Typography noWrap variant='h6' color='inherit'>
85 {process.containerRequest.name}
90 <Tooltip title={getDescription(process)} placement="bottom-start">
91 <Typography noWrap variant='body1' color='inherit'>
92 {getDescription(process)}
97 {process.container && process.container.state === ContainerState.RUNNING &&
98 <span className={classes.cancelButton} onClick={() => cancelProcess(process.containerRequest.uuid)}>Cancel</span>}
99 <ProcessStatus uuid={process.containerRequest.uuid} />
100 <Tooltip title="More options" disableFocusListener>
102 aria-label="More options"
103 onClick={event => onContextMenu(event)}>
108 <Tooltip title={`Close ${panelName || 'panel'}`} disableFocusListener>
109 <IconButton onClick={doHidePanel}><CloseIcon /></IconButton>
113 <CardContent className={classes.content}>
114 <ProcessDetailsAttributes request={process.containerRequest} twoCol hideProcessPanelRedundantFields />
120 const getDescription = (process: Process) =>
121 process.containerRequest.description || '(no-description)';