Skip to content

Commit 7e827a7

Browse files
authored
Show units in details panel (#198)
* Show units in details panel * Show raw units next to chart tite * fixup! Show raw units next to chart tite * Show only raw units on title * Add tooltip
1 parent a0ea849 commit 7e827a7

File tree

5 files changed

+43
-13
lines changed

5 files changed

+43
-13
lines changed

src/components/details/context.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
import React from "react"
2-
import { TextSmall, Flex } from "@netdata/netdata-ui"
32
import { useAttributeValue } from "@/components/provider"
43
import Row from "./row"
5-
6-
const Info = ({ title, children }) => (
7-
<Flex gap={2}>
8-
<TextSmall color="textDescription">{title}</TextSmall>
9-
<Flex as={TextSmall} background="elementBackground">
10-
{children}
11-
</Flex>
12-
</Flex>
13-
)
4+
import Info from "./info"
145

156
const Context = () => {
167
const contextScope = useAttributeValue("contextScope")

src/components/details/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useAttributeValue } from "@/components/provider"
55
import Context from "./context"
66
import Source from "./source"
77
import Description from "./description"
8+
import Units from "./units"
89

910
const Container = styled(Flex).attrs({
1011
column: true,
@@ -23,6 +24,7 @@ const Details = () => {
2324
<Description />
2425
{nodeName && <Source />}
2526
<Context />
27+
<Units />
2628
</Container>
2729
)
2830
}

src/components/details/info.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React from "react"
2+
import { TextSmall, Flex } from "@netdata/netdata-ui"
3+
4+
const Info = ({ title, children }) => (
5+
<Flex gap={2}>
6+
<TextSmall color="textDescription">{title}</TextSmall>
7+
<Flex as={TextSmall} background="elementBackground">
8+
{children}
9+
</Flex>
10+
</Flex>
11+
)
12+
13+
export default Info

src/components/details/units.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from "react"
2+
import { useUnitSign } from "@/components/provider"
3+
import Row from "./row"
4+
import Info from "./info"
5+
6+
const Units = () => {
7+
const rawUnits = useUnitSign({ withoutConversion: true, long: true })
8+
9+
return (
10+
<Row title="Units" color="key" data-testid="cartDetails-units">
11+
<Info title="Raw data units">{rawUnits}</Info>
12+
</Row>
13+
)
14+
}
15+
16+
export default Units

src/components/title/index.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ import {
88
useIsMinimal,
99
useAttributeValue,
1010
} from "@/components/provider"
11+
import { withTooltip } from "@/components/tooltip"
12+
13+
const TextWithTooltip = withTooltip(TextSmall)
1114

1215
export const Title = props => {
1316
const title = useTitle()
14-
const units = useUnitSign({ long: true })
17+
const units = useUnitSign({ withoutConversion: true, long: true })
1518
const name = useName()
1619
const isMinimal = useIsMinimal()
1720
const contextScope = useAttributeValue("contextScope")
@@ -39,9 +42,14 @@ export const Title = props => {
3942
</CopyToClipboard>
4043
)}
4144
{!!units && !isMinimal && (
42-
<TextSmall color="textLite" whiteSpace="nowrap">
45+
<TextWithTooltip
46+
color="textLite"
47+
whiteSpace="nowrap"
48+
title="Source unit (alerts)"
49+
tooltipProps={{ align: "top" }}
50+
>
4351
• [{units}]
44-
</TextSmall>
52+
</TextWithTooltip>
4553
)}
4654
</Flex>
4755
)

0 commit comments

Comments
 (0)