Skip to content

Commit

Permalink
fix: fixed the progress bar color to match the severity label colors (#…
Browse files Browse the repository at this point in the history
…331)

Signed-off-by: Olga Lavtar <[email protected]>
  • Loading branch information
olavtar authored Apr 16, 2024
1 parent 6d7bcfa commit 33192eb
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/main/resources/freemarker/templates/generated/main.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/main/resources/freemarker/templates/generated/main.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

19 changes: 13 additions & 6 deletions ui/src/components/VulnerabilityScore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,33 @@ import {
Progress,
ProgressMeasureLocation,
ProgressSize,
ProgressVariant,
Split,
SplitItem,
} from '@patternfly/react-core';
import { Vulnerability } from '../api/report';
import {Vulnerability} from '../api/report';

interface VulnerabilityScoreProps {
vulnerability: Vulnerability;
}

export const VulnerabilityScore: React.FC<VulnerabilityScoreProps> = ({ vulnerability }) => {
const severity = vulnerability.severity;
let progressBarVariant: ProgressVariant;
let progressBarClassName;
switch (severity) {
case 'CRITICAL':
progressBarClassName = 'bar-critical'
break;
case 'HIGH':
progressBarVariant = ProgressVariant.danger;
progressBarClassName = 'bar-high'
break;
case 'MEDIUM':
progressBarClassName = 'bar-medium'
break;
case 'LOW':
progressBarClassName = 'bar-low'
break;
default:
progressBarVariant = ProgressVariant.warning;
progressBarClassName = 'bar-default'
break;
}
return (
Expand All @@ -36,8 +43,8 @@ export const VulnerabilityScore: React.FC<VulnerabilityScoreProps> = ({ vulnerab
min={0}
max={10}
size={ProgressSize.sm}
variant={progressBarVariant}
measureLocation={ProgressMeasureLocation.none}
className={`${progressBarClassName}`}
/>
</SplitItem>
</Split>
Expand Down
22 changes: 22 additions & 0 deletions ui/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,25 @@ body {
height: 100%;
color: black;
}

/* Progress bar styles */

.bar-critical .pf-v5-c-progress__indicator {
background-color: #800000;
}

.bar-high .pf-v5-c-progress__indicator {
background-color: #FF0000;
}

.bar-medium .pf-v5-c-progress__indicator{
background-color: #FFA500;
}

.bar-low .pf-v5-c-progress__indicator {
background-color: #5BA352;
}

.bar-default .pf-v5-c-progress__indicator {
background-color: #06c;
}

0 comments on commit 33192eb

Please sign in to comment.