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

SceneTimeRange: Allow time range refresh on activation #835

Closed gtk-grafana closed 2 months ago

gtk-grafana commented 2 months ago

Add optional state to SceneTimeRange allowing invalidation and refresh of time range using percent or absolute interval.

Adds optional invalidateAfterMs and invalidateAfterPercent state props to SceneTimeRangeState. If set, on activation we will check to see if enough time has elapsed to meet either criteria. If both values are set in the time range, the shortest duration value will be used.

The values can be set together, or independently. Providing both allows the scenes developer to specify a minimum elapsed interval before the time range is refreshed, which would be helpful when users are looking at very long durations (e.g. weeks), but update more often when users are looking at very short durations (minutes).

10% and 5m seem to be reasonable: 5 minute interval will refresh after 30s 15minute interval will refresh after 1.5 minutes 30 minute interval will refresh after 3 minutes 1 hour intervals and greater will refresh after 5 minutes

📦 Published PR as canary version: 5.6.1--canary.835.10040331799.0
:sparkles: Test out this PR locally via: ```bash npm install @grafana/scenes-react@5.6.1--canary.835.10040331799.0 npm install @grafana/scenes@5.6.1--canary.835.10040331799.0 # or yarn add @grafana/scenes-react@5.6.1--canary.835.10040331799.0 yarn add @grafana/scenes@5.6.1--canary.835.10040331799.0 ```
gtk-grafana commented 2 months ago

I'd like to get this rolled out to Explore Logs if/when approved, do we typically include a version bump in the feature PR, or open a separate PR to bump the version?

grafanabot commented 2 months ago

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