mirror of https://github.com/grafana/grafana.git
Add support for old and new pathfinder IDs
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
This commit is contained in:
parent
a5490b2836
commit
ca9d6f558d
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<Dropdown overlay={() => <TopNavBarMenu node={enrichedHelpNode} />} placement="bottom-end">
|
||||
<ToolbarButton iconOnly icon="question-circle" aria-label={t('navigation.help.aria-label', 'Help')} />
|
||||
|
|
@ -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',
|
||||
})
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue