-
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] Last used Index pattern is saved to and retrieved from local storage #69511
Conversation
ce8fcd0
to
d8ae93a
Compare
Pinging @elastic/kibana-app (Team:KibanaApp) |
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.
Changes LGTM!
@@ -287,10 +300,51 @@ describe('loader', () => { | |||
}); | |||
}); | |||
|
|||
it('should load a default state when lastUsedIndexPatternId is not found in indexPatternRefs', async () => { |
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.
Will it also write back to localStorage overwriting the missing index pattern?
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.
Good idea! I'll add it.
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.
Actually, that made me think
- (scenario you mentioned) lastUsedIndexPatternId is not found in kibana - we write back to localStorage overwriting the missing index pattern
- (second scenario) we open saved visualization - should we also write back to localStorage? I think so 🤔 -for now we only do it on index pattern change
28545f0
to
3b71699
Compare
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 and LGTM once green - I like the current behavior because If I'm not mistaken it follows this logic:
When opening Lens, show the index pattern which was visible the last time Lens was used, except if it doesn't make sense for the opened visualization.
Looks just right to me, this is what I would expect.
Edit: Just thought about one case where this rule is broken: Create a Lens vis with a layer using pattern "a" and a layer using pattern "b". Create a new Lens vis with "b" visible. Then exit and open the first saved Lens vis again - "a" will be visible initially because it's the first one in the list of the saved object, and the "last used" logic only kicks in if there is no state. I don't think we have to consider this special case, just wanted to mention it. Still LGTM :)
💚 Build SucceededBuild metricspage load asset sizebeta
History
To update your PR or re-run it, just comment with: |
Summary
When opening the saved object, the first index pattern from the is the active one. It is set as the
indexPatternId
in local storage.When opening the new lens vis:
2.1. If the last used index pattern is found in local storage and it still exists in kibana, it is set as active.
2.2. If the last used index pattern is found in storage but doesn't exist in kibana, the default one is set as active. The default one is set as the
indexPatternId
in local storage.2.3. If there's no index pattern in storage, the default one is set as active. The default one is set as the
indexPatternId
in local storage.When changing the index pattern in layer or in datasource panel, it is set as the
indexPatternId
in local storage.Fixes #61757
Checklist