Skip to content

Commit e6cf358

Browse files
committed
chore: move severity order to constants
1 parent bc793b3 commit e6cf358

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

src/components/common/helpers/Helpers.tsx

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,16 +1100,16 @@ export const getPluginIdsFromBuildStage = (
11001100
return pluginIds
11011101
}
11021102

1103+
const SEVERITY_ORDER = [
1104+
{ key: SeveritiesDTO.CRITICAL, label: 'Critical', variant: 'negative' },
1105+
{ key: SeveritiesDTO.HIGH, label: 'High', variant: 'custom', fontColor: 'R500', bgColor: 'R100' },
1106+
{ key: SeveritiesDTO.MEDIUM, label: 'Medium', variant: 'custom', fontColor: 'O600', bgColor: 'O100' },
1107+
{ key: SeveritiesDTO.LOW, label: 'Low', variant: 'warning' },
1108+
{ key: SeveritiesDTO.UNKNOWN, label: 'Unknown', variant: 'neutral' },
1109+
] as const
1110+
11031111
export const getSeverityWithCount = (severityCount: SeverityCount) => {
1104-
const order = [
1105-
{ key: SeveritiesDTO.CRITICAL, label: 'Critical', variant: 'negative' },
1106-
{ key: SeveritiesDTO.HIGH, label: 'High', variant: 'custom', fontColor: 'R500', bgColor: 'R100' },
1107-
{ key: SeveritiesDTO.MEDIUM, label: 'Medium', variant: 'custom', fontColor: 'O600', bgColor: 'O100' },
1108-
{ key: SeveritiesDTO.LOW, label: 'Low', variant: 'warning' },
1109-
{ key: SeveritiesDTO.UNKNOWN, label: 'Unknown', variant: 'neutral' },
1110-
] as const
1111-
1112-
for (const item of order) {
1112+
for (const item of SEVERITY_ORDER) {
11131113
if (severityCount[item.key]) {
11141114
if (item.variant === 'custom') {
11151115
return (
@@ -1119,18 +1119,12 @@ export const getSeverityWithCount = (severityCount: SeverityCount) => {
11191119
fontColor={item.fontColor}
11201120
bgColor={item.bgColor}
11211121
/>
1122-
);
1123-
} else {
1124-
return (
1125-
<Badge
1126-
label={`${severityCount[item.key]} ${item.label}`}
1127-
variant={item.variant}
1128-
/>
1129-
);
1122+
)
11301123
}
1124+
return <Badge label={`${severityCount[item.key]} ${item.label}`} variant={item.variant} />
11311125
}
11321126
}
1133-
return <Badge label='Passed' variant='positive' />
1127+
return <Badge label="Passed" variant="positive" />
11341128
}
11351129

11361130
// FIXME: Ideally whole branch calculations should be in fe-lib

0 commit comments

Comments
 (0)