mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 10:03:33 -06:00
23 lines
604 B
TypeScript
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;
|
|
};
|