X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/909ee82b3c7c7fd033c6ab2e82b4fb92f383e191..b066e77c51858c0534c8fdedf6d45a141be85fb9:/src/views/process-panel/process-subprocesses-card.tsx?ds=sidebyside

diff --git a/src/views/process-panel/process-subprocesses-card.tsx b/src/views/process-panel/process-subprocesses-card.tsx
index 2ea1b7eb..be4ad905 100644
--- a/src/views/process-panel/process-subprocesses-card.tsx
+++ b/src/views/process-panel/process-subprocesses-card.tsx
@@ -7,14 +7,14 @@ import {
     StyleRulesCallback, WithStyles, withStyles, Card,
     CardHeader, IconButton, CardContent, Typography, Tooltip
 } from '@material-ui/core';
-import * as classnames from "classnames";
 import { ArvadosTheme } from '~/common/custom-theme';
 import { MoreOptionsIcon } from '~/components/icon/icon';
 import { DetailsAttribute } from '~/components/details-attribute/details-attribute';
-import { getBackgroundColorStatus } from '~/views/process-panel/process-panel';
+import { Process, getProcessStatus, getProcessRuntime } from '~/store/processes/process';
+import { formatTime } from '~/common/formatters';
+import { getProcessStatusColor } from '~/store/processes/process';
 
-export type CssRules = 'label' | 'value' | 'title' | 'content' | 'action' | 'options' | 'status' | 'rightSideHeader' | 'titleHeader'
-    | 'header' | 'headerActive' | 'headerCompleted' | 'headerQueued' | 'headerFailed' | 'headerCanceled';
+export type CssRules = 'label' | 'value' | 'title' | 'content' | 'action' | 'options' | 'status' | 'rightSideHeader' | 'titleHeader' | 'header' | 'moreOptions';
 
 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     label: {
@@ -56,59 +56,56 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
         paddingTop: 0,
         paddingBottom: 0,
     },
-    headerActive: {
-        backgroundColor: theme.customs.colors.blue500,
-    },
-    headerCompleted: {
-        backgroundColor: theme.customs.colors.green700,
-    },
-    headerQueued: {
-        backgroundColor: theme.customs.colors.grey500,
-    },
-    headerFailed: {
-        backgroundColor: theme.customs.colors.red900,
-    },
-    headerCanceled: {
-        backgroundColor: theme.customs.colors.red900,
-    },
+    moreOptions: {
+        position: 'absolute'
+    }
 });
 
+export interface SubprocessItemProps {
+    title: string;
+    status: string;
+    runtime?: string;
+}
+
 export interface ProcessSubprocessesCardDataProps {
     onContextMenu: (event: React.MouseEvent<HTMLElement>) => void;
-    items: any;
+    subprocess: Process;
 }
 
-type ProcessSubprocessesCardProps = ProcessSubprocessesCardDataProps & WithStyles<CssRules>;
+type ProcessSubprocessesCardProps = ProcessSubprocessesCardDataProps & WithStyles<CssRules, true>;
 
-export const ProcessSubprocessesCard = withStyles(styles)(
-    ({ classes, onContextMenu, items }: ProcessSubprocessesCardProps) => {
+export const ProcessSubprocessesCard = withStyles(styles, { withTheme: true })(
+    ({ classes, onContextMenu, subprocess, theme }: ProcessSubprocessesCardProps) => {
         return <Card>
             <CardHeader
-                className={classnames([classes.header, getBackgroundColorStatus(items.status, classes)])}
+                className={classes.header}
+                style={{ backgroundColor: getProcessStatusColor(getProcessStatus(subprocess), theme as ArvadosTheme) }}
                 classes={{ content: classes.title, action: classes.action }}
                 action={
                     <div className={classes.rightSideHeader}>
                         <Typography noWrap variant="body2" className={classes.status}>
-                            {items.status}
+                            {getProcessStatus(subprocess)}
                         </Typography>
-                        <IconButton
-                            className={classes.options}
-                            aria-label="More options"
-                            onClick={event => onContextMenu(event)}>
-                            <MoreOptionsIcon />
-                        </IconButton>
+                        <Tooltip title="More options">
+                            <IconButton
+                                className={classes.options}
+                                aria-label="More options"
+                                onClick={onContextMenu}>
+                                <MoreOptionsIcon className={classes.moreOptions}/>
+                            </IconButton>
+                        </Tooltip>
                     </div>
                 }
                 title={
-                    <Tooltip title={items.title}>
+                    <Tooltip title={subprocess.containerRequest.name}>
                         <Typography noWrap variant="body2" className={classes.titleHeader}>
-                            {items.title}
+                            {subprocess.containerRequest.name}
                         </Typography>
                     </Tooltip>
                 } />
             <CardContent className={classes.content}>
                 <DetailsAttribute classLabel={classes.label} classValue={classes.value}
-                    label='Runtime' value="0h 2m" />
+                    label="Runtime" value={formatTime(getProcessRuntime(subprocess))} />
             </CardContent>
         </Card>;
-    });
\ No newline at end of file
+    });
