1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import { CustomStyleRulesCallback } from 'common/custom-theme';
7 import { Accordion, AccordionDetails, AccordionSummary, Paper, Typography } from "@mui/material";
8 import { WithStyles } from '@mui/styles';
9 import withStyles from '@mui/styles/withStyles';
10 import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
11 import { RuntimeStatus } from "models/runtime-status";
12 import { ArvadosTheme } from 'common/custom-theme';
13 import classNames from 'classnames';
15 type CssRules = 'root'
27 const styles: CustomStyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
29 marginBottom: theme.spacing(1),
35 paddingLeft: theme.spacing(1),
36 paddingRight: theme.spacing(1),
39 whiteSpace: 'pre-line',
42 paddingLeft: theme.spacing(1),
43 paddingRight: theme.spacing(1),
49 whiteSpace: 'pre-line',
52 color: theme.customs.colors.grey700,
55 backgroundColor: theme.customs.colors.red100,
59 backgroundColor: theme.customs.colors.yellow100,
62 color: theme.customs.colors.grey700,
65 minHeight: theme.spacing(6),
70 export interface ProcessRuntimeStatusDataProps {
71 runtimeStatus: RuntimeStatus | undefined;
72 containerCount: number;
75 type ProcessRuntimeStatusProps = ProcessRuntimeStatusDataProps & WithStyles<CssRules>;
77 export const ProcessRuntimeStatus = withStyles(styles)(
78 ({ runtimeStatus, containerCount, classes }: ProcessRuntimeStatusProps) => {
79 return <div className={classes.root}>
80 { runtimeStatus?.error &&
81 <div data-cy='process-runtime-status-error'><Accordion className={classes.error} elevation={0}>
82 <AccordionSummary className={classNames(classes.summary, classes.detailsText)} expandIcon={<ExpandMoreIcon />}>
83 <Typography className={classNames(classes.heading, classes.errorColor)}>
84 {`Error: ${runtimeStatus.error }`}
87 <AccordionDetails className={classes.details}>
88 <Typography className={classNames(classes.errorColor, classes.detailsText)}>
89 {runtimeStatus?.errorDetail || 'No additional error details available'}
94 { runtimeStatus?.warning &&
95 <div data-cy='process-runtime-status-warning' ><Accordion className={classes.warning} elevation={0}>
96 <AccordionSummary className={classNames(classes.summary, classes.detailsText)} expandIcon={<ExpandMoreIcon />}>
97 <Typography className={classNames(classes.heading, classes.warningColor)}>
98 {`Warning: ${runtimeStatus.warning }`}
101 <AccordionDetails className={classes.details}>
102 <Typography className={classNames(classes.warningColor, classes.detailsText)}>
103 {runtimeStatus?.warningDetail || 'No additional warning details available'}
108 { containerCount > 1 &&
109 <div data-cy='process-runtime-status-retry-warning' >
110 <Paper className={classNames(classes.warning, classes.paperRoot)} elevation={0}>
111 <Typography className={classNames(classes.heading, classes.summary, classes.warningColor)}>
112 {`Warning: Process retried ${containerCount - 1} time${containerCount > 2 ? 's' : ''} due to failure.`}