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 { DetailsAttribute } from 'components/details-attribute/details-attribute';
21 import { Process } from 'store/processes/process';
22 import { formatDate } from 'common/formatters';
23 import classNames from 'classnames';
24 import { ContainerState } from 'models/container';
25 import { MPVPanelProps } from 'components/multi-panel-view/multi-panel-view';
26 import { ProcessRuntimeStatus } from 'views-components/process-runtime-status/process-runtime-status';
27 import { ProcessStatus } from 'views-components/data-explorer/renderers';
29 type CssRules = 'card' | 'iconHeader' | 'label' | 'value' | 'link' | 'content' | 'title' | 'avatar' | 'cancelButton' | 'header';
31 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
36 paddingTop: theme.spacing.unit,
37 paddingBottom: theme.spacing.unit,
41 color: theme.customs.colors.green700,
44 alignSelf: 'flex-start',
45 paddingTop: theme.spacing.unit * 0.5
49 justifyContent: 'flex-start',
51 marginRight: theme.spacing.unit * 3,
52 paddingRight: theme.spacing.unit
55 textTransform: 'none',
60 color: theme.palette.primary.main,
67 paddingLeft: theme.spacing.unit * 1,
68 paddingRight: theme.spacing.unit * 1,
70 paddingBottom: theme.spacing.unit * 1,
75 paddingTop: theme.spacing.unit * 0.5
78 paddingRight: theme.spacing.unit * 2,
80 color: theme.customs.colors.red900,
87 export interface ProcessInformationCardDataProps {
89 onContextMenu: (event: React.MouseEvent<HTMLElement>) => void;
90 openProcessInputDialog: (uuid: string) => void;
91 navigateToOutput: (uuid: string) => void;
92 openWorkflow: (uuid: string) => void;
93 cancelProcess: (uuid: string) => void;
96 type ProcessInformationCardProps = ProcessInformationCardDataProps & WithStyles<CssRules, true> & MPVPanelProps;
98 export const ProcessInformationCard = withStyles(styles, { withTheme: true })(
99 ({ classes, process, onContextMenu, theme, openProcessInputDialog, navigateToOutput, openWorkflow, cancelProcess, doHidePanel, panelName }: ProcessInformationCardProps) => {
100 const { container } = process;
101 const startedAt = container ? formatDate(container.startedAt) : 'N/A';
102 const finishedAt = container ? formatDate(container.finishedAt) : 'N/A';
103 return <Card className={classes.card}>
105 className={classes.header}
107 content: classes.title,
108 avatar: classes.avatar
110 avatar={<ProcessIcon className={classes.iconHeader} />}
113 {process.container && process.container.state === ContainerState.RUNNING &&
114 <span className={classes.cancelButton} onClick={() => cancelProcess(process.containerRequest.uuid)}>Cancel</span>}
115 <ProcessStatus uuid={process.containerRequest.uuid} />
116 <Tooltip title="More options" disableFocusListener>
118 aria-label="More options"
119 onClick={event => onContextMenu(event)}>
124 <Tooltip title={`Close ${panelName || 'panel'}`} disableFocusListener>
125 <IconButton onClick={doHidePanel}><CloseIcon /></IconButton>
129 title={ !!process.containerRequest.name &&
130 <Typography noWrap variant='h6' color='inherit'>
131 {process.containerRequest.name}
135 <Typography noWrap variant='body1' color='inherit'>
136 {process.containerRequest.description}
140 <CardContent className={classes.content}>
143 <ProcessRuntimeStatus runtimeStatus={process.container?.runtimeStatus} />
146 <DetailsAttribute classLabel={classes.label} classValue={classes.value}
149 <DetailsAttribute classLabel={classes.label} classValue={classes.value}
151 value={finishedAt} />
152 {process.containerRequest.properties.workflowUuid &&
153 <span onClick={() => openWorkflow(process.containerRequest.properties.workflowUuid)}>
154 <DetailsAttribute classLabel={classes.label} classValue={classNames(classes.value, classes.link)}
155 label='Workflow' value={process.containerRequest.properties.workflowName} />
159 <span onClick={() => navigateToOutput(process.containerRequest.outputUuid!)}>
160 <DetailsAttribute classLabel={classes.link} label='Outputs' />
162 <span onClick={() => openProcessInputDialog(process.containerRequest.uuid)}>
163 <DetailsAttribute classLabel={classes.link} label='Inputs' />