chore(litmus-portal): Updated the Linear ProgressBar component and some minor bug fixes (#2595)

* Updated the Linear Progressbar component and minor change
* Minor bug fixes and updated RR score for running phase
* Minor translation fix
* Updated image during custom chaos generation
Signed-off-by: Amit Kumar Das <amitkumar.das@mayadata.io>
This commit is contained in:
Amit Kumar Das 2021-03-25 13:09:54 +05:30 committed by GitHub
parent 17799da808
commit 2e2b309813
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 91 additions and 60 deletions

View File

@ -278,6 +278,7 @@ error:
workflowDetails: workflowDetails:
detailedLog: Click on Info to see details of your workflow detailedLog: Click on Info to see details of your workflow
fetchError: An error has occurred while fetching the data fetchError: An error has occurred while fetching the data
overallRR: 'Overall RR: '
###################################### ######################################
############ Views ############# ############ Views #############

View File

@ -65,8 +65,8 @@ const AdjustedWeights: React.FC<AdjustedWeightsProps> = ({
)} )}
</div> </div>
<div> <div className={classes.progressbarDiv}>
<LinearProgressBar width={1} value={testValue} /> <LinearProgressBar width={0.2} value={testValue} />
</div> </div>
</div> </div>
); );

View File

@ -24,6 +24,9 @@ const useStyles = makeStyles((theme: Theme) => ({
display: 'flex', display: 'flex',
justifyContent: 'space-between', justifyContent: 'space-between',
}, },
progressbarDiv: {
marginRight: theme.spacing(1.25),
},
})); }));
export default useStyles; export default useStyles;

View File

@ -21,24 +21,25 @@ const AnalyticsLinearProgressBar: React.FC<LinearProgressBarProps> = ({
<LinearProgress <LinearProgress
variant="determinate" variant="determinate"
value={resultValue} value={resultValue}
classes={ style={{
isInTable height: '0.2rem',
}}
classes={{
colorPrimary: isInTable
? resultValue > 60 ? resultValue > 60
? { ? classes.greenColorSecondary
root: classes.root,
barColorPrimary: classes.greenColorPrimary,
}
: resultValue > 30 : resultValue > 30
? { ? classes.yellowColorSecondary
root: classes.root, : classes.redColorSecondary
barColorPrimary: classes.yellowColorPrimary, : classes.greenColorSecondary,
} barColorPrimary: isInTable
: { ? resultValue > 60
root: classes.root, ? classes.greenColorPrimary
barColorPrimary: classes.redColorPrimary, : resultValue > 30
} ? classes.yellowColorPrimary
: {} : classes.redColorPrimary
} : classes.greenColorSecondary,
}}
/> />
); );
}; };

View File

@ -3,17 +3,25 @@ import { makeStyles, Theme } from '@material-ui/core/styles';
const useStyle = makeStyles((theme: Theme) => ({ const useStyle = makeStyles((theme: Theme) => ({
root: { root: {
borderRadius: '5rem', borderRadius: '5rem',
height: '1rem',
}, },
redColorPrimary: { redColorPrimary: {
backgroundColor: theme.palette.error.main, backgroundColor: theme.palette.error.main,
}, },
redColorSecondary: {
backgroundColor: theme.palette.error.light,
},
greenColorPrimary: { greenColorPrimary: {
backgroundColor: theme.palette.success.main, backgroundColor: theme.palette.success.main,
}, },
greenColorSecondary: {
backgroundColor: theme.palette.success.light,
},
yellowColorPrimary: { yellowColorPrimary: {
backgroundColor: theme.palette.warning.main, backgroundColor: theme.palette.warning.main,
}, },
yellowColorSecondary: {
backgroundColor: theme.palette.warning.light,
},
})); }));
export default useStyle; export default useStyle;

View File

@ -21,25 +21,26 @@ const LinearProgressBar: React.FC<LinearProgressBarProps> = ({
<LinearProgress <LinearProgress
variant="determinate" variant="determinate"
value={resultValue} value={resultValue}
classes={ style={{
isDefault height: `${width}rem`,
? resultValue > 60 borderRadius: '5rem',
? { }}
root: classes.root, classes={{
barColorPrimary: classes.greenColorPrimary, colorPrimary: isDefault
} ? classes.greenColorSecondary
: resultValue > 60
? classes.greenColorSecondary
: resultValue > 30 : resultValue > 30
? { ? classes.yellowColorSecondary
root: classes.root, : classes.redColorSecondary,
barColorPrimary: classes.yellowColorPrimary, barColorPrimary: isDefault
} ? classes.greenColorPrimary
: { : resultValue > 60
root: classes.root, ? classes.greenColorPrimary
barColorPrimary: classes.redColorPrimary, : resultValue > 30
} ? classes.yellowColorPrimary
: {} : classes.redColorPrimary,
} }}
style={{ height: `${width}rem`, borderRadius: '5rem' }}
/> />
); );
}; };

View File

@ -3,17 +3,25 @@ import { makeStyles, Theme } from '@material-ui/core/styles';
const useStyle = makeStyles((theme: Theme) => ({ const useStyle = makeStyles((theme: Theme) => ({
root: { root: {
borderRadius: '5rem', borderRadius: '5rem',
height: '1rem',
}, },
redColorPrimary: { redColorPrimary: {
backgroundColor: theme.palette.error.main, backgroundColor: theme.palette.error.main,
}, },
redColorSecondary: {
backgroundColor: theme.palette.error.light,
},
greenColorPrimary: { greenColorPrimary: {
backgroundColor: theme.palette.success.main, backgroundColor: theme.palette.success.main,
}, },
greenColorSecondary: {
backgroundColor: theme.palette.success.light,
},
yellowColorPrimary: { yellowColorPrimary: {
backgroundColor: theme.palette.warning.main, backgroundColor: theme.palette.warning.main,
}, },
yellowColorSecondary: {
backgroundColor: theme.palette.warning.light,
},
})); }));
export default useStyle; export default useStyle;

View File

@ -145,9 +145,6 @@ const MyHub: React.FC = () => {
<Typography variant="h3" gutterBottom> <Typography variant="h3" gutterBottom>
{t('myhub.mainPage.header')} {t('myhub.mainPage.header')}
</Typography> </Typography>
<Typography variant="h4">
<strong>{t('myhub.mainPage.github')}</strong>
</Typography>
</div> </div>
{/* Charts Div */} {/* Charts Div */}
<div className={classes.mainDiv}> <div className={classes.mainDiv}>

View File

@ -31,7 +31,7 @@ const WorkflowDetails: React.FC = () => {
const tabs = useActions(TabActions); const tabs = useActions(TabActions);
const { pathname } = useLocation(); const { pathname } = useLocation();
// Getting the workflow nome from the pathname // Getting the workflow nome from the pathname
const workflowRunId = pathname.split('/')[3]; const workflowRunId = pathname.split('/')[2];
const { t } = useTranslation(); const { t } = useTranslation();
// get ProjectID // get ProjectID

View File

@ -66,7 +66,7 @@ const TableData: React.FC<TableDataProps> = ({ data }) => {
<div className={classes.reliabiltyData}> <div className={classes.reliabiltyData}>
<Typography>{data.resulting_points} Points</Typography> <Typography>{data.resulting_points} Points</Typography>
<div className={classes.progressBar}> <div className={classes.progressBar}>
<LinearProgressBar width={2} value={data.resulting_points ?? 0} /> <LinearProgressBar width={0.2} value={data.resulting_points ?? 0} />
</div> </div>
</div> </div>
</StyledTableCell> </StyledTableCell>

View File

@ -21,7 +21,7 @@ const ExperimentPoints: React.FC<ExperimentPointsProps> = ({
{weight === 1 || 0 ? `${weight} point` : `${weight} points`} {weight === 1 || 0 ? `${weight} point` : `${weight} points`}
</Typography> </Typography>
</div> </div>
<LinearProgressBar width={1} value={weight} /> <LinearProgressBar width={0.2} value={weight} />
</> </>
); );
}; };

View File

@ -27,7 +27,6 @@ import * as TabActions from '../../../redux/actions/tabs';
import * as WorkflowActions from '../../../redux/actions/workflow'; import * as WorkflowActions from '../../../redux/actions/workflow';
import { history } from '../../../redux/configureStore'; import { history } from '../../../redux/configureStore';
import { ReactComponent as CrossMarkIcon } from '../../../svg/crossmark.svg'; import { ReactComponent as CrossMarkIcon } from '../../../svg/crossmark.svg';
import { getUserRole } from '../../../utils/auth';
import { getProjectID, getProjectRole } from '../../../utils/getSearchParams'; import { getProjectID, getProjectRole } from '../../../utils/getSearchParams';
import ExperimentPoints from './ExperimentPoints'; import ExperimentPoints from './ExperimentPoints';
import useStyles from './styles'; import useStyles from './styles';
@ -41,7 +40,6 @@ const TableData: React.FC<TableDataProps> = ({ data, deleteRow }) => {
const classes = useStyles(); const classes = useStyles();
const { t } = useTranslation(); const { t } = useTranslation();
const userRole = getUserRole();
const projectID = getProjectID(); const projectID = getProjectID();
const projectRole = getProjectRole(); const projectRole = getProjectRole();
@ -238,7 +236,7 @@ const TableData: React.FC<TableDataProps> = ({ data, deleteRow }) => {
<div className={classes.weightDiv}> <div className={classes.weightDiv}>
{data.weightages.map((expData) => { {data.weightages.map((expData) => {
return ( return (
<div style={{ marginBottom: 8 }}> <div style={{ marginBottom: 20 }}>
<ExperimentPoints <ExperimentPoints
expName={expData.experiment_name} expName={expData.experiment_name}
weight={expData.weightage} weight={expData.weightage}
@ -284,7 +282,7 @@ const TableData: React.FC<TableDataProps> = ({ data, deleteRow }) => {
) : ( ) : (
<></> <></>
)} )}
{data.cronSyntax === '' ? ( {projectRole !== 'Viewer' && data.cronSyntax === '' ? (
<MenuItem value="Rerun_Schedule" onClick={() => reRunSchedule()}> <MenuItem value="Rerun_Schedule" onClick={() => reRunSchedule()}>
<div className={classes.expDiv}> <div className={classes.expDiv}>
<ReplayIcon className={classes.rerunBtn} /> <ReplayIcon className={classes.rerunBtn} />
@ -312,7 +310,7 @@ const TableData: React.FC<TableDataProps> = ({ data, deleteRow }) => {
</Typography> </Typography>
</div> </div>
</MenuItem> </MenuItem>
{userRole !== 'Viewer' ? ( {projectRole !== 'Viewer' ? (
<MenuItem value="Analysis" onClick={() => setIsModalOpen(true)}> <MenuItem value="Analysis" onClick={() => setIsModalOpen(true)}>
<div className={classes.expDiv}> <div className={classes.expDiv}>
<img <img

View File

@ -177,7 +177,7 @@ const useStyles = makeStyles((theme) => ({
weightInfo: { weightInfo: {
display: 'flex', display: 'flex',
flexDirection: 'row', flexDirection: 'row',
paddingBottom: theme.spacing(0.625), paddingBottom: theme.spacing(1),
}, },
points: { points: {
marginLeft: 'auto', marginLeft: 'auto',

View File

@ -7,6 +7,7 @@ import {
} from '@material-ui/core'; } from '@material-ui/core';
import MoreVertIcon from '@material-ui/icons/MoreVert'; import MoreVertIcon from '@material-ui/icons/MoreVert';
import React from 'react'; import React from 'react';
import { useTranslation } from 'react-i18next';
import LinearProgressBar from '../../../components/ProgressBar/LinearProgressBar'; import LinearProgressBar from '../../../components/ProgressBar/LinearProgressBar';
import { import {
ExecutionData, ExecutionData,
@ -28,6 +29,8 @@ const TableData: React.FC<TableDataProps> = ({ data, exeData }) => {
const projectID = getProjectID(); const projectID = getProjectID();
const projectRole = getProjectRole(); const projectRole = getProjectRole();
const { t } = useTranslation();
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null); const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
const open = Boolean(anchorEl); const open = Boolean(anchorEl);
@ -74,22 +77,29 @@ const TableData: React.FC<TableDataProps> = ({ data, exeData }) => {
</TableCell> </TableCell>
<TableCell> <TableCell>
<div className={classes.reliabiltyData}> <div className={classes.reliabiltyData}>
{exeData.phase === 'Failed' || exeData.phase === '' ? ( {exeData.finishedAt.length === 0 ? (
<Typography>
{t('workflowDetails.overallRR')}
<span className={classes.failed}>NA</span>
</Typography>
) : exeData.phase === 'Failed' || exeData.phase === '' ? (
<> <>
<Typography> <Typography>
Overall RR: <span className={classes.failed}>0%</span> {t('workflowDetails.overallRR')}
<span className={classes.failed}>0%</span>
</Typography> </Typography>
<div className={classes.progressBar}> <div className={classes.progressBar}>
<LinearProgressBar width={2} value={0} /> <LinearProgressBar width={0.1} value={0} />
</div> </div>
</> </>
) : ( ) : (
<> <>
<Typography> <Typography>
Overall RR: <span className={classes.success}>100%</span> {t('workflowDetails.overallRR')}
<span className={classes.success}>100%</span>
</Typography> </Typography>
<div className={classes.progressBar}> <div className={classes.progressBar}>
<LinearProgressBar width={2} value={100} /> <LinearProgressBar width={0.1} value={10} />
</div> </div>
</> </>
)} )}

View File

@ -101,6 +101,7 @@ const useStyles = makeStyles((theme) => ({
}, },
progressBar: { progressBar: {
width: '6.5rem', width: '6.5rem',
marginTop: theme.spacing(2),
}, },
steps: { steps: {
marginLeft: theme.spacing(5.625), marginLeft: theme.spacing(5.625),
@ -135,6 +136,9 @@ const useStyles = makeStyles((theme) => ({
success: { success: {
color: theme.palette.success.main, color: theme.palette.success.main,
}, },
warning: {
color: theme.palette.warning.main,
},
// Menu option with icon // Menu option with icon
expDiv: { expDiv: {
display: 'flex', display: 'flex',

View File

@ -189,7 +189,7 @@ const ScheduleCustomWorkflow: React.FC<VerifyCommitProps> = ({ gotoStep }) => {
container: { container: {
args: [`${installAllExp}sleep 30`], args: [`${installAllExp}sleep 30`],
command: ['sh', '-c'], command: ['sh', '-c'],
image: 'alpine/k8s:1.18.2', image: 'litmuschaos/k8s:latest',
}, },
}; };
workflows.forEach((data) => { workflows.forEach((data) => {
@ -242,7 +242,7 @@ const ScheduleCustomWorkflow: React.FC<VerifyCommitProps> = ({ gotoStep }) => {
`kubectl delete chaosengine ${removeChaosEngine} -n {{workflow.parameters.adminModeNamespace}}`, `kubectl delete chaosengine ${removeChaosEngine} -n {{workflow.parameters.adminModeNamespace}}`,
], ],
command: ['sh', '-c'], command: ['sh', '-c'],
image: 'alpine/k8s:1.18.2', image: 'litmuschaos/k8s:latest',
}, },
}; };
} }

View File

@ -116,7 +116,7 @@ const ResultTable: React.FC<ResultModalProps> = ({ testValue, testNames }) => {
{t('createWorkflow.reliabilityScore.resultTable.points')} {t('createWorkflow.reliabilityScore.resultTable.points')}
<br /> <br />
<div className={classes.progressBar}> <div className={classes.progressBar}>
<LinearProgressBar width={2} value={row.weight} /> <LinearProgressBar width={0.2} value={row.weight} />
</div> </div>
</TableCell> </TableCell>
<TableCell align="left" className={classes.tablePoints}> <TableCell align="left" className={classes.tablePoints}>
@ -125,7 +125,7 @@ const ResultTable: React.FC<ResultModalProps> = ({ testValue, testNames }) => {
{t('createWorkflow.reliabilityScore.resultTable.points')} {t('createWorkflow.reliabilityScore.resultTable.points')}
<br /> <br />
<div className={classes.progressBar}> <div className={classes.progressBar}>
<LinearProgressBar width={2} value={row.points} /> <LinearProgressBar width={0.2} value={row.points} />
</div> </div>
</TableCell> </TableCell>
</TableRow> </TableRow>