-
Notifications
You must be signed in to change notification settings - Fork 11.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserve variables and time range when navigating between dashboards #87966
Conversation
public/app/features/dashboard-scene/serialization/transformSaveModelToScene.ts
Outdated
Show resolved
Hide resolved
public/app/features/dashboard-scene/serialization/transformSaveModelToScene.ts
Outdated
Show resolved
Hide resolved
public/app/features/dashboard-scene/pages/DashboardScenePageStateManager.ts
Outdated
Show resolved
Hide resolved
@torkelo @ashharrison90 - i still need to implement tests, but this should be ready for approach review and testing. Available under |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! some minor refactoring that could simplify and reduce the string/url manipulation, and missing tests but otherwise this looks really good.
An interesting thing to discuss with @thanos-karachalios and @Ijin08 would be how users could opt in to this when moving between specific dashboards (ctrl+click or something, or maybe an icon in the dashboard search or dashboard links)
public/app/features/dashboard-scene/pages/DashboardScenePageStateManager.ts
Outdated
Show resolved
Hide resolved
if (!scene.state.uid) { | ||
return; | ||
} | ||
const variables = scene.state.$variables?.state.variables; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason not using UrlSyncManager.getUrlState(scene) here? (I know it might have more state you don't care about but we can filter that out either before save or when we try to use it)
public/app/features/dashboard-scene/pages/DashboardScenePageStateManager.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
behaviour-wise looks great 🙌
just a couple of structure suggestions that i think will help make this cleaner
public/app/features/dashboard-scene/pages/DashboardScenePageStateManager.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great job on this 👏👏👏
just some minor nits
public/app/features/dashboard-scene/utils/dashboardSceneGraph.ts
Outdated
Show resolved
Hide resolved
public/app/features/dashboard-scene/utils/dashboardSessionState.ts
Outdated
Show resolved
Hide resolved
public/app/features/dashboard-scene/utils/dashboardSessionState.ts
Outdated
Show resolved
Hide resolved
public/app/features/dashboard-scene/utils/dashboardSessionState.ts
Outdated
Show resolved
Hide resolved
const variables = scene.state.$variables?.state.variables; | ||
const timeRange = scene.state.$timeRange; | ||
|
||
let urlStates: UrlQueryMap = variables |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still not sure why we are not using UrlSyncManager.getUrlState(scene) here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it's better to opt-in for params to sync, rather than removing items from the full state (may include setting, panel edit, view panel id etc...).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dprokop but instead of removing state you don't care about just include from & to and all that start with var-
, that is basically the same as the code here but much smaller and less complex
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just pushed 👍
Available under
preserveDashboardStateWhenNavigating
feature toggle.This is a POC of a functionality that will allow preserving currently selected
filters and group by dimensionsdashboard variables and time range when navigating between different dashboards. It's an early WIP to gather some opinions.How it works?
TODO:
newDashboardWithFiltersAndGroupBy
that guarantees the same name of the filters and group by variable across different dashboards.