diff --git a/public/app/plugins/panel/table/__snapshots__/migrations.test.ts.snap b/public/app/plugins/panel/table/__snapshots__/migrations.test.ts.snap index 965c68b5c56..e51e742e7d5 100644 --- a/public/app/plugins/panel/table/__snapshots__/migrations.test.ts.snap +++ b/public/app/plugins/panel/table/__snapshots__/migrations.test.ts.snap @@ -1,142 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Table Migrations migrates styles to field config overrides and defaults 1`] = ` -{ - "fieldConfig": { - "defaults": { - "custom": { - "align": "right", - "displayMode": undefined, - }, - "decimals": 2, - "displayName": "", - "unit": "short", - }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "Time", - }, - "properties": [ - { - "id": "displayName", - "value": "Time", - }, - { - "id": "unit", - "value": "time: YYYY-MM-DD HH:mm:ss", - }, - { - "id": "custom.align", - "value": null, - }, - ], - }, - { - "matcher": { - "id": "byName", - "options": "ColorCell", - }, - "properties": [ - { - "id": "unit", - "value": "currencyUSD", - }, - { - "id": "decimals", - "value": 2, - }, - { - "id": "custom.displayMode", - "value": "color-background", - }, - { - "id": "custom.align", - "value": "left", - }, - { - "id": "thresholds", - "value": { - "mode": "absolute", - "steps": [ - { - "color": "rgba(245, 54, 54, 0.9)", - "value": -Infinity, - }, - { - "color": "rgba(237, 129, 40, 0.89)", - "value": 5, - }, - { - "color": "rgba(50, 172, 45, 0.97)", - "value": 10, - }, - ], - }, - }, - ], - }, - { - "matcher": { - "id": "byName", - "options": "ColorValue", - }, - "properties": [ - { - "id": "unit", - "value": "Bps", - }, - { - "id": "decimals", - "value": 2, - }, - { - "id": "links", - "value": [ - { - "targetBlank": true, - "title": "", - "url": "http://www.grafana.com", - }, - ], - }, - { - "id": "custom.displayMode", - "value": "color-text", - }, - { - "id": "custom.align", - "value": null, - }, - { - "id": "thresholds", - "value": { - "mode": "absolute", - "steps": [ - { - "color": "rgba(245, 54, 54, 0.9)", - "value": -Infinity, - }, - { - "color": "rgba(237, 129, 40, 0.89)", - "value": 5, - }, - { - "color": "rgba(50, 172, 45, 0.97)", - "value": 10, - }, - ], - }, - }, - ], - }, - ], - }, - "transformations": [], -} -`; - exports[`Table Migrations migrates transform out to core transforms 1`] = ` { "fieldConfig": { diff --git a/public/app/plugins/panel/table/migrations.test.ts b/public/app/plugins/panel/table/migrations.test.ts index 587d7907a7b..81b3286a6c3 100644 --- a/public/app/plugins/panel/table/migrations.test.ts +++ b/public/app/plugins/panel/table/migrations.test.ts @@ -128,6 +128,144 @@ describe('Table Migrations', () => { }; const panel = {} as PanelModel; tablePanelChangedHandler(panel, 'table-old', oldStyles); - expect(panel).toMatchSnapshot(); + expect(panel).toMatchInlineSnapshot(` + { + "fieldConfig": { + "defaults": { + "custom": { + "align": "right", + }, + "decimals": 2, + "displayName": "", + "unit": "short", + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Time", + }, + "properties": [ + { + "id": "displayName", + "value": "Time", + }, + { + "id": "unit", + "value": "time: YYYY-MM-DD HH:mm:ss", + }, + { + "id": "custom.align", + "value": null, + }, + ], + }, + { + "matcher": { + "id": "byName", + "options": "ColorCell", + }, + "properties": [ + { + "id": "unit", + "value": "currencyUSD", + }, + { + "id": "decimals", + "value": 2, + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background", + }, + }, + { + "id": "custom.align", + "value": "left", + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "rgba(245, 54, 54, 0.9)", + "value": -Infinity, + }, + { + "color": "rgba(237, 129, 40, 0.89)", + "value": 5, + }, + { + "color": "rgba(50, 172, 45, 0.97)", + "value": 10, + }, + ], + }, + }, + ], + }, + { + "matcher": { + "id": "byName", + "options": "ColorValue", + }, + "properties": [ + { + "id": "unit", + "value": "Bps", + }, + { + "id": "decimals", + "value": 2, + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "", + "url": "http://www.grafana.com", + }, + ], + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-text", + }, + }, + { + "id": "custom.align", + "value": null, + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "rgba(245, 54, 54, 0.9)", + "value": -Infinity, + }, + { + "color": "rgba(237, 129, 40, 0.89)", + "value": 5, + }, + { + "color": "rgba(50, 172, 45, 0.97)", + "value": 10, + }, + ], + }, + }, + ], + }, + ], + }, + "transformations": [], + } + `); }); }); diff --git a/public/app/plugins/panel/table/migrations.ts b/public/app/plugins/panel/table/migrations.ts index 2a32ffb8795..926a4907ab4 100644 --- a/public/app/plugins/panel/table/migrations.ts +++ b/public/app/plugins/panel/table/migrations.ts @@ -163,8 +163,10 @@ const migrateTableStyleToOverride = (style: Style) => { if (style.colorMode) { override.properties.push({ - id: 'custom.displayMode', - value: colorModeMap[style.colorMode], + id: 'custom.cellOptions', + value: { + type: colorModeMap[style.colorMode], + }, }); } @@ -200,11 +202,11 @@ const migrateDefaults = (prevDefaults: Style) => { displayName: prevDefaults.alias, custom: { align: prevDefaults.align === 'auto' ? null : prevDefaults.align, - displayMode: colorModeMap[prevDefaults.colorMode], }, }, isNil ); + if (prevDefaults.thresholds.length) { const thresholds: ThresholdsConfig = { mode: ThresholdsMode.Absolute, @@ -212,6 +214,12 @@ const migrateDefaults = (prevDefaults: Style) => { }; defaults.thresholds = thresholds; } + + if (prevDefaults.colorMode) { + defaults.custom.cellOptions = { + type: colorModeMap[prevDefaults.colorMode], + }; + } } return defaults; };