grafana/public/app/plugins/panel/canvas/migrations.ts
Drew Slobodnjak 82d7f80a15
Canvas: Rename textbox to rectangle (#55633)
Co-authored-by: nmarrs <nathanielmarrs@gmail.com>
2022-09-30 10:44:47 -07:00

23 lines
604 B
TypeScript

import { PanelModel } from '@grafana/data';
import { PanelOptions } from './models.gen';
export const canvasMigrationHandler = (panel: PanelModel): Partial<PanelOptions> => {
const pluginVersion = panel?.pluginVersion ?? '';
// Rename text-box to rectangle
// Initial plugin version is empty string for first migration
if (pluginVersion === '') {
const root = panel.options?.root;
if (root?.elements) {
for (const element of root.elements) {
if (element.type === 'text-box') {
element.type = 'rectangle';
}
}
}
}
return panel.options;
};