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, StartIcon } from 'components/icon/icon';
20 import { Process } from 'store/processes/process';
21 import { MPVPanelProps } from 'components/multi-panel-view/multi-panel-view';
22 import { ProcessDetailsAttributes } from './process-details-attributes';
23 import { ProcessStatus } from 'views-components/data-explorer/renderers';
24 import { ContainerState } from 'models/container';
25 import { ContainerRequestState } from 'models/container-request';
27 type CssRules = 'card' | 'content' | 'title' | 'header' | 'cancelButton' | 'avatar' | 'iconHeader' | 'runButton';
29 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
34 paddingTop: theme.spacing.unit,
35 paddingBottom: theme.spacing.unit,
39 color: theme.customs.colors.greyL,
42 alignSelf: 'flex-start',
43 paddingTop: theme.spacing.unit * 0.5
46 padding: theme.spacing.unit * 1.0,
47 paddingTop: theme.spacing.unit * 0.5,
49 paddingBottom: theme.spacing.unit * 1,
54 paddingTop: theme.spacing.unit * 0.5,
55 color: theme.customs.colors.green700,
58 paddingRight: theme.spacing.unit * 2,
60 color: theme.customs.colors.red900,
66 backgroundColor: theme.customs.colors.green700,
68 backgroundColor: theme.customs.colors.green800,
70 padding: "0px 5px 0 0",
75 export interface ProcessDetailsCardDataProps {
77 cancelProcess: (uuid: string) => void;
78 startProcess: (uuid: string) => void;
79 onContextMenu: (event: React.MouseEvent<HTMLElement>) => void;
82 type ProcessDetailsCardProps = ProcessDetailsCardDataProps & WithStyles<CssRules> & MPVPanelProps;
84 export const ProcessDetailsCard = withStyles(styles)(
85 ({ cancelProcess, startProcess, onContextMenu, classes, process, doHidePanel, panelName }: ProcessDetailsCardProps) => {
86 return <Card className={classes.card}>
88 className={classes.header}
90 content: classes.title,
91 avatar: classes.avatar,
93 avatar={<ProcessIcon className={classes.iconHeader} />}
95 <Tooltip title={process.containerRequest.name} placement="bottom-start">
96 <Typography noWrap variant='h6'>
97 {process.containerRequest.name}
102 <Tooltip title={getDescription(process)} placement="bottom-start">
103 <Typography noWrap variant='body1' color='inherit'>
104 {getDescription(process)}
109 {process.containerRequest.state === ContainerRequestState.UNCOMMITTED &&
114 className={classes.runButton}
115 onClick={() => startProcess(process.containerRequest.uuid)}>
119 {process.container &&
120 (process.container.state === ContainerState.QUEUED ||
121 process.container.state === ContainerState.LOCKED ||
122 process.container.state === ContainerState.RUNNING) &&
123 process.containerRequest.priority !== null &&
124 process.containerRequest.priority > 0 &&
125 <span data-cy="process-cancel" className={classes.cancelButton} onClick={() => cancelProcess(process.containerRequest.uuid)}>Cancel</span>}
126 <ProcessStatus uuid={process.containerRequest.uuid} />
127 <Tooltip title="More options" disableFocusListener>
129 aria-label="More options"
130 onClick={event => onContextMenu(event)}>
135 <Tooltip title={`Close ${panelName || 'panel'}`} disableFocusListener>
136 <IconButton onClick={doHidePanel}><CloseIcon /></IconButton>
140 <CardContent className={classes.content}>
141 <ProcessDetailsAttributes request={process.containerRequest} twoCol hideProcessPanelRedundantFields />
147 const getDescription = (process: Process) =>
148 process.containerRequest.description || '(no-description)';