18881: Adds runtime_status indicator to the process info card.
authorLucas Di Pentima <lucas.dipentima@curii.com>
Thu, 7 Apr 2022 21:15:33 +0000 (18:15 -0300)
committerLucas Di Pentima <lucas.dipentima@curii.com>
Thu, 7 Apr 2022 21:15:33 +0000 (18:15 -0300)
Also, improves a bit the layout and reclaims some padding space.

Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima@curii.com>

src/common/custom-theme.ts
src/views-components/process-runtime-status/process-runtime-status.tsx [new file with mode: 0644]
src/views/process-panel/process-information-card.tsx

index cff18538424c57cdc5194a0c05afe9c1e2e4321e..b0703237af97f4c603dffdf42548302cb67a7eac 100644 (file)
@@ -23,7 +23,10 @@ export interface ArvadosTheme extends Theme {
 
 interface Colors {
     green700: string;
+    yellow100: string;
     yellow700: string;
+    yellow900: string;
+    red100: string;
     red900: string;
     blue500: string;
     grey500: string;
@@ -43,7 +46,10 @@ export const themeOptions: ArvadosThemeOptions = {
     customs: {
         colors: {
             green700: green["700"],
+            yellow100: yellow["100"],
             yellow700: yellow["700"],
+            yellow900: yellow["900"],
+            red100: red["100"],
             red900: red['900'],
             blue500: blue['500'],
             grey500: grey500,
diff --git a/src/views-components/process-runtime-status/process-runtime-status.tsx b/src/views-components/process-runtime-status/process-runtime-status.tsx
new file mode 100644 (file)
index 0000000..fdd635d
--- /dev/null
@@ -0,0 +1,86 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import React from 'react';
+import {
+    ExpansionPanel,
+    ExpansionPanelDetails,
+    ExpansionPanelSummary,
+    StyleRulesCallback,
+    Typography,
+    withStyles,
+    WithStyles
+} from "@material-ui/core";
+import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
+import { RuntimeStatus } from "models/runtime-status";
+import { ArvadosTheme } from 'common/custom-theme';
+import classNames from 'classnames';
+
+type CssRules = 'heading' | 'summary' | 'details' | 'error' | 'errorColor' | 'warning' | 'warningColor';
+
+const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
+    heading: {
+        fontSize: '1rem',
+    },
+    summary: {
+        paddingLeft: theme.spacing.unit * 1,
+        paddingRight: theme.spacing.unit * 1,
+    },
+    details: {
+        paddingLeft: theme.spacing.unit * 1,
+        paddingRight: theme.spacing.unit * 1,
+    },
+    errorColor: {
+        color: theme.customs.colors.red900,
+    },
+    error: {
+        backgroundColor: theme.customs.colors.red100,
+
+    },
+    warning: {
+        backgroundColor: theme.customs.colors.yellow100,
+    },
+    warningColor: {
+        color: theme.customs.colors.yellow900,
+    },
+});
+export interface ProcessRuntimeStatusDataProps {
+    runtimeStatus: RuntimeStatus | undefined;
+}
+
+type ProcessRuntimeStatusProps = ProcessRuntimeStatusDataProps & WithStyles<CssRules>;
+
+export const ProcessRuntimeStatus = withStyles(styles)(
+    ({ runtimeStatus, classes }: ProcessRuntimeStatusProps) => {
+    return <>
+        { runtimeStatus?.error &&
+        <ExpansionPanel className={classes.error} elevation={0}>
+            <ExpansionPanelSummary className={classes.summary} expandIcon={<ExpandMoreIcon />}>
+                <Typography className={classNames(classes.heading, classes.errorColor)}>
+                    {`Error: ${runtimeStatus.error }`}
+                </Typography>
+            </ExpansionPanelSummary>
+            <ExpansionPanelDetails className={classes.details}>
+                <Typography className={classes.errorColor}>
+                    {runtimeStatus?.errorDetail || 'No additional error details available'}
+                </Typography>
+            </ExpansionPanelDetails>
+        </ExpansionPanel>
+        }
+        { runtimeStatus?.warning &&
+        <ExpansionPanel className={classes.warning} elevation={0}>
+            <ExpansionPanelSummary className={classes.summary} expandIcon={<ExpandMoreIcon />}>
+                <Typography className={classNames(classes.heading, classes.warningColor)}>
+                    {`Warning: ${runtimeStatus.warning }`}
+                </Typography>
+            </ExpansionPanelSummary>
+            <ExpansionPanelDetails className={classes.details}>
+                <Typography className={classes.warningColor}>
+                    {runtimeStatus?.warningDetail || 'No additional warning details available'}
+                </Typography>
+            </ExpansionPanelDetails>
+        </ExpansionPanel>
+        }
+    </>
+});
\ No newline at end of file
index fc34a31c2f2b0c7a761b88b85ca1b7e485091890..8f16db70c422f975b43950fe87e822b004f0812e 100644 (file)
@@ -16,6 +16,7 @@ import { formatDate } from 'common/formatters';
 import classNames from 'classnames';
 import { ContainerState } from 'models/container';
 import { MPVPanelProps } from 'components/multi-panel-view/multi-panel-view';
+import { ProcessRuntimeStatus } from 'views-components/process-runtime-status/process-runtime-status';
 
 type CssRules = 'card' | 'iconHeader' | 'label' | 'value' | 'chip' | 'link' | 'content' | 'title' | 'avatar' | 'cancelButton' | 'header';
 
@@ -37,7 +38,7 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     },
     label: {
         display: 'flex',
-        justifyContent: 'flex-end',
+        justifyContent: 'flex-start',
         fontSize: '0.875rem',
         marginRight: theme.spacing.unit * 3,
         paddingRight: theme.spacing.unit
@@ -61,8 +62,11 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
         borderRadius: theme.spacing.unit * 0.625,
     },
     content: {
+        paddingTop: '0px',
+        paddingLeft: theme.spacing.unit * 1,
+        paddingRight: theme.spacing.unit * 1,
         '&:last-child': {
-            paddingBottom: theme.spacing.unit * 2,
+            paddingBottom: theme.spacing.unit * 1,
         }
     },
     title: {
@@ -123,27 +127,28 @@ export const ProcessInformationCard = withStyles(styles, { withTheme: true })(
                         </Tooltip> }
                     </div>
                 }
-                title={
-                    <Tooltip title={process.containerRequest.name} placement="bottom-start">
-                        <Typography noWrap variant='h6' color='inherit'>
-                            {process.containerRequest.name}
-                        </Typography>
-                    </Tooltip>
+                title={ !!process.containerRequest.name &&
+                    <Typography noWrap variant='h6' color='inherit'>
+                        {process.containerRequest.name}
+                    </Typography>
                 }
                 subheader={
-                    <Tooltip title={getDescription(process)} placement="bottom-start">
-                        <Typography noWrap variant='body1' color='inherit'>
-                            {getDescription(process)}
-                        </Typography>
-                    </Tooltip>} />
+                    <Typography noWrap variant='body1' color='inherit'>
+                        {process.containerRequest.description}
+                    </Typography>
+                }
+            />
             <CardContent className={classes.content}>
                 <Grid container>
+                    <Grid item xs={12}>
+                        <ProcessRuntimeStatus runtimeStatus={process.container?.runtimeStatus} />
+                    </Grid>
                     <Grid item xs={6}>
                         <DetailsAttribute classLabel={classes.label} classValue={classes.value}
-                            label='From'
+                            label='Started at'
                             value={startedAt} />
                         <DetailsAttribute classLabel={classes.label} classValue={classes.value}
-                            label='To'
+                            label='Finished at'
                             value={finishedAt} />
                         {process.containerRequest.properties.workflowUuid &&
                             <span onClick={() => openWorkflow(process.containerRequest.properties.workflowUuid)}>
@@ -164,6 +169,3 @@ export const ProcessInformationCard = withStyles(styles, { withTheme: true })(
         </Card>;
     }
 );
-
-const getDescription = (process: Process) =>
-    process.containerRequest.description || '(no-description)';