Skip to content

Commit 4c17d53

Browse files
committed
feat: ResourceListTable - add tooltip for cpu and memory usage
1 parent 7b61b2d commit 4c17d53

File tree

2 files changed

+38
-13
lines changed

2 files changed

+38
-13
lines changed

src/components/ResourceBrowser/ResourceList/K8sResourceListTableCellComponent.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ const K8sResourceListTableCellComponent = ({
216216
<K8sResourceListTableUsageCell
217217
percentage={resourceData['cpu.usagePercentage'] as string}
218218
absoluteValue={resourceData['cpu.usage'] as string}
219+
totalValue={resourceData['cpu.allocatable'] as string}
219220
color="var(--B300)"
220221
/>
221222
)
@@ -226,6 +227,7 @@ const K8sResourceListTableCellComponent = ({
226227
<K8sResourceListTableUsageCell
227228
percentage={resourceData['memory.usagePercentage'] as string}
228229
absoluteValue={resourceData['memory.usage'] as string}
230+
totalValue={resourceData['memory.allocatable'] as string}
229231
color="var(--V300)"
230232
/>
231233
)
Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,53 @@
1-
import { SegmentedBarChart } from '@devtron-labs/devtron-fe-common-lib'
1+
import { SegmentedBarChart, Tooltip } from '@devtron-labs/devtron-fe-common-lib'
22

33
export const K8sResourceListTableUsageCell = ({
44
percentage,
55
absoluteValue,
6+
totalValue,
67
color,
78
}: {
89
percentage: string
910
absoluteValue: string
11+
totalValue: string
1012
color: string
1113
}) => {
1214
const percentageInNumber = parseInt(percentage, 10)
1315
const usagePercentage = Number.isNaN(percentageInNumber) ? 0 : percentageInNumber
1416

1517
return (
16-
<div className="flexbox-col dc__content-center dc__gap-4">
17-
<div className="flex left dc__gap-8">
18-
<p className="m-0 fs-13 lh-20 cn-9 flex-grow-1">{absoluteValue}</p>
19-
<p className="m-0 fs-13 lh-20 cn-7">{percentage}</p>
18+
<Tooltip
19+
className="no-content-padding w-160"
20+
alwaysShowTippyOnHover
21+
content={
22+
<div className="flexbox-col dc__gap-4 p-8">
23+
<div className="flex left dc__gap-8 text__white">
24+
<p className="m-0 fs-12 lh-18 flex-grow-1">Usage (%)</p>
25+
<p className="m-0 fs-12 lh-18">{percentage}</p>
26+
</div>
27+
<div className="flex left dc__gap-8 text__white">
28+
<p className="m-0 fs-12 lh-18 flex-grow-1">Usage (Abs.)</p>
29+
<p className="m-0 fs-12 lh-18">{absoluteValue}</p>
30+
</div>
31+
<div className="flex left dc__gap-8 text__white">
32+
<p className="m-0 fs-12 lh-18 flex-grow-1">Allocatable</p>
33+
<p className="m-0 fs-12 lh-18">{totalValue}</p>
34+
</div>
35+
</div>
36+
}
37+
>
38+
<div className="flexbox-col dc__content-center dc__gap-4 py-10 cursor">
39+
<div className="flex left dc__gap-8">
40+
<p className="m-0 fs-13 lh-20 cn-9 flex-grow-1">{absoluteValue}</p>
41+
<p className="m-0 fs-13 lh-20 cn-7">{percentage}</p>
42+
</div>
43+
<SegmentedBarChart
44+
entities={[
45+
{ value: usagePercentage, color },
46+
{ value: 100 - usagePercentage, color: 'var(--N200)' },
47+
]}
48+
hideLegend
49+
/>
2050
</div>
21-
<SegmentedBarChart
22-
entities={[
23-
{ value: usagePercentage, color },
24-
{ value: 100 - usagePercentage, color: 'var(--N200)' },
25-
]}
26-
hideLegend
27-
/>
28-
</div>
51+
</Tooltip>
2952
)
3053
}

0 commit comments

Comments
 (0)