Skip to content

Commit 62c1184

Browse files
feat(heureka): update severity icons (#1161)
* update heureka items * update heureka severity icons * update heureka severity icons * update icon color * update icon logic * update icon logic * update icon logic * update icon logic * update icon logic * update icon logic * update icon logic * update icon logic
1 parent c3eaa3c commit 62c1184

10 files changed

Lines changed: 68 additions & 48 deletions

File tree

.changeset/lovely-readers-end.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cloudoperators/juno-app-heureka": minor
3+
---
4+
5+
Update severity icons.

apps/heureka/src/components/Service/ImageVersionDetailsPanel/ImageVersionIssuesList/IssuesDataRows/IssuesDataRow/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { Issue } from "../../../../../Services/utils"
1212
import { getSeverityColor, useTextOverflow } from "../../../../../../utils"
1313

1414
const cellSeverityClasses = (severity: string) => {
15-
let borderColor = getSeverityColor(severity)
15+
const borderColor = getSeverityColor(severity.toLowerCase())
1616

1717
return `
1818
border-l-2

apps/heureka/src/components/Services/ServicesList/ServicesDataRows/ServiceDataRow.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const ServiceDataRow = ({ item, selected, onItemClick, onServiceDetailCli
4848
<SeverityCount
4949
showDashIfZero
5050
count={item.issuesCount.critical}
51-
icon="danger"
51+
icon="severityCritical"
5252
variant="danger"
5353
tooltipContent="Critical Vulnerabilities"
5454
/>
@@ -57,7 +57,7 @@ export const ServiceDataRow = ({ item, selected, onItemClick, onServiceDetailCli
5757
<SeverityCount
5858
showDashIfZero
5959
count={item.issuesCount.high}
60-
icon="warning"
60+
icon="severityHigh"
6161
variant="warning"
6262
tooltipContent="High Vulnerabilities"
6363
/>
@@ -66,7 +66,7 @@ export const ServiceDataRow = ({ item, selected, onItemClick, onServiceDetailCli
6666
<SeverityCount
6767
showDashIfZero
6868
count={item.issuesCount.medium}
69-
icon="errorOutline"
69+
icon="severityMedium"
7070
variant="warning"
7171
tooltipContent="Medium Vulnerabilities"
7272
/>
@@ -75,7 +75,7 @@ export const ServiceDataRow = ({ item, selected, onItemClick, onServiceDetailCli
7575
<SeverityCount
7676
showDashIfZero
7777
count={item.issuesCount.low}
78-
icon="info"
78+
icon="severityLow"
7979
variant="info"
8080
tooltipContent="Low Vulnerabilities"
8181
/>
@@ -84,7 +84,7 @@ export const ServiceDataRow = ({ item, selected, onItemClick, onServiceDetailCli
8484
<SeverityCount
8585
showDashIfZero
8686
count={item.issuesCount.none}
87-
icon="help"
87+
icon="severityUnknown"
8888
variant="default"
8989
tooltipContent="None Vulnerabilities"
9090
/>

apps/heureka/src/components/Vulnerabilities/VulnerabilitiesList/VulnerabilitiesDataRows/VulnerabilityDataRow.tsx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
*/
55

66
import React, { useState } from "react"
7-
import { DataGridRow, DataGridCell, Stack, Icon, KnownIcons } from "@cloudoperators/juno-ui-components"
8-
import { getSeverityColor, useTextOverflow } from "../../../../utils"
7+
import { DataGridRow, DataGridCell, Stack, Icon } from "@cloudoperators/juno-ui-components"
8+
import { getSeverityColor, iconMap, useTextOverflow } from "../../../../utils"
99
import { IssueTimestamp } from "../../../common/IssueTimestamp"
1010
import { Vulnerability } from "../../utils"
1111

@@ -16,7 +16,7 @@ type VulnerabilityDataRowProps = {
1616
}
1717

1818
const cellSeverityClasses = (severity: string) => {
19-
let borderColor = getSeverityColor(severity || "none")
19+
const borderColor = getSeverityColor(severity.toLowerCase() || "none")
2020

2121
return `
2222
border-l-2
@@ -28,15 +28,7 @@ const cellSeverityClasses = (severity: string) => {
2828

2929
const getIconForSeverity = (severity: string) => {
3030
const severityLower = (severity || "none").toLowerCase()
31-
const iconColor = getSeverityColor(severity || "none")
32-
33-
const iconMap: Record<string, KnownIcons> = {
34-
critical: "danger",
35-
high: "warning",
36-
medium: "errorOutline",
37-
low: "info",
38-
none: "help",
39-
}
31+
const iconColor = getSeverityColor(severityLower || "none")
4032

4133
return <Icon icon={iconMap[severityLower] || "help"} color={iconColor} />
4234
}

apps/heureka/src/components/common/IssueCountsPerSeverityLevel.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,35 @@ export const IssueCountsPerSeverityLevel = ({ counts }: IssueCountsPerSeverityLe
2424
<div className="font-bold mr-2">{counts.total}</div>
2525
</>
2626
<SeverityCount
27-
icon="danger"
27+
icon="severityCritical"
2828
count={counts.critical}
2929
variant={counts.critical > 0 ? "danger" : "default"}
3030
tooltipContent="Critical Vulnerabilities"
3131
/>
3232
<SeverityCount
33-
icon="warning"
33+
icon="severityHigh"
3434
count={counts.high}
3535
variant={counts.high > 0 ? "warning" : "default"}
3636
tooltipContent="High Vulnerabilities"
3737
/>
3838
<SeverityCount
39-
icon="errorOutline"
39+
icon="severityMedium"
4040
count={counts.medium}
4141
variant={counts.medium > 0 ? "warning" : "default"}
4242
tooltipContent="Medium Vulnerabilities"
4343
/>
4444
<SeverityCount
45-
icon="info"
45+
icon="severityLow"
4646
count={counts.low}
4747
variant={counts.low > 0 ? "info" : "default"}
4848
tooltipContent="Low Vulnerabilities"
4949
/>
50-
<SeverityCount icon="help" count={counts.none} variant="default" tooltipContent="None Vulnerabilities" />
50+
<SeverityCount
51+
icon="severityUnknown"
52+
count={counts.none}
53+
variant="default"
54+
tooltipContent="None Vulnerabilities"
55+
/>
5156
</Stack>
5257
)
5358
}

apps/heureka/src/components/common/IssueIcon.tsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,16 @@
44
*/
55

66
import React from "react"
7-
import { Icon, KnownIcons } from "@cloudoperators/juno-ui-components"
8-
import { getSeverityColor } from "../../utils"
7+
import { Icon } from "@cloudoperators/juno-ui-components"
8+
import { getSeverityColor, iconMap } from "../../utils"
99

1010
type IssueIconProps = {
1111
severity: string
1212
}
1313

1414
const getIconForSeverity = (severity: string) => {
1515
const severityLower = severity.toLowerCase()
16-
const iconColor = getSeverityColor(severity)
17-
18-
const iconMap: Record<string, KnownIcons> = {
19-
critical: "danger",
20-
high: "warning",
21-
medium: "errorOutline",
22-
low: "info",
23-
none: "help",
24-
}
16+
const iconColor = getSeverityColor(severityLower)
2517

2618
return <Icon icon={iconMap[severityLower] || "help"} color={iconColor} />
2719
}

apps/heureka/src/components/common/ServiceImageVersions/ImageVersionsDataRows/ImageVersionsDataRow.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const ImageVersionsDataRow = ({
5555
<SeverityCount
5656
showDashIfZero
5757
count={version.issueCounts.critical}
58-
icon="danger"
58+
icon="severityCritical"
5959
variant="danger"
6060
tooltipContent="Critical Vulnerabilities"
6161
/>
@@ -64,7 +64,7 @@ export const ImageVersionsDataRow = ({
6464
<SeverityCount
6565
showDashIfZero
6666
count={version.issueCounts.high}
67-
icon="warning"
67+
icon="severityHigh"
6868
variant="warning"
6969
tooltipContent="High Vulnerabilities"
7070
/>
@@ -73,7 +73,7 @@ export const ImageVersionsDataRow = ({
7373
<SeverityCount
7474
showDashIfZero
7575
count={version.issueCounts.medium}
76-
icon="errorOutline"
76+
icon="severityMedium"
7777
variant="warning"
7878
tooltipContent="Medium Vulnerabilities"
7979
/>
@@ -82,7 +82,7 @@ export const ImageVersionsDataRow = ({
8282
<SeverityCount
8383
showDashIfZero
8484
count={version.issueCounts.low}
85-
icon="info"
85+
icon="severityLow"
8686
variant="info"
8787
tooltipContent="Low Vulnerabilities"
8888
/>
@@ -91,7 +91,7 @@ export const ImageVersionsDataRow = ({
9191
<SeverityCount
9292
showDashIfZero
9393
count={version.issueCounts.none}
94-
icon="help"
94+
icon="severityUnknown"
9595
variant="default"
9696
tooltipContent="None Vulnerabilities"
9797
/>

apps/heureka/src/components/common/SeverityCount.test.tsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,47 @@ import { SeverityCount } from "./SeverityCount"
99

1010
describe("SeverityCount", () => {
1111
it("renders with count and shows badge", () => {
12-
render(<SeverityCount showDashIfZero icon="danger" count={5} variant="danger" tooltipContent="Critical Issues" />)
12+
render(
13+
<SeverityCount
14+
showDashIfZero
15+
icon="severityCritical"
16+
count={5}
17+
variant="danger"
18+
tooltipContent="Critical Issues"
19+
/>
20+
)
1321

1422
// Check if the badge is rendered with the count
1523
const badge = screen.getByText("5")
1624
expect(badge).toBeInTheDocument()
1725
})
1826

1927
it("renders without count and shows dash in single mode", () => {
20-
render(<SeverityCount showDashIfZero icon="danger" count={0} variant="danger" tooltipContent="Critical Issues" />)
28+
render(
29+
<SeverityCount
30+
showDashIfZero
31+
icon="severityCritical"
32+
count={0}
33+
variant="danger"
34+
tooltipContent="Critical Issues"
35+
/>
36+
)
2137

2238
// Check if dash is rendered instead of a badge
2339
const dash = screen.getByText("—")
2440
expect(dash).toBeInTheDocument()
2541
})
2642

2743
it("renders with zero count and shows '0' in all mode", () => {
28-
render(<SeverityCount icon="danger" count={0} variant="danger" tooltipContent="Critical Issues" />)
44+
render(<SeverityCount icon="severityCritical" count={0} variant="danger" tooltipContent="Critical Issues" />)
2945

3046
// Check if the badge is rendered with "0"
3147
const badge = screen.getByText("0")
3248
expect(badge).toBeInTheDocument()
3349
})
3450

3551
it("renders with positive count in all mode", () => {
36-
render(<SeverityCount icon="danger" count={3} variant="danger" tooltipContent="Critical Issues" />)
52+
render(<SeverityCount icon="severityCritical" count={3} variant="danger" tooltipContent="Critical Issues" />)
3753

3854
// Check if the badge is rendered with the count
3955
const badge = screen.getByText("3")

apps/heureka/src/components/common/SeverityCount.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
TooltipContent,
1212
KnownIcons,
1313
BadgeVariantType,
14+
Icon,
1415
} from "@cloudoperators/juno-ui-components"
1516

1617
type SeverityCountProps = {

apps/heureka/src/utils.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
import { useState, useRef, useEffect } from "react"
7+
import { KnownIcons } from "@cloudoperators/juno-ui-components"
78

89
export const capitalizeFirstLetter = (str: string): string => {
910
return str.charAt(0).toUpperCase() + str.slice(1)
@@ -12,20 +13,28 @@ export const capitalizeFirstLetter = (str: string): string => {
1213
export const getSeverityColor = (severity: string): string => {
1314
switch (severity.toLowerCase()) {
1415
case "critical":
15-
return "text-theme-danger"
16+
return "text-theme-severity-critical"
1617
case "high":
17-
return "text-theme-warning"
18+
return "text-theme-severity-high"
1819
case "medium":
19-
return "text-theme-warning"
20+
return "text-theme-severity-medium"
2021
case "low":
21-
return "text-theme-info"
22+
return "text-theme-severity-low"
2223
case "none":
23-
return "text-theme-default"
24+
return "text-theme-severity-unknown"
2425
default:
2526
return "text-theme-default"
2627
}
2728
}
2829

30+
export const iconMap: Record<string, KnownIcons> = {
31+
critical: "severityCritical",
32+
high: "severityHigh",
33+
medium: "severityMedium",
34+
low: "severityLow",
35+
none: "severityUnknown",
36+
}
37+
2938
/**
3039
* Hook to detect if text content overflows its container
3140
* @param text - The text content to check

0 commit comments

Comments
 (0)