diff --git a/src/Components/Panels/PanelMenu.tsx b/src/Components/Panels/PanelMenu.tsx index 22cae39f4..96bb7bbd7 100644 --- a/src/Components/Panels/PanelMenu.tsx +++ b/src/Components/Panels/PanelMenu.tsx @@ -18,7 +18,7 @@ import { IndexScene } from '../IndexScene/IndexScene'; import { findObjectOfType, getQueryRunnerFromChildren } from '../../services/scenes'; import { reportAppInteraction, USER_EVENTS_ACTIONS, USER_EVENTS_PAGES } from '../../services/analytics'; import { logger } from '../../services/logger'; -import { AddToExplorationButton } from '../ServiceScene/Breakdowns/AddToExplorationButton'; +import { AddToInvestigationButton } from '../ServiceScene/Breakdowns/AddToInvestigationButton'; import { getPluginLinkExtensions } from '@grafana/runtime'; import { ExtensionPoints } from '../../services/extensions/links'; import { setLevelColorOverrides } from '../../services/panel'; @@ -53,8 +53,8 @@ interface InvestigationOptions { interface PanelMenuState extends SceneObjectState { body?: VizPanelMenu; - addExplorationsLink?: boolean; - explorationsButton?: AddToExplorationButton; + addInvestigationsLink?: boolean; + investigationsButton?: AddToInvestigationButton; panelType?: AvgFieldPanelType; investigationOptions?: InvestigationOptions; @@ -65,7 +65,7 @@ interface PanelMenuState extends SceneObjectState { */ export class PanelMenu extends SceneObjectBase implements VizPanelMenu, SceneObject { constructor(state: Partial) { - super({ ...state, addExplorationsLink: state.addExplorationsLink ?? true }); + super({ ...state, addInvestigationsLink: state.addInvestigationsLink ?? true }); this.addActivationHandler(() => { // Navigation options (all panels) const items: PanelMenuItem[] = [ @@ -96,7 +96,7 @@ export class PanelMenu extends SceneObjectBase implements VizPan } this.setState({ - explorationsButton: new AddToExplorationButton({ + investigationsButton: new AddToInvestigationButton({ labelName: this.state.investigationOptions?.getLabelName ? this.state.investigationOptions?.getLabelName() : this.state.investigationOptions?.labelName, @@ -106,10 +106,10 @@ export class PanelMenu extends SceneObjectBase implements VizPan }), }); - if (this.state.addExplorationsLink) { + if (this.state.addInvestigationsLink) { // @todo rewrite the AddToExplorationButton // Manually activate scene - this.state.explorationsButton?.activate(); + this.state.investigationsButton?.activate(); } // Visualization options @@ -132,8 +132,8 @@ export class PanelMenu extends SceneObjectBase implements VizPan }); this._subs.add( - this.state.explorationsButton?.subscribeToState(() => { - subscribeToAddToExploration(this); + this.state.investigationsButton?.subscribeToState(() => { + subscribeToAddToInvestigation(this); }) ); }); @@ -280,26 +280,26 @@ const onSwitchVizTypeTracking = (newVizType: AvgFieldPanelType) => { }); }; -const getInvestigationLink = (addToExplorations: AddToExplorationButton) => { +const getInvestigationLink = (addToInvestigation: AddToInvestigationButton) => { const links = getPluginLinkExtensions({ - extensionPointId: ExtensionPoints.MetricExploration, - context: addToExplorations.state.context, + extensionPointId: ExtensionPoints.MetricInvestigation, + context: addToInvestigation.state.context, }); return links.extensions[0]; }; -const onAddToInvestigationClick = (event: React.MouseEvent, addToExplorations: AddToExplorationButton) => { - const link = getInvestigationLink(addToExplorations); +const onAddToInvestigationClick = (event: React.MouseEvent, addToInvestigation: AddToInvestigationButton) => { + const link = getInvestigationLink(addToInvestigation); if (link && link.onClick) { link.onClick(event); } }; -function subscribeToAddToExploration(exploreLogsVizPanelMenu: PanelMenu) { - const addToExplorationButton = exploreLogsVizPanelMenu.state.explorationsButton; - if (addToExplorationButton) { - const link = getInvestigationLink(addToExplorationButton); +function subscribeToAddToInvestigation(exploreLogsVizPanelMenu: PanelMenu) { + const addToInvestigationButton = exploreLogsVizPanelMenu.state.investigationsButton; + if (addToInvestigationButton) { + const link = getInvestigationLink(addToInvestigationButton); const existingMenuItems = exploreLogsVizPanelMenu.state.body?.state.items ?? []; @@ -318,7 +318,7 @@ function subscribeToAddToExploration(exploreLogsVizPanelMenu: PanelMenu) { exploreLogsVizPanelMenu.state.body?.addItem({ text: ADD_TO_INVESTIGATION_MENU_TEXT, iconClassName: 'plus-square', - onClick: (e) => onAddToInvestigationClick(e, addToExplorationButton), + onClick: (e) => onAddToInvestigationClick(e, addToInvestigationButton), }); } else { if (existingAddToExplorationLink) { diff --git a/src/Components/ServiceScene/Breakdowns/AddToExplorationButton.tsx b/src/Components/ServiceScene/Breakdowns/AddToInvestigationButton.tsx similarity index 90% rename from src/Components/ServiceScene/Breakdowns/AddToExplorationButton.tsx rename to src/Components/ServiceScene/Breakdowns/AddToInvestigationButton.tsx index a9c9a5351..2405711e7 100644 --- a/src/Components/ServiceScene/Breakdowns/AddToExplorationButton.tsx +++ b/src/Components/ServiceScene/Breakdowns/AddToInvestigationButton.tsx @@ -10,7 +10,7 @@ import { findObjectOfType, getLokiDatasource } from 'services/scenes'; import LokiLogo from '../../../img/logo.svg'; import { LokiDatasource, LokiQuery } from '../../../services/lokiQuery'; -export interface AddToExplorationButtonState extends SceneObjectState { +export interface AddToInvestigationButtonState extends SceneObjectState { frame?: DataFrame; labelName?: string; fieldName?: string; @@ -34,8 +34,8 @@ type ExtensionContext = { drillDownLabel?: string; }; -export class AddToExplorationButton extends SceneObjectBase { - constructor(state: Omit) { +export class AddToInvestigationButton extends SceneObjectBase { + constructor(state: Omit) { super({ ...state, queries: [] }); this.addActivationHandler(this.onActivate); } @@ -98,14 +98,14 @@ export class AddToExplorationButton extends SceneObjectBase) => { + public static Component = ({ model }: SceneComponentProps) => { const { context } = model.useState(); - const { links } = usePluginLinks({ extensionPointId: ExtensionPoints.MetricExploration, context }); + const { links } = usePluginLinks({ extensionPointId: ExtensionPoints.MetricInvestigation, context }); return ( <> {links - .filter((link) => link.pluginId === 'grafana-explorations-app' && link.onClick) + .filter((link) => link.pluginId === 'grafana-investigations-app' && link.onClick) .map((link) => ( { public onActivate() { this.setState({ - menu: new PanelMenu({ addExplorationsLink: false }), + menu: new PanelMenu({ addInvestigationsLink: false }), }); } public static Component = ({ model }: SceneComponentProps) => { diff --git a/src/plugin.json b/src/plugin.json index b7e3b6ffc..0746ddb89 100644 --- a/src/plugin.json +++ b/src/plugin.json @@ -77,7 +77,7 @@ ], "extensionPoints": [ { - "id": "grafana-lokiexplore-app/metric-exploration/v1" + "id": "grafana-lokiexplore-app/investigation/v1" }, { "id": "grafana-lokiexplore-app/toolbar-open-related/v1", diff --git a/src/services/extensions/links.ts b/src/services/extensions/links.ts index f58ccecbe..c271ff3cc 100644 --- a/src/services/extensions/links.ts +++ b/src/services/extensions/links.ts @@ -30,7 +30,7 @@ const description = 'Open current query in the Explore Logs view'; const icon = 'gf-logs'; export const ExtensionPoints = { - MetricExploration: 'grafana-lokiexplore-app/metric-exploration/v1', + MetricInvestigation: 'grafana-lokiexplore-app/investigation/v1', } as const; export type LinkConfigs = Array<