-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Lens] Keep global filters, time range and refresh interval on refresh #68075
Conversation
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.
Tested in Chrome and Safari and LGTM. Found an edge case which we may need to combine with index pattern persistence:
- Create a pinned filter in a Dashboard
- Go to Lens, and you might see that the pinned filter is showing a Warning text label
- Change the Lens index pattern and the warning goes away
I don't expect you to fix this issue in this PR.
await PageObjects.timePicker.setAbsoluteRange( | ||
'Sep 06, 2015 @ 06:31:44.000', | ||
'Sep 18, 2025 @ 06:31:44.000' | ||
); |
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.
I assume it's intentional that this range doesn't overlap with the default time range, but I'm not sure why? We do have a PageObjects.lens.goToTimeRange
helper which wraps this.
const { stop: stopSyncingQueryServiceStateWithUrl } = syncQueryStateWithUrl( | ||
data.query, | ||
kbnUrlStateStorage | ||
); |
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.
I think we need to add some of these dependencies to the useEffect
list explicitly- the linting rule is not currently being required, but should be.
@elasticmachine merge upstream |
@flash1293 could you modify the title and description of PR to include the fact that the refreshInterval is also included? Just for the clarity.
The behaviour is consistent with the rest of visualize so it's a good start in my opinion. Tested on FF, code LGTM. @wylieconlon I checked the edge case you've written down here, but I don't get how it's buggy, it seems like a proper behaviour for me. Could you clarify what's the expected behaviour? |
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
@mbondyra The text "Warning" is caused by a mismatch in the default index pattern vs the index pattern used in the filters. If we want to fix this, the best way is to look at the |
Fixes #61758
This PR uses the same approach as Visualize/Discover/Dashboard to keep the global query context (time range, refresh interval and pinned filters) around even if the page is refreshed or opened in another tab / browser.
As this behavior is difficult to validate via unit test, it adds a functional test suite which also makes sure the context is kept when navigating between apps.
x-pack/plugins/lens/public/app_plugin/app.tsx
contains the main changes.x-pack/plugins/lens/public/app_plugin/app.test.tsx
was only changed to keep existing unit tests working, the behavior is not tested (because the only test I can think of is basically a reverse implementation of the actual code)x-pack/test/functional/apps/lens/persistent_context.ts
contains the functional testsNote: The original issue also states
This is handled by #67689 - if query or non-pinned filters are changed, the user will be stopped from navigating away by modal. With this PR all changes the user did are either persisted in the URL or in the saved object and protected via modal.
Considerations
On this PR changing the time range will write a new history entry, so going back will bring you back to the last time range instead of navigating away from Lens. I'm not sure whether that's expected behavior, but it seems like an improvement over the current state, so I left it in. A thing we should add (if possible) is to prevent the user from losing configuration by using the back button, but it seems like this is out of scope for this PR. For reference: Maps is trapping the user and the back button doesn't work at all (not sure whether that's the right approach).