Migrate from AngularJS to React
If you want to migrate a plugin to Grafana's React-based plugin platform, then we recommend that you release it under a new major version.
While there's no standard migration path from an Angular plugin to the new React platform, weโve learned that one of the easiest ways to migrate is to:
- Create a new branch called
migrate-to-react
. - Start from scratch with one of the templates provided by the
create-plugin
tool. - Move the existing code into the new plugin incrementally, one component at a time.
Migrate a panel pluginโ
Starting with Grafana 7.0, plugins export a PanelPlugin
from module.ts
where MyPanel
is a React component containing the props from PanelProps
.
import { PanelPlugin } from '@grafana/data';
export const plugin = new PanelPlugin<MyOptions>(MyPanel);
import { PanelProps } from '@grafana/data';
interface Props extends PanelProps<SimpleOptions> {}
export function MyPanel({ options, data, width, height }: Props) {
// ...
}
Migrate a data source pluginโ
While all plugins are different, we'd like to share a migration process that has worked for some of our users.
- Define your configuration model and
ConfigEditor
. For many plugins, the configuration editor is the simplest component, so it's a good candidate to start with. - Implement the
testDatasource()
method on the class that extendsDataSourceApi
. Use the settings in your configuration model to make sure that you can successfully configure and access the external API. - Implement the
query()
method. At this point, you can hard-code your query, because we havenโt yet implemented the query editor. Thequery()
method supports both the new data frame response and the oldTimeSeries
response, so donโt worry about converting to the new format just yet. - Implement the
QueryEditor
. How much work this requires depends on how complex your query model is.
By now, you should be able to release your new version.
To fully migrate to the new plugin platform, convert the time series response to a data frame response.
Guidesโ
The following guides will help you perform specific migration actions.
๐๏ธ Migrate from kbn package
How to migrate a plugin that uses the kbn package to current methods.
๐๏ธ Convert value and range maps
How to migrate an Angular plugin that uses value and range maps to React
๐๏ธ Custom configuration components
How to migrate a Grafana plugin from AngularJS with custom fields to React with custom components.
๐๏ธ Migrate configuration settings
How to migrate AngularJS plugin configuration to React.
๐๏ธ Migrate from time_series2 package
How to migrate a plugin that uses the app/core/time_series2 package to current methods.
๐๏ธ Targeting older releases
How to target older releases for a plugin.
๐๏ธ Add a suggestion supplier
How to add a suggestion supplier to a plugin.