PanelPlugin: Add shouldMigrate callback to setMigrationHandler() (#103710)
This commit is contained in:
@@ -113,6 +113,7 @@ export class PanelPlugin<
|
||||
panel: ComponentType<PanelProps<TOptions>> | null;
|
||||
editor?: ComponentClass<PanelEditorProps<TOptions>>;
|
||||
onPanelMigration?: PanelMigrationHandler<TOptions>;
|
||||
shouldMigrate?: (panel: ComponentType<PanelProps<TOptions>> | null) => boolean;
|
||||
onPanelTypeChanged?: PanelTypeChangedHandler<TOptions>;
|
||||
noPadding?: boolean;
|
||||
dataSupport: PanelPluginDataSupport = {
|
||||
@@ -201,10 +202,18 @@ export class PanelPlugin<
|
||||
* This function is called before the panel first loads if
|
||||
* the current version is different than the version that was saved.
|
||||
*
|
||||
* If shouldMigrate is provided, it will be called regardless of whether
|
||||
* the version has changed, and can explicitly opt into running the
|
||||
* migration handler
|
||||
*
|
||||
* This is a good place to support any changes to the options model
|
||||
*/
|
||||
setMigrationHandler(handler: PanelMigrationHandler<TOptions>) {
|
||||
setMigrationHandler(
|
||||
handler: PanelMigrationHandler<TOptions>,
|
||||
shouldMigrate?: (panel: ComponentType<PanelProps<TOptions>> | null) => boolean
|
||||
) {
|
||||
this.onPanelMigration = handler;
|
||||
this.shouldMigrate = shouldMigrate;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user