From ac8ad3e12395a4e03274b5defeed2ebd15268aa2 Mon Sep 17 00:00:00 2001 From: Martin Muzikar Date: Thu, 29 Aug 2024 14:42:19 +0200 Subject: [PATCH] fix: Disable help for disabled plugins --- packages/hawtio/src/help/HawtioHelp.tsx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/hawtio/src/help/HawtioHelp.tsx b/packages/hawtio/src/help/HawtioHelp.tsx index 6600119f..f09aa03c 100644 --- a/packages/hawtio/src/help/HawtioHelp.tsx +++ b/packages/hawtio/src/help/HawtioHelp.tsx @@ -11,16 +11,30 @@ import { TextContent, Title, } from '@patternfly/react-core' -import React from 'react' +import React, { useMemo } from 'react' import Markdown from 'react-markdown' import { NavLink, Navigate, Route, Routes, useLocation } from 'react-router-dom' import help from './help.md' import { helpRegistry } from './registry' +import { hawtio, usePlugins } from '@hawtiosrc/core' helpRegistry.add('home', 'Home', help, 1) export const HawtioHelp: React.FunctionComponent = () => { const location = useLocation() + const { plugins } = usePlugins() + + const helps = useMemo(() => { + const pluginIds = hawtio.getPlugins().map(p => p.id) + const activePlugins = plugins.map(p => p.id) + return helpRegistry.getHelps().filter(help => { + if (pluginIds.includes(help.id)) { + return activePlugins.includes(help.id) + } + return true + }) + }, [plugins]) + return ( @@ -30,7 +44,7 @@ export const HawtioHelp: React.FunctionComponent = () => {