From e3367ccf9a08600b866f90a112e314d9c0217c8e Mon Sep 17 00:00:00 2001 From: "grafana-delivery-bot[bot]" <132647405+grafana-delivery-bot[bot]@users.noreply.github.com> Date: Thu, 21 Nov 2024 13:32:12 +0100 Subject: [PATCH] [v11.3.x] Scenes: Fix angular migrations that are using the targets property on the old panel model (#96831) Scenes: Fix angular migrations that are using the targets property on the old panel model (#96626) Fix angular migrations using target (cherry picked from commit 5986b03a8fc64ae9eaef708894e6fa5f168dfb80) Co-authored-by: Oscar Kilhed --- .../serialization/angularMigration.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/public/app/features/dashboard-scene/serialization/angularMigration.ts b/public/app/features/dashboard-scene/serialization/angularMigration.ts index d92f13cb1ed..606cf8545e4 100644 --- a/public/app/features/dashboard-scene/serialization/angularMigration.ts +++ b/public/app/features/dashboard-scene/serialization/angularMigration.ts @@ -1,4 +1,4 @@ -import { defaults } from 'lodash'; +import { defaults, cloneDeep } from 'lodash'; import { PanelModel as PanelModelFromData, PanelPlugin } from '@grafana/data'; import { autoMigrateAngular, PanelModel } from 'app/features/dashboard/state/PanelModel'; @@ -12,6 +12,17 @@ export function getAngularPanelMigrationHandler(oldModel: PanelModel) { if (!oldModel.options || Object.keys(oldModel.options).length === 0) { defaults(panel, oldModel.getOptionsToRemember()); + + // Some plugins rely on being able to access targets to set up the fieldConfig when migrating from angular. + const targetClone = cloneDeep(oldModel.targets); + Object.defineProperty(panel, 'targets', { + get: function () { + console.warn( + 'Accessing the targets property when migrating a panel plugin is deprecated. Changes to this property will be ignored.' + ); + return targetClone; + }, + }); } if (oldModel.autoMigrateFrom) {