Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Disable help for disabled plugins #1087

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading