From 8ee1fb55e786c8e8bd4e4675e917f77ec6947484 Mon Sep 17 00:00:00 2001 From: kozhuhds Date: Thu, 30 Oct 2025 11:51:45 +0100 Subject: [PATCH] fix: helpers in dynamic command palette api --- .../actions/useDynamicExtensionActions.ts | 43 ++++++++++++++++--- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/public/app/features/commandPalette/actions/useDynamicExtensionActions.ts b/public/app/features/commandPalette/actions/useDynamicExtensionActions.ts index ab3a4a24c65..d9fa36c1864 100644 --- a/public/app/features/commandPalette/actions/useDynamicExtensionActions.ts +++ b/public/app/features/commandPalette/actions/useDynamicExtensionActions.ts @@ -6,8 +6,15 @@ import { CommandPaletteDynamicResultAction, PluginExtensionCommandPaletteContext, } from '@grafana/data'; +import appEvents from 'app/core/app_events'; +import { + CloseExtensionSidebarEvent, + OpenExtensionSidebarEvent, + ToggleExtensionSidebarEvent, +} from 'app/types/events'; import { commandPaletteDynamicRegistry } from '../../plugins/extensions/registry/setup'; +import { createOpenModalFunction } from '../../plugins/extensions/utils'; import { CommandPaletteAction } from '../types'; import { EXTENSIONS_PRIORITY } from '../values'; @@ -107,17 +114,39 @@ export function useDynamicExtensionActions(searchQuery: string): { keywords: result.keywords?.join(' '), perform: () => { if (result.onSelect) { + const extensionPointId = 'grafana/commandpalette/action'; result.onSelect(result, { context: { searchQuery: debouncedSearchQuery }, - extensionPointId: 'grafana/commandpalette/action', - openModal: () => { - console.warn('openModal: Full implementation requires createOpenModalFunction from extensions/utils'); + extensionPointId, + openModal: createOpenModalFunction({ + pluginId: result.pluginId, + title: result.title, + description: result.description, + extensionPointId, + path: result.path, + category: result.section, + }), + openSidebar: (componentTitle, context) => { + appEvents.publish( + new OpenExtensionSidebarEvent({ + props: context, + pluginId: result.pluginId, + componentTitle, + }) + ); }, - openSidebar: () => { - console.warn('openSidebar: Available but marked as internal API'); + closeSidebar: () => { + appEvents.publish(new CloseExtensionSidebarEvent()); + }, + toggleSidebar: (componentTitle, context) => { + appEvents.publish( + new ToggleExtensionSidebarEvent({ + props: context, + pluginId: result.pluginId, + componentTitle, + }) + ); }, - closeSidebar: () => {}, - toggleSidebar: () => {}, }); } },