From 199f772bcfd6b4fdbe3daae9782d0999fff62f8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 1 Jul 2020 08:52:49 +0200 Subject: [PATCH] StatPanel: Add migration for singlestat tableColumn to to fields property (#25901) --- .../SingleStatShared/SingleStatBaseOptions.test.ts | 12 ++++++++++++ .../SingleStatShared/SingleStatBaseOptions.ts | 6 +++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/grafana-ui/src/components/SingleStatShared/SingleStatBaseOptions.test.ts b/packages/grafana-ui/src/components/SingleStatShared/SingleStatBaseOptions.test.ts index 72a4afc10ae..084712e90c4 100644 --- a/packages/grafana-ui/src/components/SingleStatShared/SingleStatBaseOptions.test.ts +++ b/packages/grafana-ui/src/components/SingleStatShared/SingleStatBaseOptions.test.ts @@ -198,6 +198,18 @@ describe('sharedSingleStatMigrationHandler', () => { expect(panel.fieldConfig.defaults.max).toBe(undefined); }); + it('change from angular singlestat with tableColumn set', () => { + const old: any = { + angular: { + tableColumn: 'info', + }, + }; + const panel = {} as PanelModel; + const newOptions = sharedSingleStatPanelChangedHandler(panel, 'singlestat', old); + expect(newOptions.reduceOptions.calcs).toEqual(['mean']); + expect(newOptions.reduceOptions.fields).toBe('/^info$/'); + }); + it('change from angular singlestat with no enabled gauge', () => { const old: any = { angular: { diff --git a/packages/grafana-ui/src/components/SingleStatShared/SingleStatBaseOptions.ts b/packages/grafana-ui/src/components/SingleStatShared/SingleStatBaseOptions.ts index 296f236f636..9f1382bd58f 100644 --- a/packages/grafana-ui/src/components/SingleStatShared/SingleStatBaseOptions.ts +++ b/packages/grafana-ui/src/components/SingleStatShared/SingleStatBaseOptions.ts @@ -55,7 +55,7 @@ function migrateFromAngularSinglestat(panel: PanelModel