Skip to content

Commit

Permalink
Added fixes for handling edge cases in Workflow Visualisation Screen (#…
Browse files Browse the repository at this point in the history
…2660)

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

Signed-off-by: Jonsy13 <[email protected]>
  • Loading branch information
Jonsy13 authored Apr 8, 2021
1 parent 7d8a6ab commit 6680b25
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 36 deletions.
4 changes: 2 additions & 2 deletions litmus-portal/frontend/public/locales/en/translation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,8 @@ error:
goBack: Go back

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
overallRR: 'Overall RR: '

######################################
############ Views #############
Expand Down Expand Up @@ -602,6 +601,7 @@ workflowDetailsView:
workflowInfo:
header: Overall Workflow Description
resilienceScore: Resilience Score
Completed: Completed
runTime:
runTimeHeader: Run Time
startTime: 'Start Time :'
Expand Down
24 changes: 12 additions & 12 deletions litmus-portal/frontend/src/pages/WorkflowDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import {
} from '../../models/graphql/scheduleData';
import * as NodeSelectionActions from '../../redux/actions/nodeSelection';
import useStyles from './styles';
import { FAILED } from '../../views/WorkflowDetails/workflowConstants';

const WorkflowDetails: React.FC = () => {
const theme = useTheme();
Expand Down Expand Up @@ -78,13 +77,13 @@ const WorkflowDetails: React.FC = () => {
)[0];

// Apollo query to get the scheduled data
const { data: SchedulesData } = useQuery<Schedules, ScheduleDataVars>(
SCHEDULE_DETAILS,
{
variables: { projectID },
fetchPolicy: 'cache-and-network',
}
);
const { data: SchedulesData, loading } = useQuery<
Schedules,
ScheduleDataVars
>(SCHEDULE_DETAILS, {
variables: { projectID },
fetchPolicy: 'cache-and-network',
});

// Using subscription to get realtime data
useEffect(() => {
Expand Down Expand Up @@ -147,8 +146,7 @@ const WorkflowDetails: React.FC = () => {
useEffect(() => {
if (workflow && pod_name === '') {
if (
(JSON.parse(workflow.execution_data as string) as ExecutionData)
.phase !== FAILED
Object.keys(JSON.parse(workflow.execution_data as string).nodes).length
) {
const firstNodeId = JSON.parse(workflow.execution_data as string).nodes[
Object.keys(JSON.parse(workflow.execution_data as string).nodes)[0]
Expand All @@ -170,7 +168,7 @@ const WorkflowDetails: React.FC = () => {
<BackButton />
</div>
{/* If workflow data is present then display the workflow details */}
{workflow && pod_name !== '' ? (
{workflow && pod_name !== '' && !loading ? (
<div>
<Typography data-cy="wfName" className={classes.title}>
{t('workflowDetailsView.headerDesc')} {workflow.workflow_name}
Expand Down Expand Up @@ -268,8 +266,10 @@ const WorkflowDetails: React.FC = () => {
/>
</TabPanel>
</div>
) : error || isWorkflowFailed ? (
) : error ? (
<Typography>{t('workflowDetails.fetchError')}</Typography>
) : isWorkflowFailed ? (
<Typography>{t('workflowDetails.workflowNotStarted')}</Typography>
) : (
<Loader />
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Typography } from '@material-ui/core';
import React, { useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { SUCCEEDED } from '../../WorkflowDetails/workflowConstants';
import useStyles from './styles';

interface StatusProps {
Expand All @@ -8,6 +10,7 @@ interface StatusProps {

const CustomStatus: React.FC<StatusProps> = ({ status }) => {
const classes = useStyles();
const { t } = useTranslation();
const [label, setLabel] = React.useState(' ');
useEffect(() => {
if (status === 'Succeeded') {
Expand All @@ -22,7 +25,11 @@ const CustomStatus: React.FC<StatusProps> = ({ status }) => {
return (
<>
<div className={label}>
<Typography className={classes.statusFont}>{status}</Typography>
<Typography className={classes.statusFont}>
{status === SUCCEEDED
? `${t('workflowDetailsView.workflowInfo.Completed')}`
: status}
</Typography>
</div>
</>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Typography } from '@material-ui/core';
import React from 'react';
import { useTranslation } from 'react-i18next';
import { RUNNING, SUCCEEDED, PENDING, FAILED } from '../workflowConstants';
import useStyles from './styles';

interface WorkflowStatusProps {
Expand All @@ -9,35 +11,36 @@ interface WorkflowStatusProps {
const WorkflowStatus: React.FC<WorkflowStatusProps> = ({ phase }) => {
const classes = useStyles();

const { t } = useTranslation();
function getStatus(phase: string) {
switch (phase) {
case 'Succeeded':
return classes.succeeded;
case 'Running':
return classes.running;
case 'Failed':
return classes.failed;
case 'Pending':
return classes.pending;
case SUCCEEDED:
return `${classes.textBold} ${classes.succeeded}`;
case RUNNING:
return `${classes.textBold} ${classes.running}`;
case FAILED:
return `${classes.textBold} ${classes.failed}`;
case PENDING:
return `${classes.textBold} ${classes.pending}`;
default:
return classes.pending;
return `${classes.textBold} ${classes.pending}`;
}
}

return (
<div className={classes.status}>
<span className={classes.icon}>
<img
className={
phase.toLowerCase() === 'running' ? classes.runningSmallIcon : ''
}
className={phase === RUNNING ? classes.runningSmallIcon : ''}
src={`/icons/${phase.toLowerCase()}.svg`}
alt="status"
/>
</span>
<Typography>
<span className={getStatus(phase)}>
<strong>{phase}</strong>
{phase === SUCCEEDED
? `${t('workflowDetailsView.workflowInfo.Completed')}`
: phase}
</span>
</Typography>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ const useStyles = makeStyles((theme) => ({
color: theme.palette.text.primary,
},

textBold: {
fontWeight: 'bold',
},

status: {
display: 'flex',
flexDirection: 'row',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ const TableData: React.FC<TableDataProps> = ({
key={index.toString()}
className={classes.popoverItems}
>
{key} : {YAML.parse(embeddedYAML).spec.appinfo[key]}
<span className={classes.boldText}>{key} :</span>
&nbsp;
{YAML.parse(embeddedYAML).spec.appinfo[key]}
</Typography>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,16 @@ const useStyles = makeStyles((theme) => ({
},

popover: {
display: 'flex',
flexDirection: 'column',
height: '5rem',
padding: theme.spacing(0, 1, 0, 1),
padding: theme.spacing(2),
},

popoverItems: {
textAlign: 'left',
marginTop: 'auto',
marginBottom: 'auto',
margin: theme.spacing(1, 'auto'),
},

boldText: {
fontWeight: 'bold',
},
}));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const FAILED: string = 'Failed';
export const RUNNING: string = 'Running';
export const PENDING: string = 'Pending';
export const SUCCEEDED: string = 'Succeded';
export const SUCCEEDED: string = 'Succeeded';

0 comments on commit 6680b25

Please sign in to comment.