Skip to content

Commit

Permalink
chore(litmus-portal): Updated the Linear ProgressBar component and so…
Browse files Browse the repository at this point in the history
…me 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 <[email protected]>
  • Loading branch information
amityt authored Mar 25, 2021
1 parent 17799da commit 2e2b309
Show file tree
Hide file tree
Showing 17 changed files with 91 additions and 60 deletions.
1 change: 1 addition & 0 deletions litmus-portal/frontend/public/locales/en/translation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ error:
workflowDetails:
detailedLog: Click on Info to see details of your workflow
fetchError: An error has occurred while fetching the data
overallRR: 'Overall RR: '

######################################
############ Views #############
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ const AdjustedWeights: React.FC<AdjustedWeightsProps> = ({
)}
</div>

<div>
<LinearProgressBar width={1} value={testValue} />
<div className={classes.progressbarDiv}>
<LinearProgressBar width={0.2} value={testValue} />
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ const useStyles = makeStyles((theme: Theme) => ({
display: 'flex',
justifyContent: 'space-between',
},
progressbarDiv: {
marginRight: theme.spacing(1.25),
},
}));

export default useStyles;
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,25 @@ const AnalyticsLinearProgressBar: React.FC<LinearProgressBarProps> = ({
<LinearProgress
variant="determinate"
value={resultValue}
classes={
isInTable
style={{
height: '0.2rem',
}}
classes={{
colorPrimary: isInTable
? resultValue > 60
? {
root: classes.root,
barColorPrimary: classes.greenColorPrimary,
}
? classes.greenColorSecondary
: resultValue > 30
? {
root: classes.root,
barColorPrimary: classes.yellowColorPrimary,
}
: {
root: classes.root,
barColorPrimary: classes.redColorPrimary,
}
: {}
}
? classes.yellowColorSecondary
: classes.redColorSecondary
: classes.greenColorSecondary,
barColorPrimary: isInTable
? resultValue > 60
? classes.greenColorPrimary
: resultValue > 30
? classes.yellowColorPrimary
: classes.redColorPrimary
: classes.greenColorSecondary,
}}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,25 @@ import { makeStyles, Theme } from '@material-ui/core/styles';
const useStyle = makeStyles((theme: Theme) => ({
root: {
borderRadius: '5rem',
height: '1rem',
},
redColorPrimary: {
backgroundColor: theme.palette.error.main,
},
redColorSecondary: {
backgroundColor: theme.palette.error.light,
},
greenColorPrimary: {
backgroundColor: theme.palette.success.main,
},
greenColorSecondary: {
backgroundColor: theme.palette.success.light,
},
yellowColorPrimary: {
backgroundColor: theme.palette.warning.main,
},
yellowColorSecondary: {
backgroundColor: theme.palette.warning.light,
},
}));

export default useStyle;
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,26 @@ const LinearProgressBar: React.FC<LinearProgressBarProps> = ({
<LinearProgress
variant="determinate"
value={resultValue}
classes={
isDefault
? resultValue > 60
? {
root: classes.root,
barColorPrimary: classes.greenColorPrimary,
}
: resultValue > 30
? {
root: classes.root,
barColorPrimary: classes.yellowColorPrimary,
}
: {
root: classes.root,
barColorPrimary: classes.redColorPrimary,
}
: {}
}
style={{ height: `${width}rem`, borderRadius: '5rem' }}
style={{
height: `${width}rem`,
borderRadius: '5rem',
}}
classes={{
colorPrimary: isDefault
? classes.greenColorSecondary
: resultValue > 60
? classes.greenColorSecondary
: resultValue > 30
? classes.yellowColorSecondary
: classes.redColorSecondary,
barColorPrimary: isDefault
? classes.greenColorPrimary
: resultValue > 60
? classes.greenColorPrimary
: resultValue > 30
? classes.yellowColorPrimary
: classes.redColorPrimary,
}}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,25 @@ import { makeStyles, Theme } from '@material-ui/core/styles';
const useStyle = makeStyles((theme: Theme) => ({
root: {
borderRadius: '5rem',
height: '1rem',
},
redColorPrimary: {
backgroundColor: theme.palette.error.main,
},
redColorSecondary: {
backgroundColor: theme.palette.error.light,
},
greenColorPrimary: {
backgroundColor: theme.palette.success.main,
},
greenColorSecondary: {
backgroundColor: theme.palette.success.light,
},
yellowColorPrimary: {
backgroundColor: theme.palette.warning.main,
},
yellowColorSecondary: {
backgroundColor: theme.palette.warning.light,
},
}));

export default useStyle;
3 changes: 0 additions & 3 deletions litmus-portal/frontend/src/pages/MyHub/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,6 @@ const MyHub: React.FC = () => {
<Typography variant="h3" gutterBottom>
{t('myhub.mainPage.header')}
</Typography>
<Typography variant="h4">
<strong>{t('myhub.mainPage.github')}</strong>
</Typography>
</div>
{/* Charts Div */}
<div className={classes.mainDiv}>
Expand Down
2 changes: 1 addition & 1 deletion litmus-portal/frontend/src/pages/WorkflowDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const WorkflowDetails: React.FC = () => {
const tabs = useActions(TabActions);
const { pathname } = useLocation();
// Getting the workflow nome from the pathname
const workflowRunId = pathname.split('/')[3];
const workflowRunId = pathname.split('/')[2];
const { t } = useTranslation();

// get ProjectID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const TableData: React.FC<TableDataProps> = ({ data }) => {
<div className={classes.reliabiltyData}>
<Typography>{data.resulting_points} Points</Typography>
<div className={classes.progressBar}>
<LinearProgressBar width={2} value={data.resulting_points ?? 0} />
<LinearProgressBar width={0.2} value={data.resulting_points ?? 0} />
</div>
</div>
</StyledTableCell>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const ExperimentPoints: React.FC<ExperimentPointsProps> = ({
{weight === 1 || 0 ? `${weight} point` : `${weight} points`}
</Typography>
</div>
<LinearProgressBar width={1} value={weight} />
<LinearProgressBar width={0.2} value={weight} />
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import * as TabActions from '../../../redux/actions/tabs';
import * as WorkflowActions from '../../../redux/actions/workflow';
import { history } from '../../../redux/configureStore';
import { ReactComponent as CrossMarkIcon } from '../../../svg/crossmark.svg';
import { getUserRole } from '../../../utils/auth';
import { getProjectID, getProjectRole } from '../../../utils/getSearchParams';
import ExperimentPoints from './ExperimentPoints';
import useStyles from './styles';
Expand All @@ -41,7 +40,6 @@ const TableData: React.FC<TableDataProps> = ({ data, deleteRow }) => {
const classes = useStyles();
const { t } = useTranslation();

const userRole = getUserRole();
const projectID = getProjectID();
const projectRole = getProjectRole();

Expand Down Expand Up @@ -238,7 +236,7 @@ const TableData: React.FC<TableDataProps> = ({ data, deleteRow }) => {
<div className={classes.weightDiv}>
{data.weightages.map((expData) => {
return (
<div style={{ marginBottom: 8 }}>
<div style={{ marginBottom: 20 }}>
<ExperimentPoints
expName={expData.experiment_name}
weight={expData.weightage}
Expand Down Expand Up @@ -284,7 +282,7 @@ const TableData: React.FC<TableDataProps> = ({ data, deleteRow }) => {
) : (
<></>
)}
{data.cronSyntax === '' ? (
{projectRole !== 'Viewer' && data.cronSyntax === '' ? (
<MenuItem value="Rerun_Schedule" onClick={() => reRunSchedule()}>
<div className={classes.expDiv}>
<ReplayIcon className={classes.rerunBtn} />
Expand Down Expand Up @@ -312,7 +310,7 @@ const TableData: React.FC<TableDataProps> = ({ data, deleteRow }) => {
</Typography>
</div>
</MenuItem>
{userRole !== 'Viewer' ? (
{projectRole !== 'Viewer' ? (
<MenuItem value="Analysis" onClick={() => setIsModalOpen(true)}>
<div className={classes.expDiv}>
<img
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ const useStyles = makeStyles((theme) => ({
weightInfo: {
display: 'flex',
flexDirection: 'row',
paddingBottom: theme.spacing(0.625),
paddingBottom: theme.spacing(1),
},
points: {
marginLeft: 'auto',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from '@material-ui/core';
import MoreVertIcon from '@material-ui/icons/MoreVert';
import React from 'react';
import { useTranslation } from 'react-i18next';
import LinearProgressBar from '../../../components/ProgressBar/LinearProgressBar';
import {
ExecutionData,
Expand All @@ -28,6 +29,8 @@ const TableData: React.FC<TableDataProps> = ({ data, exeData }) => {
const projectID = getProjectID();
const projectRole = getProjectRole();

const { t } = useTranslation();

const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
const open = Boolean(anchorEl);

Expand Down Expand Up @@ -74,22 +77,29 @@ const TableData: React.FC<TableDataProps> = ({ data, exeData }) => {
</TableCell>
<TableCell>
<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>
Overall RR: <span className={classes.failed}>0%</span>
{t('workflowDetails.overallRR')}
<span className={classes.failed}>0%</span>
</Typography>
<div className={classes.progressBar}>
<LinearProgressBar width={2} value={0} />
<LinearProgressBar width={0.1} value={0} />
</div>
</>
) : (
<>
<Typography>
Overall RR: <span className={classes.success}>100%</span>
{t('workflowDetails.overallRR')}
<span className={classes.success}>100%</span>
</Typography>
<div className={classes.progressBar}>
<LinearProgressBar width={2} value={100} />
<LinearProgressBar width={0.1} value={10} />
</div>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ const useStyles = makeStyles((theme) => ({
},
progressBar: {
width: '6.5rem',
marginTop: theme.spacing(2),
},
steps: {
marginLeft: theme.spacing(5.625),
Expand Down Expand Up @@ -135,6 +136,9 @@ const useStyles = makeStyles((theme) => ({
success: {
color: theme.palette.success.main,
},
warning: {
color: theme.palette.warning.main,
},
// Menu option with icon
expDiv: {
display: 'flex',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ const ScheduleCustomWorkflow: React.FC<VerifyCommitProps> = ({ gotoStep }) => {
container: {
args: [`${installAllExp}sleep 30`],
command: ['sh', '-c'],
image: 'alpine/k8s:1.18.2',
image: 'litmuschaos/k8s:latest',
},
};
workflows.forEach((data) => {
Expand Down Expand Up @@ -242,7 +242,7 @@ const ScheduleCustomWorkflow: React.FC<VerifyCommitProps> = ({ gotoStep }) => {
`kubectl delete chaosengine ${removeChaosEngine} -n {{workflow.parameters.adminModeNamespace}}`,
],
command: ['sh', '-c'],
image: 'alpine/k8s:1.18.2',
image: 'litmuschaos/k8s:latest',
},
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const ResultTable: React.FC<ResultModalProps> = ({ testValue, testNames }) => {
{t('createWorkflow.reliabilityScore.resultTable.points')}
<br />
<div className={classes.progressBar}>
<LinearProgressBar width={2} value={row.weight} />
<LinearProgressBar width={0.2} value={row.weight} />
</div>
</TableCell>
<TableCell align="left" className={classes.tablePoints}>
Expand All @@ -125,7 +125,7 @@ const ResultTable: React.FC<ResultModalProps> = ({ testValue, testNames }) => {
{t('createWorkflow.reliabilityScore.resultTable.points')}
<br />
<div className={classes.progressBar}>
<LinearProgressBar width={2} value={row.points} />
<LinearProgressBar width={0.2} value={row.points} />
</div>
</TableCell>
</TableRow>
Expand Down

0 comments on commit 2e2b309

Please sign in to comment.