diff --git a/public/app/features/commandPalette/actions/staticActions.ts b/public/app/features/commandPalette/actions/staticActions.ts index 12f69fe247f..d7dd4abd953 100644 --- a/public/app/features/commandPalette/actions/staticActions.ts +++ b/public/app/features/commandPalette/actions/staticActions.ts @@ -1,4 +1,5 @@ import { NavModelItem } from '@grafana/data'; +import { enrichHelpItem } from 'app/core/components/AppChrome/MegaMenu/utils'; import { t } from 'app/core/internationalization'; import { changeTheme } from 'app/core/services/theme'; @@ -13,11 +14,16 @@ function idForNavItem(navItem: NavModelItem) { function navTreeToActions(navTree: NavModelItem[], parents: NavModelItem[] = []): CommandPaletteAction[] { const navActions: CommandPaletteAction[] = []; - for (const navItem of navTree) { - const { url, target, text, isCreateAction, children } = navItem; + for (let navItem of navTree) { + // help node needs enriching with the frontend links + if (navItem.id === 'help') { + navItem = enrichHelpItem({ ...navItem }); + delete navItem.url; + } + const { url, target, text, isCreateAction, children, onClick } = navItem; const hasChildren = Boolean(children?.length); - if (!(url || hasChildren)) { + if (!(url || onClick || hasChildren)) { continue; } @@ -28,13 +34,14 @@ function navTreeToActions(navTree: NavModelItem[], parents: NavModelItem[] = []) const priority = isCreateAction ? ACTIONS_PRIORITY : DEFAULT_PRIORITY; const subtitle = parents.map((parent) => parent.text).join(' > '); - const action = { + const action: CommandPaletteAction = { id: idForNavItem(navItem), name: text, section: section, url, target, parent: parents.length > 0 && !isCreateAction ? idForNavItem(parents[parents.length - 1]) : undefined, + perform: onClick, priority: priority, subtitle: isCreateAction ? undefined : subtitle, };