Files
grafana/public/app/plugins/panel/table/migrations.ts
T

33 lines
1019 B
TypeScript

import { PanelModel } from '@grafana/data';
import { Options } from './types';
/**
* At 7.0, the `table` panel was swapped from an angular implementation to a react one.
* The models do not match, so this process will delegate to the old implementation when
* a saved table configuration exists.
*/
export const tableMigrationHandler = (panel: PanelModel<Options>): Partial<Options> => {
// Table was saved as an angular table, lets just swap to the 'table-old' panel
if (!panel.pluginVersion && (panel as any).columns) {
console.log('Was angular table', panel);
}
// Nothing changed
return panel.options;
};
/**
* This is called when the panel changes from another panel
*/
export const tablePanelChangedHandler = (
panel: PanelModel<Partial<Options>> | any,
prevPluginId: string,
prevOptions: any
) => {
// Changing from angular singlestat
if (prevPluginId === 'table-old' && prevOptions.angular) {
console.log('Migrating from angular table', panel);
}
return prevOptions;
};