[v9.5.x] Table Panel: Fix panel migration for options cell type (#66406)

Table Panel: Fix panel migration for options cell type (#66305)

(cherry picked from commit b83627a661)

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
This commit is contained in:
Grot (@grafanabot)
2023-04-12 20:00:11 +03:00
committed by GitHub
co-authored by Ryan McKinley
parent 522598d650
commit c52f932025
2 changed files with 10 additions and 10 deletions
@@ -3,6 +3,7 @@ import { each, map } from 'lodash';
import { DataLinkBuiltInVars, MappingType } from '@grafana/data';
import { getPanelPlugin } from '@grafana/data/test/__mocks__/pluginMocks';
import { setDataSourceSrv } from '@grafana/runtime';
import { FieldConfigSource } from '@grafana/schema';
import { config } from 'app/core/config';
import { GRID_CELL_HEIGHT, GRID_CELL_VMARGIN } from 'app/core/constants';
import { mockDataSource, MockDataSourceSrv } from 'app/features/alerting/unified/mocks';
@@ -2196,8 +2197,7 @@ describe('when migrating table cell display mode to cell options', () => {
inspect: false,
},
},
overrides: [],
},
} as unknown as FieldConfigSource, // missing overrides
},
// @ts-expect-error
{
@@ -825,14 +825,14 @@ export class DashboardMigrator {
}
// Update any overrides referencing the cell display mode
for (let i = 0; i < panel.fieldConfig.overrides.length; i++) {
for (let j = 0; j < panel.fieldConfig.overrides[i].properties.length; j++) {
let overrideDisplayMode = panel.fieldConfig.overrides[i].properties[j].value;
if (panel.fieldConfig.overrides[i].properties[j].id === 'custom.displayMode') {
panel.fieldConfig.overrides[i].properties[j].id = 'custom.cellOptions';
panel.fieldConfig.overrides[i].properties[j].value =
migrateTableDisplayModeToCellOptions(overrideDisplayMode);
if (panel.fieldConfig?.overrides) {
for (const override of panel.fieldConfig.overrides) {
for (let j = 0; j < override.properties?.length ?? 0; j++) {
let overrideDisplayMode = override.properties[j].value;
if (override.properties[j].id === 'custom.displayMode') {
override.properties[j].id = 'custom.cellOptions';
override.properties[j].value = migrateTableDisplayModeToCellOptions(overrideDisplayMode);
}
}
}
}