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

GroupByVariable: Sync label to URL #705

Closed bfmatei closed 4 months ago

bfmatei commented 5 months ago

This PR syncs labels of the values in the group by variable similarly to what we introduced for ad-hoc filters.

Unlike ad-hoc filters, group by is a little bit more of a special case hence the reason why some of the changes below. The solution might not be optimal, so please feel free to suggested changes and improvements.

Changes:

The gotcha: let's assume we pass a value via URL. This value is not returned by the datasource hence we consider it a custom value. We then remove the custom value using the UI button. When opening the dropdown again, the custom value can be found in the dropdown. Is this a behavior we want to keep? You can also see this behavior in the demo below.

PS: tests will come in a subsequent push. For the time being I'm trying to decide upon edge cases.

Demo:

https://github.com/grafana/scenes/assets/9215315/54ca86b9-9db9-4ac1-ac8e-144a8cd576f2

📦 Published PR as canary version: 4.20.0--canary.705.9031064372.0
:sparkles: Test out this PR locally via: ```bash npm install @grafana/scenes@4.20.0--canary.705.9031064372.0 # or yarn add @grafana/scenes@4.20.0--canary.705.9031064372.0 ```
grafanabot commented 4 months ago

:rocket: PR was released in v4.20.0 :rocket: