diff --git a/public/app/features/commandPalette/KBarResults.tsx b/public/app/features/commandPalette/KBarResults.tsx index 76ff919b1f1..9222315f335 100644 --- a/public/app/features/commandPalette/KBarResults.tsx +++ b/public/app/features/commandPalette/KBarResults.tsx @@ -155,13 +155,16 @@ export const KBarResults: React.FC = (props) => { }} > {rowVirtualizer.virtualItems.map((virtualRow) => { - const item = itemsRef.current[virtualRow.index]; + // eslint-disable-next-line @typescript-eslint/consistent-type-assertions + const item = itemsRef.current[virtualRow.index] as ActionImpl & { + url?: string; + target?: React.HTMLAttributeAnchorTarget; + }; // ActionImpl constructor copies all properties from action onto ActionImpl // so our url property is secretly there, but completely untyped // Preferably this change is upstreamed and ActionImpl has this - // eslint-disable-next-line @typescript-eslint/consistent-type-assertions - const url = (item as ActionImpl & { url?: string }).url; + const { target, url } = item; const handlers = typeof item !== 'string' && { onPointerMove: () => @@ -200,6 +203,7 @@ export const KBarResults: React.FC = (props) => { ) : null} {...childProps} diff --git a/public/app/features/commandPalette/actions/staticActions.ts b/public/app/features/commandPalette/actions/staticActions.ts index 422894a551d..dd702722b41 100644 --- a/public/app/features/commandPalette/actions/staticActions.ts +++ b/public/app/features/commandPalette/actions/staticActions.ts @@ -14,7 +14,7 @@ function navTreeToActions(navTree: NavModelItem[], parents: NavModelItem[] = []) const navActions: CommandPaletteAction[] = []; for (const navItem of navTree) { - const { url, text, isCreateAction, children } = navItem; + const { url, target, text, isCreateAction, children } = navItem; const hasChildren = Boolean(children?.length); if (!(url || hasChildren)) { @@ -33,6 +33,7 @@ function navTreeToActions(navTree: NavModelItem[], parents: NavModelItem[] = []) name: text, section: section, url: url && locationUtil.stripBaseFromUrl(url), + target, parent: parents.length > 0 && !isCreateAction ? idForNavItem(parents[parents.length - 1]) : undefined, priority: priority, subtitle: isCreateAction ? undefined : subtitle, diff --git a/public/app/features/commandPalette/types.ts b/public/app/features/commandPalette/types.ts index d44879d69cd..564d691928d 100644 --- a/public/app/features/commandPalette/types.ts +++ b/public/app/features/commandPalette/types.ts @@ -9,11 +9,13 @@ export type CommandPaletteAction = RootCommandPaletteAction | ChildCommandPalett type RootCommandPaletteAction = Omit & { section: NotNullable; priority: NotNullable; + target?: React.HTMLAttributeAnchorTarget; url?: string; }; type ChildCommandPaletteAction = Action & { parent: NotNullable; priority: NotNullable; + target?: React.HTMLAttributeAnchorTarget; url?: string; };