From b812133ea0d9c9a4c52b200731deaba1045478e3 Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Thu, 7 Apr 2022 18:15:33 -0300 Subject: [PATCH] 18881: Adds runtime_status indicator to the process info card. Also, improves a bit the layout and reclaims some padding space. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- src/common/custom-theme.ts | 6 ++ .../process-runtime-status.tsx | 86 +++++++++++++++++++ .../process-information-card.tsx | 38 ++++---- 3 files changed, 112 insertions(+), 18 deletions(-) create mode 100644 src/views-components/process-runtime-status/process-runtime-status.tsx diff --git a/src/common/custom-theme.ts b/src/common/custom-theme.ts index cff18538..b0703237 100644 --- a/src/common/custom-theme.ts +++ b/src/common/custom-theme.ts @@ -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 index 00000000..fdd635d2 --- /dev/null +++ b/src/views-components/process-runtime-status/process-runtime-status.tsx @@ -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 = (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; + +export const ProcessRuntimeStatus = withStyles(styles)( + ({ runtimeStatus, classes }: ProcessRuntimeStatusProps) => { + return <> + { runtimeStatus?.error && + + }> + + {`Error: ${runtimeStatus.error }`} + + + + + {runtimeStatus?.errorDetail || 'No additional error details available'} + + + + } + { runtimeStatus?.warning && + + }> + + {`Warning: ${runtimeStatus.warning }`} + + + + + {runtimeStatus?.warningDetail || 'No additional warning details available'} + + + + } + +}); \ No newline at end of file diff --git a/src/views/process-panel/process-information-card.tsx b/src/views/process-panel/process-information-card.tsx index fc34a31c..8f16db70 100644 --- a/src/views/process-panel/process-information-card.tsx +++ b/src/views/process-panel/process-information-card.tsx @@ -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 = (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 = (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 })( } } - title={ - - - {process.containerRequest.name} - - + title={ !!process.containerRequest.name && + + {process.containerRequest.name} + } subheader={ - - - {getDescription(process)} - - } /> + + {process.containerRequest.description} + + } + /> + + + {process.containerRequest.properties.workflowUuid && openWorkflow(process.containerRequest.properties.workflowUuid)}> @@ -164,6 +169,3 @@ export const ProcessInformationCard = withStyles(styles, { withTheme: true })( ; } ); - -const getDescription = (process: Process) => - process.containerRequest.description || '(no-description)'; -- 2.30.2