From 6680b25d326479e506860736404027881633afdb Mon Sep 17 00:00:00 2001 From: VEDANT SHROTRIA <40681425+Jonsy13@users.noreply.github.com> Date: Thu, 8 Apr 2021 16:41:01 +0530 Subject: [PATCH] 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 --- .../public/locales/en/translation.yaml | 4 +-- .../src/pages/WorkflowDetails/index.tsx | 24 +++++++-------- .../ChaosWorkflows/CustomStatus/Status.tsx | 9 +++++- .../WorkflowDetails/WorkflowStatus/index.tsx | 29 ++++++++++--------- .../WorkflowDetails/WorkflowStatus/styles.ts | 4 +++ .../WorkflowTable/TableData.tsx | 4 ++- .../WorkflowDetails/WorkflowTable/styles.ts | 12 ++++---- .../WorkflowDetails/workflowConstants.ts | 2 +- 8 files changed, 52 insertions(+), 36 deletions(-) diff --git a/litmus-portal/frontend/public/locales/en/translation.yaml b/litmus-portal/frontend/public/locales/en/translation.yaml index 823af6c848a..fd5a67cb47f 100644 --- a/litmus-portal/frontend/public/locales/en/translation.yaml +++ b/litmus-portal/frontend/public/locales/en/translation.yaml @@ -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 ############# @@ -602,6 +601,7 @@ workflowDetailsView: workflowInfo: header: Overall Workflow Description resilienceScore: Resilience Score + Completed: Completed runTime: runTimeHeader: Run Time startTime: 'Start Time :' diff --git a/litmus-portal/frontend/src/pages/WorkflowDetails/index.tsx b/litmus-portal/frontend/src/pages/WorkflowDetails/index.tsx index 998b433c072..5b330d6d70c 100644 --- a/litmus-portal/frontend/src/pages/WorkflowDetails/index.tsx +++ b/litmus-portal/frontend/src/pages/WorkflowDetails/index.tsx @@ -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(); @@ -78,13 +77,13 @@ const WorkflowDetails: React.FC = () => { )[0]; // Apollo query to get the scheduled data - const { data: SchedulesData } = useQuery( - 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(() => { @@ -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] @@ -170,7 +168,7 @@ const WorkflowDetails: React.FC = () => { {/* If workflow data is present then display the workflow details */} - {workflow && pod_name !== '' ? ( + {workflow && pod_name !== '' && !loading ? (
{t('workflowDetailsView.headerDesc')} {workflow.workflow_name} @@ -268,8 +266,10 @@ const WorkflowDetails: React.FC = () => { />
- ) : error || isWorkflowFailed ? ( + ) : error ? ( {t('workflowDetails.fetchError')} + ) : isWorkflowFailed ? ( + {t('workflowDetails.workflowNotStarted')} ) : ( )} diff --git a/litmus-portal/frontend/src/views/ChaosWorkflows/CustomStatus/Status.tsx b/litmus-portal/frontend/src/views/ChaosWorkflows/CustomStatus/Status.tsx index a8e128d1f44..959855e9adf 100644 --- a/litmus-portal/frontend/src/views/ChaosWorkflows/CustomStatus/Status.tsx +++ b/litmus-portal/frontend/src/views/ChaosWorkflows/CustomStatus/Status.tsx @@ -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 { @@ -8,6 +10,7 @@ interface StatusProps { const CustomStatus: React.FC = ({ status }) => { const classes = useStyles(); + const { t } = useTranslation(); const [label, setLabel] = React.useState(' '); useEffect(() => { if (status === 'Succeeded') { @@ -22,7 +25,11 @@ const CustomStatus: React.FC = ({ status }) => { return ( <>
- {status} + + {status === SUCCEEDED + ? `${t('workflowDetailsView.workflowInfo.Completed')}` + : status} +
); diff --git a/litmus-portal/frontend/src/views/WorkflowDetails/WorkflowStatus/index.tsx b/litmus-portal/frontend/src/views/WorkflowDetails/WorkflowStatus/index.tsx index 916b62e8c10..e973f2965b8 100644 --- a/litmus-portal/frontend/src/views/WorkflowDetails/WorkflowStatus/index.tsx +++ b/litmus-portal/frontend/src/views/WorkflowDetails/WorkflowStatus/index.tsx @@ -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 { @@ -9,18 +11,19 @@ interface WorkflowStatusProps { const WorkflowStatus: React.FC = ({ 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}`; } } @@ -28,16 +31,16 @@ const WorkflowStatus: React.FC = ({ phase }) => {
status - {phase} + {phase === SUCCEEDED + ? `${t('workflowDetailsView.workflowInfo.Completed')}` + : phase}
diff --git a/litmus-portal/frontend/src/views/WorkflowDetails/WorkflowStatus/styles.ts b/litmus-portal/frontend/src/views/WorkflowDetails/WorkflowStatus/styles.ts index 9a26ad7d355..eeb31ab98dd 100644 --- a/litmus-portal/frontend/src/views/WorkflowDetails/WorkflowStatus/styles.ts +++ b/litmus-portal/frontend/src/views/WorkflowDetails/WorkflowStatus/styles.ts @@ -18,6 +18,10 @@ const useStyles = makeStyles((theme) => ({ color: theme.palette.text.primary, }, + textBold: { + fontWeight: 'bold', + }, + status: { display: 'flex', flexDirection: 'row', diff --git a/litmus-portal/frontend/src/views/WorkflowDetails/WorkflowTable/TableData.tsx b/litmus-portal/frontend/src/views/WorkflowDetails/WorkflowTable/TableData.tsx index 8410f8df65e..5a75a6666b2 100644 --- a/litmus-portal/frontend/src/views/WorkflowDetails/WorkflowTable/TableData.tsx +++ b/litmus-portal/frontend/src/views/WorkflowDetails/WorkflowTable/TableData.tsx @@ -120,7 +120,9 @@ const TableData: React.FC = ({ key={index.toString()} className={classes.popoverItems} > - {key} : {YAML.parse(embeddedYAML).spec.appinfo[key]} + {key} : +   + {YAML.parse(embeddedYAML).spec.appinfo[key]} ); } diff --git a/litmus-portal/frontend/src/views/WorkflowDetails/WorkflowTable/styles.ts b/litmus-portal/frontend/src/views/WorkflowDetails/WorkflowTable/styles.ts index b2c52f87f04..a4718405a77 100644 --- a/litmus-portal/frontend/src/views/WorkflowDetails/WorkflowTable/styles.ts +++ b/litmus-portal/frontend/src/views/WorkflowDetails/WorkflowTable/styles.ts @@ -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', }, })); diff --git a/litmus-portal/frontend/src/views/WorkflowDetails/workflowConstants.ts b/litmus-portal/frontend/src/views/WorkflowDetails/workflowConstants.ts index 574793626a8..9504350667d 100644 --- a/litmus-portal/frontend/src/views/WorkflowDetails/workflowConstants.ts +++ b/litmus-portal/frontend/src/views/WorkflowDetails/workflowConstants.ts @@ -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';