From d9858e0af95b83a9ede0b5dc94561a6335519b3b Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Thu, 8 Jul 2021 11:07:16 +0200 Subject: [PATCH] Timeseries Panel: Retain alerts when migrating from old graph (#36514) (#36546) Closes #36106 (cherry picked from commit 8d66db09bf359b122615c6109994b03ad9f16cd4) Co-authored-by: kay delaney <45561153+kaydelaney@users.noreply.github.com> --- packages/grafana-data/src/types/panel.ts | 1 + .../timeseries/__snapshots__/migrations.test.ts.snap | 11 +++++++++++ public/app/plugins/panel/timeseries/migrations.ts | 1 + 3 files changed, 13 insertions(+) diff --git a/packages/grafana-data/src/types/panel.ts b/packages/grafana-data/src/types/panel.ts index c0904cf8781..8da91ebe6a2 100644 --- a/packages/grafana-data/src/types/panel.ts +++ b/packages/grafana-data/src/types/panel.ts @@ -124,6 +124,7 @@ export interface PanelEditorProps { export interface PanelModel { /** ID of the panel within the current dashboard */ id: number; + alert?: any; /** Panel options */ options: TOptions; /** Field options configuration */ diff --git a/public/app/plugins/panel/timeseries/__snapshots__/migrations.test.ts.snap b/public/app/plugins/panel/timeseries/__snapshots__/migrations.test.ts.snap index 342cbb434f8..e9d8df90a76 100644 --- a/public/app/plugins/panel/timeseries/__snapshots__/migrations.test.ts.snap +++ b/public/app/plugins/panel/timeseries/__snapshots__/migrations.test.ts.snap @@ -2,6 +2,7 @@ exports[`Graph Migrations legend with multiple values 1`] = ` Object { + "alert": undefined, "fieldConfig": Object { "defaults": Object { "custom": Object { @@ -53,6 +54,7 @@ Object { exports[`Graph Migrations legend with single value 1`] = ` Object { + "alert": undefined, "fieldConfig": Object { "defaults": Object { "custom": Object { @@ -79,6 +81,7 @@ Object { exports[`Graph Migrations legend without values 1`] = ` Object { + "alert": undefined, "fieldConfig": Object { "defaults": Object { "custom": Object { @@ -103,6 +106,7 @@ Object { exports[`Graph Migrations preserves colors from series overrides 1`] = ` Object { + "alert": undefined, "fieldConfig": Object { "defaults": Object { "custom": Object { @@ -157,6 +161,7 @@ Object { exports[`Graph Migrations preserves series overrides using a regex alias 1`] = ` Object { + "alert": undefined, "fieldConfig": Object { "defaults": Object { "custom": Object { @@ -211,6 +216,7 @@ Object { exports[`Graph Migrations simple bars 1`] = ` Object { + "alert": undefined, "fieldConfig": Object { "defaults": Object { "custom": Object { @@ -237,6 +243,7 @@ Object { exports[`Graph Migrations stacking groups 1`] = ` Object { + "alert": undefined, "fieldConfig": Object { "defaults": Object { "custom": Object { @@ -322,6 +329,7 @@ Object { exports[`Graph Migrations stacking simple 1`] = ` Object { + "alert": undefined, "fieldConfig": Object { "defaults": Object { "custom": Object { @@ -377,6 +385,7 @@ Object { exports[`Graph Migrations stairscase 1`] = ` Object { + "alert": undefined, "fieldConfig": Object { "defaults": Object { "custom": Object { @@ -416,6 +425,7 @@ Object { exports[`Graph Migrations stepped line 1`] = ` Object { + "alert": undefined, "fieldConfig": Object { "defaults": Object { "custom": Object { @@ -463,6 +473,7 @@ Object { exports[`Graph Migrations twoYAxis 1`] = ` Object { + "alert": undefined, "fieldConfig": Object { "defaults": Object { "custom": Object { diff --git a/public/app/plugins/panel/timeseries/migrations.ts b/public/app/plugins/panel/timeseries/migrations.ts index 20aca285678..570ea3d0da6 100644 --- a/public/app/plugins/panel/timeseries/migrations.ts +++ b/public/app/plugins/panel/timeseries/migrations.ts @@ -45,6 +45,7 @@ export const graphPanelChangedHandler: PanelTypeChangedHandler = ( fieldConfig: prevFieldConfig, }); panel.fieldConfig = fieldConfig; // Mutates the incoming panel + panel.alert = prevOptions.angular.alert; return options; }