From a2795f129138f050548215f1560c18eaab16c325 Mon Sep 17 00:00:00 2001 From: Darren Janeczek <38694490+darrenjaneczek@users.noreply.github.com> Date: Fri, 22 Mar 2024 10:05:03 -0400 Subject: [PATCH] datatrails: fix: only show datatrails link for timeseries dashboard panels (#84942) fix: only show datatrails link for timeseries dashboard panels --- .../trails/Integrations/dashboardIntegration.ts | 13 ++++++++++++- public/app/features/trails/Integrations/utils.ts | 7 +++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/public/app/features/trails/Integrations/dashboardIntegration.ts b/public/app/features/trails/Integrations/dashboardIntegration.ts index 09a8227d290..a378758683d 100644 --- a/public/app/features/trails/Integrations/dashboardIntegration.ts +++ b/public/app/features/trails/Integrations/dashboardIntegration.ts @@ -12,13 +12,24 @@ import { MetricScene } from '../MetricScene'; import { DataTrailEmbedded, DataTrailEmbeddedState } from './DataTrailEmbedded'; import { SceneDrawerAsScene, launchSceneDrawerInGlobalModal } from './SceneDrawer'; import { QueryMetric, getQueryMetrics } from './getQueryMetrics'; -import { createAdHocFilters, getQueryMetricLabel, getQueryRunner, getTimeRangeFromDashboard } from './utils'; +import { + createAdHocFilters, + getPanelType, + getQueryMetricLabel, + getQueryRunner, + getTimeRangeFromDashboard, +} from './utils'; export function addDataTrailPanelAction( dashboard: DashboardScene | DashboardModel, panel: VizPanel | PanelModel, items: PanelMenuItem[] ) { + const panelType = getPanelType(panel); + if (panelType !== 'timeseries') { + return; + } + const queryRunner = getQueryRunner(panel); if (!queryRunner) { return; diff --git a/public/app/features/trails/Integrations/utils.ts b/public/app/features/trails/Integrations/utils.ts index e6f518283d5..f5faf434c02 100644 --- a/public/app/features/trails/Integrations/utils.ts +++ b/public/app/features/trails/Integrations/utils.ts @@ -43,3 +43,10 @@ export function getQueryMetricLabel({ metric, labelFilters }: QueryMetric) { export function createAdHocFilters(labels: QueryBuilderLabelFilter[]) { return labels?.map((label) => ({ key: label.label, value: label.value, operator: label.op })); } + +export function getPanelType(panel: VizPanel | PanelModel) { + if (panel instanceof VizPanel) { + return panel.state.pluginId; + } + return panel.type; +}