grafana / scenes

Build Grafana dashboards directly in your Grafana app plugins.
https://grafana.com/developers/scenes
Apache License 2.0
133 stars 20 forks source link

Scenes: Move change panel plugin logic in VizPanel #836

Closed mdvictor closed 2 months ago

mdvictor commented 2 months ago

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:

ivanortegaalba commented 2 months ago

LGTM!

grafanabot commented 2 months ago

:rocket: PR was released in v5.5.0 :rocket: