// Copyright (C) The Arvados Authors. All rights reserved. // // SPDX-License-Identifier: AGPL-3.0 import React from 'react'; import { StyleRulesCallback, WithStyles, withStyles, Card, CardHeader, IconButton, CardContent, Tooltip, Typography, Button, } from '@material-ui/core'; import { ArvadosTheme } from 'common/custom-theme'; import { CloseIcon, MoreVerticalIcon, ProcessIcon, StartIcon, StopIcon } from 'components/icon/icon'; import { Process, isProcessRunnable, isProcessResumable, isProcessCancelable } from 'store/processes/process'; import { MPVPanelProps } from 'components/multi-panel-view/multi-panel-view'; import { ProcessDetailsAttributes } from './process-details-attributes'; import { ProcessStatus } from 'views-components/data-explorer/renderers'; import classNames from 'classnames'; type CssRules = 'card' | 'content' | 'title' | 'header' | 'cancelButton' | 'avatar' | 'iconHeader' | 'actionButton'; const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ card: { height: '100%' }, header: { paddingTop: theme.spacing.unit, paddingBottom: theme.spacing.unit, }, iconHeader: { fontSize: '1.875rem', color: theme.customs.colors.greyL, }, avatar: { alignSelf: 'flex-start', paddingTop: theme.spacing.unit * 0.5 }, content: { padding: theme.spacing.unit * 1.0, paddingTop: theme.spacing.unit * 0.5, '&:last-child': { paddingBottom: theme.spacing.unit * 1, } }, title: { overflow: 'hidden', paddingTop: theme.spacing.unit * 0.5, color: theme.customs.colors.green700, }, actionButton: { padding: "0px 5px 0 0", marginRight: "5px", fontSize: '0.78rem', }, cancelButton: { color: theme.palette.common.white, backgroundColor: theme.customs.colors.red900, '&:hover': { backgroundColor: theme.customs.colors.red900, }, '& svg': { fontSize: '22px', }, }, }); export interface ProcessDetailsCardDataProps { process: Process; cancelProcess: (uuid: string) => void; startProcess: (uuid: string) => void; resumeOnHoldWorkflow: (uuid: string) => void; onContextMenu: (event: React.MouseEvent) => void; } type ProcessDetailsCardProps = ProcessDetailsCardDataProps & WithStyles & MPVPanelProps; export const ProcessDetailsCard = withStyles(styles)( ({ cancelProcess, startProcess, resumeOnHoldWorkflow, onContextMenu, classes, process, doHidePanel, panelName }: ProcessDetailsCardProps) => { let runAction: ((uuid: string) => void) | undefined = undefined; if (isProcessRunnable(process)) { runAction = startProcess; } else if (isProcessResumable(process)) { runAction = resumeOnHoldWorkflow; } return } title={ {process.containerRequest.name} } subheader={ {getDescription(process)} } action={
{runAction !== undefined && } {isProcessCancelable(process) && } onContextMenu(event)}> {doHidePanel && }
} />
; } ); const getDescription = (process: Process) => process.containerRequest.description || '(no-description)';