From ca9d6f558d1d18564a2ce92467945953a048e422 Mon Sep 17 00:00:00 2001 From: Jack Baldry Date: Wed, 8 Oct 2025 15:12:51 +0100 Subject: [PATCH] Add support for old and new pathfinder IDs Signed-off-by: Jack Baldry --- pkg/services/navtree/navtreeimpl/navtree.go | 7 +++++-- .../ExtensionSidebar/ExtensionSidebarProvider.tsx | 15 +++++++++++++++ .../ExtensionSidebar/ExtensionToolbarItem.tsx | 14 +++++++------- .../AppChrome/TopBar/HelpTopBarButton.tsx | 9 ++++++--- 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/pkg/services/navtree/navtreeimpl/navtree.go b/pkg/services/navtree/navtreeimpl/navtree.go index 6bca3f4d31e..08853afa2bf 100644 --- a/pkg/services/navtree/navtreeimpl/navtree.go +++ b/pkg/services/navtree/navtreeimpl/navtree.go @@ -260,8 +260,11 @@ func (s *ServiceImpl) addHelpLinks(treeRoot *navtree.NavTreeRoot, c *contextmode treeRoot.AddSection(helpNode) ctx := c.Req.Context() - _, grafanaPathfinderInstalled := s.pluginStore.Plugin(ctx, "grafana-grafanadocsplugin-app") - if grafanaPathfinderInstalled { + // The docs plugin ID is going to transition from grafana-grafanadocsplugin-app to grafana-pathfinder-app. + // Support both until that migration is complete. + _, oldPathfinderInstalled := s.pluginStore.Plugin(ctx, "grafana-grafanadocsplugin-app") + _, newPathfinderInstalled := s.pluginStore.Plugin(ctx, "grafana-pathfinder-app") + if oldPathfinderInstalled || newPathfinderInstalled { // Add a custom property to indicate this should open Grafana Pathfinder. helpNode.HideFromTabs = true } diff --git a/public/app/core/components/AppChrome/ExtensionSidebar/ExtensionSidebarProvider.tsx b/public/app/core/components/AppChrome/ExtensionSidebar/ExtensionSidebarProvider.tsx index 28b8a8378bb..9dcb1cf1edb 100644 --- a/public/app/core/components/AppChrome/ExtensionSidebar/ExtensionSidebarProvider.tsx +++ b/public/app/core/components/AppChrome/ExtensionSidebar/ExtensionSidebarProvider.tsx @@ -252,3 +252,18 @@ export function getComponentMetaFromComponentId( return undefined; } } + +// The docs plugin ID is going to transition from grafana-grafanadocsplugin-app to grafana-pathfinder-app. +// Support both until that migration is complete. +// Prioritize the new plugin ID (grafana-pathfinder-app). +export function getPathfinderPluginId(availableComponents: ExtensionPointPluginMeta): string | undefined { + if (availableComponents.has('grafana-pathfinder-app')) { + return 'grafana-pathfinder-app'; + } + + if (availableComponents.has('grafana-grafanadocsplugin-app')) { + return 'grafana-grafanadocsplugin-app'; + } + + return undefined; +} diff --git a/public/app/core/components/AppChrome/ExtensionSidebar/ExtensionToolbarItem.tsx b/public/app/core/components/AppChrome/ExtensionSidebar/ExtensionToolbarItem.tsx index cd6d3d53e9c..cee522a2e85 100644 --- a/public/app/core/components/AppChrome/ExtensionSidebar/ExtensionToolbarItem.tsx +++ b/public/app/core/components/AppChrome/ExtensionSidebar/ExtensionToolbarItem.tsx @@ -17,17 +17,17 @@ type Props = { }; const compactAllowedComponents = ['grafana-assistant-app']; +const pathfinderPluginIds = ['grafana-pathfinder-app', 'grafana-grafanadocsplugin-app']; export function ExtensionToolbarItem({ compact }: Props) { const { availableComponents, dockedComponentId, setDockedComponentId } = useExtensionSidebarContext(); - if (availableComponents.size === 0) { - return null; - } - - // Don't render the toolbar if the only available plugin is Grafana Pathfinder. + // Don't render the toolbar if the only available plugins are Grafana Pathfinder. // It's opened by the help menu. - if (availableComponents.size === 1 && availableComponents.has('grafana-grafanadocsplugin-app')) { + const nonPathfinderPlugins = Array.from(availableComponents.keys()).filter( + (pluginId) => !pathfinderPluginIds.includes(pluginId) + ); + if (nonPathfinderPlugins.length === 0) { return null; } @@ -36,7 +36,7 @@ export function ExtensionToolbarItem({ compact }: Props) { const renderPluginButton = (pluginId: string, components: ComponentWithPluginId[]) => { // Don't render the Grafana Pathfinder button. // It's opened by the help menu button. - if (pluginId === 'grafana-grafanadocsplugin-app') { + if (pathfinderPluginIds.includes(pluginId)) { return null; } diff --git a/public/app/core/components/AppChrome/TopBar/HelpTopBarButton.tsx b/public/app/core/components/AppChrome/TopBar/HelpTopBarButton.tsx index 633226ec2ec..aca5ff92a20 100644 --- a/public/app/core/components/AppChrome/TopBar/HelpTopBarButton.tsx +++ b/public/app/core/components/AppChrome/TopBar/HelpTopBarButton.tsx @@ -10,6 +10,7 @@ import { OpenExtensionSidebarEvent } from 'app/types/events'; import { useExtensionSidebarContext, getComponentIdFromComponentMeta, + getPathfinderPluginId, } from '../ExtensionSidebar/ExtensionSidebarProvider'; import { TopNavBarMenu } from './TopNavBarMenu'; @@ -28,7 +29,9 @@ export const HelpTopBarButton = memo(function HelpTopBarButton({ isSmallScreen } return null; } - if (isSmallScreen || !enrichedHelpNode.hideFromTabs || !availableComponents.has('grafana-grafanadocsplugin-app')) { + const pathfinderPluginId = getPathfinderPluginId(availableComponents); + + if (isSmallScreen || !enrichedHelpNode.hideFromTabs || pathfinderPluginId === undefined) { return ( } placement="bottom-end"> @@ -36,7 +39,7 @@ export const HelpTopBarButton = memo(function HelpTopBarButton({ isSmallScreen } ); } - const componentId = getComponentIdFromComponentMeta('grafana-grafanadocsplugin-app', 'Grafana Pathfinder'); + const componentId = getComponentIdFromComponentMeta(pathfinderPluginId, 'Grafana Pathfinder'); const isOpen = dockedComponentId === componentId; return ( @@ -52,7 +55,7 @@ export const HelpTopBarButton = memo(function HelpTopBarButton({ isSmallScreen } const appEvents = getAppEvents(); appEvents.publish( new OpenExtensionSidebarEvent({ - pluginId: 'grafana-grafanadocsplugin-app', + pluginId: pathfinderPluginId, componentTitle: 'Grafana Pathfinder', }) );