mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
moved migration hook to its own function
This commit is contained in:
@@ -21,13 +21,18 @@ export interface PanelEditorProps<T = any> {
|
||||
onOptionsChange: (options: T) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a panel is first loaded with existing options
|
||||
*/
|
||||
export type PanelMigrationHook<TOptions = any> = (options: Partial<TOptions>) => Partial<TOptions>;
|
||||
|
||||
/**
|
||||
* Called before a panel is initalized
|
||||
*/
|
||||
export type PanelTypeChangedHook<TOptions = any> = (
|
||||
options: Partial<TOptions>,
|
||||
prevPluginId?: string,
|
||||
prevOptions?: any
|
||||
prevPluginId: string,
|
||||
prevOptions: any
|
||||
) => Partial<TOptions>;
|
||||
|
||||
export class ReactPanelPlugin<TOptions = any> {
|
||||
@@ -35,6 +40,7 @@ export class ReactPanelPlugin<TOptions = any> {
|
||||
editor?: ComponentClass<PanelEditorProps<TOptions>>;
|
||||
defaults?: TOptions;
|
||||
|
||||
panelMigrationHook?: PanelMigrationHook<TOptions>;
|
||||
panelTypeChangedHook?: PanelTypeChangedHook<TOptions>;
|
||||
|
||||
constructor(panel: ComponentClass<PanelProps<TOptions>>) {
|
||||
@@ -49,6 +55,13 @@ export class ReactPanelPlugin<TOptions = any> {
|
||||
this.defaults = defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the panel first loaded with
|
||||
*/
|
||||
setPanelMigrationHook(v: PanelMigrationHook<TOptions>) {
|
||||
this.panelMigrationHook = v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the visualization changes.
|
||||
* Lets you keep whatever settings made sense in the previous panel
|
||||
|
||||
Reference in New Issue
Block a user