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

Commit a74ec68

Browse files
authored
Fix prometheus menus (#384)
* Fixed prometheus menus. * 2.22.0 * Replaced dashes. * 2.22.1 * Added forgotten replacement. * 2.22.2
1 parent 357cc8f commit a74ec68

File tree

6 files changed

+19
-10
lines changed

6 files changed

+19
-10
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@netdata/dashboard",
3-
"version": "2.21.8",
3+
"version": "2.22.2",
44
"homepage": ".",
55
"main": "./lib/src/index-npm.js",
66
"files": [

src/domains/charts/getChartMenu.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
export default (
22
{ id, name, family, context, priority, chartLabels },
33
submenuNames,
4-
hasKubernetes
4+
{ hasKubernetes, composite } = {}
55
) => {
66
const subMenuId = family || "all"
77
const clusterId = hasKubernetes && chartLabels?.k8s_cluster_id?.[0]
88

9-
const [type, typeB] = id.split(".")
9+
const [type, typeB, typeC] = id.split(".")
1010
const parts = type.split("_")
1111
const [part1, part2] = parts
1212

@@ -81,7 +81,13 @@ export default (
8181
}
8282

8383
case "prometheus": {
84-
if (parts.length !== 1) return emit({ menuPattern: "prometheus" })
84+
if (parts.length !== 1) {
85+
if (composite && typeC) return emit({ menuPattern: `${type} ${typeB.replace("-", " ")}` })
86+
87+
return emit({ menuPattern: "prometheus" })
88+
}
89+
90+
if (composite && typeC) return emit({ menu: `${type} ${typeB.replace("-", " ")}` })
8591

8692
const familyPart = family.split("_")[0]
8793
return emit({ menu: `prometheus ${familyPart}` })

src/domains/charts/getMenu.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import getChartMenu from "./getChartMenu"
55
import getChartHeads from "./getChartHeads"
66
import getMenuChartAttributes from "./getMenuChartAttributes"
77

8-
export const getMenuInfo = (chartIds, getChart, hasKubernetes) => {
8+
export const getMenuInfo = (chartIds, getChart, { hasKubernetes, composite } = {}) => {
99
const submenuNames = {}
1010
const chartMenus = {}
1111
const menuChartsAttributeById = {}
@@ -16,7 +16,7 @@ export const getMenuInfo = (chartIds, getChart, hasKubernetes) => {
1616
chartIds.forEach(id => {
1717
const chart = getChart(id)
1818
menuChartsAttributeById[id] = getMenuChartAttributes(chart)
19-
chartMenus[id] = getChartMenu(chart, submenuNames, hasKubernetes)
19+
chartMenus[id] = getChartMenu(chart, submenuNames, { hasKubernetes, composite })
2020
})
2121

2222
const sortedChartIds = [...chartIds].sort(
@@ -47,15 +47,15 @@ export const getMenuInfo = (chartIds, getChart, hasKubernetes) => {
4747
}
4848
}
4949

50-
export default (chartIds, getChart, { hasKubernetes } = {}) => {
50+
export default (chartIds, getChart, { hasKubernetes, composite } = {}) => {
5151
const {
5252
chartMenus,
5353
menuChartsAttributeById,
5454
menuGroups,
5555
menuGroupChartIds,
5656
subMenus,
5757
submenuNames,
58-
} = getMenuInfo(chartIds, getChart, hasKubernetes)
58+
} = getMenuInfo(chartIds, getChart, { hasKubernetes, composite })
5959

6060
const menuGroupById = Object.keys(menuGroups).reduce((acc, menuId) => {
6161
const chartIds = menuGroupChartIds[menuId]

src/domains/charts/provider.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ const Provider = ({
1414
getChart,
1515
dashboardAttributes,
1616
hasKubernetes,
17+
composite,
1718
children,
1819
}) => {
1920
const { menuGroupIds, menuGroupById, subMenuById, menuChartsAttributeById } = useMemo(
20-
() => getMenu(chartIds, getChart, { hasKubernetes }),
21+
() => getMenu(chartIds, getChart, { hasKubernetes, composite }),
2122
[chartIds, getChart]
2223
)
2324

src/domains/dashboard/components/virtualized/provider.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const Provider = ({
2323
chartIds,
2424
theme,
2525
hasKubernetes,
26+
composite,
2627
children,
2728
}) => {
2829
const ref = useRef()
@@ -45,6 +46,7 @@ const Provider = ({
4546
onAttributesChange={onAttributesChange}
4647
dashboardAttributes={dashboardAttributes}
4748
hasKubernetes={hasKubernetes}
49+
composite={composite}
4850
>
4951
{children}
5052
</DashboardMenuProvider>

0 commit comments

Comments
 (0)