grafana icon indicating copy to clipboard operation
grafana copied to clipboard

Preserve variables and time range when navigating between dashboards

Open dprokop opened this issue 9 months ago • 1 comments

Available under preserveDashboardStateWhenNavigating feature toggle.

This is a POC of a functionality that will allow preserving currently selected ~filters and group by dimensions~ dashboard variables and time range when navigating between different dashboards. It's an early WIP to gather some opinions.

How it works?

  1. Currently selected variable and time range are captured on DashboardScene deactivation and stored in the local storage under a tab-specific key.
  2. When new dashboard scene is loaded, we read from local storage and replace the location in the browser with the saved query params, so that when the URL sync is activated, the variables will restore preserved values.
  3. When one navigates away from Grafana the preserved filters are cleared.

TODO:

  • [x] Deduplicate query params with the same value to avoid duplicate values in scenarios when someone navigates back and forts between the same dashboard (using browser's back button).
  • [x] On the target dashboard only apply those query params that match variable names - thi I'm not sure if we need this as this is supposed to work as part of the newDashboardWithFiltersAndGroupBy that guarantees the same name of the filters and group by variable across different dashboards.
  • [x] Preserve filters with tab id, so that closing one tab will not cause clearing the filters for other tabs. Or for other tabs not to override filters stored by other tabs.
  • [ ] Add test coverage

dprokop avatar May 16 '24 10:05 dprokop