keep plugin versions

This commit is contained in:
ryan
2019-03-22 13:45:09 -07:00
parent 82be27a42a
commit 6da2f132c7
4 changed files with 29 additions and 10 deletions

View File

@@ -1,6 +1,7 @@
import React, { PureComponent } from 'react';
import config from 'app/core/config';
import classNames from 'classnames';
import get from 'lodash/get';
import { getAngularLoader, AngularComponent } from 'app/core/services/AngularLoader';
import { importPluginModule } from 'app/features/plugins/plugin_loader';
@@ -99,12 +100,13 @@ export class DashboardPanel extends PureComponent<Props, State> {
panel.changeType(pluginId, hook);
}
} else if (plugin.exports && plugin.exports.reactPanel && panel.options) {
const pluginVersion = get(plugin, 'info.version') || config.buildInfo.version;
const hook = plugin.exports.reactPanel.onPanelMigration;
if (hook) {
panel.options = hook(panel.options);
if (hook && panel.pluginVersion !== pluginVersion) {
panel.options = hook(panel.options, panel.pluginVersion);
panel.pluginVersion = pluginVersion;
}
}
this.setState({ plugin, angularPanel: null });
}
}