Skip to content

Commit

Permalink
fix: Disable help for disabled plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
mmuzikar authored and tadayosi committed Aug 30, 2024
1 parent bdc7f40 commit 8c6f3c8
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions packages/hawtio/src/help/HawtioHelp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<React.Fragment>
<PageSection variant={PageSectionVariants.light}>
Expand All @@ -30,7 +44,7 @@ export const HawtioHelp: React.FunctionComponent = () => {
<PageNavigation>
<Nav aria-label='Nav' variant='tertiary'>
<NavList>
{helpRegistry.getHelps().map(help => (
{helps.map(help => (
<NavItem key={help.id} isActive={location.pathname === `/help/${help.id}`}>
<NavLink to={help.id}>{help.title}</NavLink>
</NavItem>
Expand Down

0 comments on commit 8c6f3c8

Please sign in to comment.