From 97037580dfbafc176b95e019bfe4d41f896c2602 Mon Sep 17 00:00:00 2001 From: Dominik Prokop Date: Mon, 14 Oct 2024 09:17:37 +0200 Subject: [PATCH] PanelMenu: Allow showing panel menu when data source does not exist (#94545) --- .../trails/Integrations/dashboardIntegration.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/public/app/features/trails/Integrations/dashboardIntegration.ts b/public/app/features/trails/Integrations/dashboardIntegration.ts index ea2a34ea91f..4ff039f377b 100644 --- a/public/app/features/trails/Integrations/dashboardIntegration.ts +++ b/public/app/features/trails/Integrations/dashboardIntegration.ts @@ -1,4 +1,4 @@ -import { PanelMenuItem } from '@grafana/data'; +import { DataSourceApi, PanelMenuItem } from '@grafana/data'; import { PromQuery } from '@grafana/prometheus'; import { getDataSourceSrv } from '@grafana/runtime'; import { SceneTimeRangeState, VizPanel } from '@grafana/scenes'; @@ -34,7 +34,13 @@ export async function addDataTrailPanelAction(dashboard: DashboardScene, panel: return; } - const dataSourceApi = await getDataSourceSrv().get(datasource); + let dataSourceApi: DataSourceApi | undefined; + + try { + dataSourceApi = await getDataSourceSrv().get(datasource); + } catch (e) { + return; + } if (dataSourceApi.interpolateVariablesInQueries == null) { return;