Added fixes for handling edge cases in Workflow Visualisation Screen (#2660)

* Added Fix for some edge cases and replaced Status Succeeded with Completed for workflow and Nodes.
* Added required changes

Signed-off-by: Jonsy13 <vedant.shrotria@chaosnative.com>
This commit is contained in:
VEDANT SHROTRIA 2021-04-08 16:41:01 +05:30 committed by GitHub
parent 7d8a6abb74
commit 6680b25d32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 52 additions and 36 deletions

View File

@ -324,9 +324,8 @@ error:
goBack: Go back goBack: Go back
workflowDetails: workflowDetails:
detailedLog: Click on Info to see details of your workflow workflowNotStarted: Please check the configuration, the workflow was not able to start
fetchError: An error has occurred while fetching the data fetchError: An error has occurred while fetching the data
overallRR: 'Overall RR: '
###################################### ######################################
############ Views ############# ############ Views #############
@ -602,6 +601,7 @@ workflowDetailsView:
workflowInfo: workflowInfo:
header: Overall Workflow Description header: Overall Workflow Description
resilienceScore: Resilience Score resilienceScore: Resilience Score
Completed: Completed
runTime: runTime:
runTimeHeader: Run Time runTimeHeader: Run Time
startTime: 'Start Time :' startTime: 'Start Time :'

View File

@ -36,7 +36,6 @@ import {
} from '../../models/graphql/scheduleData'; } from '../../models/graphql/scheduleData';
import * as NodeSelectionActions from '../../redux/actions/nodeSelection'; import * as NodeSelectionActions from '../../redux/actions/nodeSelection';
import useStyles from './styles'; import useStyles from './styles';
import { FAILED } from '../../views/WorkflowDetails/workflowConstants';
const WorkflowDetails: React.FC = () => { const WorkflowDetails: React.FC = () => {
const theme = useTheme(); const theme = useTheme();
@ -78,13 +77,13 @@ const WorkflowDetails: React.FC = () => {
)[0]; )[0];
// Apollo query to get the scheduled data // Apollo query to get the scheduled data
const { data: SchedulesData } = useQuery<Schedules, ScheduleDataVars>( const { data: SchedulesData, loading } = useQuery<
SCHEDULE_DETAILS, Schedules,
{ ScheduleDataVars
variables: { projectID }, >(SCHEDULE_DETAILS, {
fetchPolicy: 'cache-and-network', variables: { projectID },
} fetchPolicy: 'cache-and-network',
); });
// Using subscription to get realtime data // Using subscription to get realtime data
useEffect(() => { useEffect(() => {
@ -147,8 +146,7 @@ const WorkflowDetails: React.FC = () => {
useEffect(() => { useEffect(() => {
if (workflow && pod_name === '') { if (workflow && pod_name === '') {
if ( if (
(JSON.parse(workflow.execution_data as string) as ExecutionData) Object.keys(JSON.parse(workflow.execution_data as string).nodes).length
.phase !== FAILED
) { ) {
const firstNodeId = JSON.parse(workflow.execution_data as string).nodes[ const firstNodeId = JSON.parse(workflow.execution_data as string).nodes[
Object.keys(JSON.parse(workflow.execution_data as string).nodes)[0] Object.keys(JSON.parse(workflow.execution_data as string).nodes)[0]
@ -170,7 +168,7 @@ const WorkflowDetails: React.FC = () => {
<BackButton /> <BackButton />
</div> </div>
{/* If workflow data is present then display the workflow details */} {/* If workflow data is present then display the workflow details */}
{workflow && pod_name !== '' ? ( {workflow && pod_name !== '' && !loading ? (
<div> <div>
<Typography data-cy="wfName" className={classes.title}> <Typography data-cy="wfName" className={classes.title}>
{t('workflowDetailsView.headerDesc')} {workflow.workflow_name} {t('workflowDetailsView.headerDesc')} {workflow.workflow_name}
@ -268,8 +266,10 @@ const WorkflowDetails: React.FC = () => {
/> />
</TabPanel> </TabPanel>
</div> </div>
) : error || isWorkflowFailed ? ( ) : error ? (
<Typography>{t('workflowDetails.fetchError')}</Typography> <Typography>{t('workflowDetails.fetchError')}</Typography>
) : isWorkflowFailed ? (
<Typography>{t('workflowDetails.workflowNotStarted')}</Typography>
) : ( ) : (
<Loader /> <Loader />
)} )}

View File

@ -1,5 +1,7 @@
import { Typography } from '@material-ui/core'; import { Typography } from '@material-ui/core';
import React, { useEffect } from 'react'; import React, { useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { SUCCEEDED } from '../../WorkflowDetails/workflowConstants';
import useStyles from './styles'; import useStyles from './styles';
interface StatusProps { interface StatusProps {
@ -8,6 +10,7 @@ interface StatusProps {
const CustomStatus: React.FC<StatusProps> = ({ status }) => { const CustomStatus: React.FC<StatusProps> = ({ status }) => {
const classes = useStyles(); const classes = useStyles();
const { t } = useTranslation();
const [label, setLabel] = React.useState(' '); const [label, setLabel] = React.useState(' ');
useEffect(() => { useEffect(() => {
if (status === 'Succeeded') { if (status === 'Succeeded') {
@ -22,7 +25,11 @@ const CustomStatus: React.FC<StatusProps> = ({ status }) => {
return ( return (
<> <>
<div className={label}> <div className={label}>
<Typography className={classes.statusFont}>{status}</Typography> <Typography className={classes.statusFont}>
{status === SUCCEEDED
? `${t('workflowDetailsView.workflowInfo.Completed')}`
: status}
</Typography>
</div> </div>
</> </>
); );

View File

@ -1,5 +1,7 @@
import { Typography } from '@material-ui/core'; import { Typography } from '@material-ui/core';
import React from 'react'; import React from 'react';
import { useTranslation } from 'react-i18next';
import { RUNNING, SUCCEEDED, PENDING, FAILED } from '../workflowConstants';
import useStyles from './styles'; import useStyles from './styles';
interface WorkflowStatusProps { interface WorkflowStatusProps {
@ -9,18 +11,19 @@ interface WorkflowStatusProps {
const WorkflowStatus: React.FC<WorkflowStatusProps> = ({ phase }) => { const WorkflowStatus: React.FC<WorkflowStatusProps> = ({ phase }) => {
const classes = useStyles(); const classes = useStyles();
const { t } = useTranslation();
function getStatus(phase: string) { function getStatus(phase: string) {
switch (phase) { switch (phase) {
case 'Succeeded': case SUCCEEDED:
return classes.succeeded; return `${classes.textBold} ${classes.succeeded}`;
case 'Running': case RUNNING:
return classes.running; return `${classes.textBold} ${classes.running}`;
case 'Failed': case FAILED:
return classes.failed; return `${classes.textBold} ${classes.failed}`;
case 'Pending': case PENDING:
return classes.pending; return `${classes.textBold} ${classes.pending}`;
default: default:
return classes.pending; return `${classes.textBold} ${classes.pending}`;
} }
} }
@ -28,16 +31,16 @@ const WorkflowStatus: React.FC<WorkflowStatusProps> = ({ phase }) => {
<div className={classes.status}> <div className={classes.status}>
<span className={classes.icon}> <span className={classes.icon}>
<img <img
className={ className={phase === RUNNING ? classes.runningSmallIcon : ''}
phase.toLowerCase() === 'running' ? classes.runningSmallIcon : ''
}
src={`/icons/${phase.toLowerCase()}.svg`} src={`/icons/${phase.toLowerCase()}.svg`}
alt="status" alt="status"
/> />
</span> </span>
<Typography> <Typography>
<span className={getStatus(phase)}> <span className={getStatus(phase)}>
<strong>{phase}</strong> {phase === SUCCEEDED
? `${t('workflowDetailsView.workflowInfo.Completed')}`
: phase}
</span> </span>
</Typography> </Typography>
</div> </div>

View File

@ -18,6 +18,10 @@ const useStyles = makeStyles((theme) => ({
color: theme.palette.text.primary, color: theme.palette.text.primary,
}, },
textBold: {
fontWeight: 'bold',
},
status: { status: {
display: 'flex', display: 'flex',
flexDirection: 'row', flexDirection: 'row',

View File

@ -120,7 +120,9 @@ const TableData: React.FC<TableDataProps> = ({
key={index.toString()} key={index.toString()}
className={classes.popoverItems} className={classes.popoverItems}
> >
{key} : {YAML.parse(embeddedYAML).spec.appinfo[key]} <span className={classes.boldText}>{key} :</span>
&nbsp;
{YAML.parse(embeddedYAML).spec.appinfo[key]}
</Typography> </Typography>
); );
} }

View File

@ -79,16 +79,16 @@ const useStyles = makeStyles((theme) => ({
}, },
popover: { popover: {
display: 'flex', padding: theme.spacing(2),
flexDirection: 'column',
height: '5rem',
padding: theme.spacing(0, 1, 0, 1),
}, },
popoverItems: { popoverItems: {
textAlign: 'left', textAlign: 'left',
marginTop: 'auto', margin: theme.spacing(1, 'auto'),
marginBottom: 'auto', },
boldText: {
fontWeight: 'bold',
}, },
})); }));

View File

@ -1,4 +1,4 @@
export const FAILED: string = 'Failed'; export const FAILED: string = 'Failed';
export const RUNNING: string = 'Running'; export const RUNNING: string = 'Running';
export const PENDING: string = 'Pending'; export const PENDING: string = 'Pending';
export const SUCCEEDED: string = 'Succeded'; export const SUCCEEDED: string = 'Succeeded';