This PR moves panel plugin logic from grafana, from VizPanelManager (related PR ) into the VizPanel. This is needed because the VizPanel is aware of when the plugin is updated and we need the new plugin to fetch default configs, to be able to merge existing options/fieldConfigs, if they exist, with default ones.
This also changes things a bit in the sense that we no longed create a new VizPanel but reuse the existing one by updating it's state with the updated options/fieldConfigs. In the changePluginType function we receive overwrite options and fieldConfigs which represent, in the context of core Grafana, configs that are cached when switching panels in panel edit. These configurations, if present, are passed to the VizPanel to properly set both existing configs and default panel plugin configs after loading the new plugin. If we do not have any cached configs then we will load the new panel with default values.
TODO:
[x] Add a demo here for dynamically changing a plugin panel.
📦 Published PR as canary version: 5.5.0--canary.836.9987320115.0
:sparkles: Test out this PR locally via:
```bash
npm install @grafana/scenes-react@5.5.0--canary.836.9987320115.0
npm install @grafana/scenes@5.5.0--canary.836.9987320115.0
# or
yarn add @grafana/scenes-react@5.5.0--canary.836.9987320115.0
yarn add @grafana/scenes@5.5.0--canary.836.9987320115.0
```
This PR moves panel plugin logic from grafana, from
VizPanelManager
(related PR ) into theVizPanel
. This is needed because theVizPanel
is aware of when the plugin is updated and we need the new plugin to fetch default configs, to be able to merge existing options/fieldConfigs, if they exist, with default ones.This also changes things a bit in the sense that we no longed create a new
VizPanel
but reuse the existing one by updating it's state with the updated options/fieldConfigs. In thechangePluginType
function we receive overwrite options and fieldConfigs which represent, in the context of core Grafana, configs that are cached when switching panels in panel edit. These configurations, if present, are passed to the VizPanel to properly set both existing configs and default panel plugin configs after loading the new plugin. If we do not have any cached configs then we will load the new panel with default values.TODO:
[x] Add a demo here for dynamically changing a plugin panel.
📦 Published PR as canary version:
5.5.0--canary.836.9987320115.0
:sparkles: Test out this PR locally via: ```bash npm install @grafana/scenes-react@5.5.0--canary.836.9987320115.0 npm install @grafana/scenes@5.5.0--canary.836.9987320115.0 # or yarn add @grafana/scenes-react@5.5.0--canary.836.9987320115.0 yarn add @grafana/scenes@5.5.0--canary.836.9987320115.0 ```