Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
Introduce NodeInfo on MenuSidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
jjtsou committed Jun 7, 2022
1 parent da25070 commit bb4ecf9
Showing 1 changed file with 44 additions and 6 deletions.
50 changes: 44 additions & 6 deletions src/domains/charts/menuGroup/menu.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { memo, forwardRef } from "react"
import styled from "styled-components"
import { Flex } from "@netdata/netdata-ui"
import { Flex, Text } from "@netdata/netdata-ui"
import { useContainer } from "domains/charts/charts"
import { withMenuGroupIds } from "./context"
import { MenuGroupContainer } from "./menuGroup"
Expand Down Expand Up @@ -40,15 +40,53 @@ export const MenuSidebar = props => {
return props.isFixedPosition ? <StyledMenuSidebar top={top} {...props} /> : <Flex {...props} />
}

const StyledText = styled(Text)`
line-height: 25px;
`

const NodeInfo = memo(({ showCounters, chartsCount, metricsCount, alarmsCount, nodeName }) => {
const shouldShowCounters = showCounters && chartsCount && metricsCount && alarmsCount

if (!shouldShowCounters) return null
return (
<StyledText margin={[5]} color="textLite">
Every second, Netdata collects
<Text strong color="textLite" margin={[0, 1]}>
{metricsCount}
</Text>
metrics on {nodeName}, presents them in
<Text strong color="textLite" margin={[0, 1]}>
{chartsCount}
</Text>
charts, and monitors them with
<Text strong color="textLite" margin={[0, 1]}>
{alarmsCount}
</Text>
alarms.
</StyledText>
)
})

export const MenuSidebarContainer = ({
onMenuGroupClick,
onSubMenuClick,
isFixedPosition = true,
...rest
}) => (
<MenuSidebar isFixedPosition={isFixedPosition} {...rest}>
<MenuContainer onMenuGroupClick={onMenuGroupClick} onSubMenuClick={onSubMenuClick} />
</MenuSidebar>
)
}) => {
const { showCounters, chartsCount, metricsCount, alarmsCount, nodeName } = rest

return (
<MenuSidebar isFixedPosition={isFixedPosition} {...rest}>
<MenuContainer onMenuGroupClick={onMenuGroupClick} onSubMenuClick={onSubMenuClick} />
<NodeInfo
nodeName={nodeName}
chartsCount={chartsCount}
metricsCount={metricsCount}
alarmsCount={alarmsCount}
showCounters={showCounters}
/>
</MenuSidebar>
)
}

export const SidebarContainer = memo(MenuSidebarContainer)

0 comments on commit bb4ecf9

Please sign in to comment.