-
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
[Visualize] Make linked saved search work when user navigates back using browser back button #59690
Conversation
searchSourceParent.getField('filter') | ||
); | ||
searchSource.setField('index', searchSourceParent.getField('index')); | ||
searchSource.setField('index', currentIndex); |
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'm still not sure, whether we should inherit the index of the parent source while unlinking,
since both the searchSource index
and searchSourceParent index
are equal always. At least, I didn't find a case, when they could be different.
Maybe it's a question to @ppisljar
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.
if you create visualization based on saved search, then searchsource won't have index field, but the parent will.
calling searchSource.getField('index') will of course show the correct index (as that walks up the tree)
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.
Code LGTM, tested locally in chrome, fixes the issue of navigation with the back button 👍 thx for having a look for small details 🔍 🕵
@@ -379,6 +380,18 @@ function VisualizeAppController( | |||
}, | |||
}; | |||
|
|||
const handleLinkedSearch = linked => { | |||
if (linked && !savedVis.savedSearchId) { |
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.
this confuses me ... you desctructure savedSearchId
from savedVis
... so this logic is actually:
if (linked && !savedVis.savdSearchId) {
savedVis.savedSearchId = savedVis.savedSearchId;
vis.savedSearchId = savedVis.savedSearchId;
...
}
also i am not sure why we need to duplicate information on vis.savedSearchId
, which is also violating the types (vis has no savedSearchId property)
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 once you unlink, all we need is to delete savedVis.savedSearchId (for the sake of saved object) and remove the parent search source (for the sake of current view)
and when linking back, you will need to select the saved search, so you get the new savedSearchId and you can set it on savedVis
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.
ps: i am working on a small refactor to vis saved object and vis state, which will allow to further clean this up: you will no longer need to care about savedVis here, all you will need to do is remove parent search source and we will provide utilities to serialize searchSource + vis into the saved vis object.
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.
Hey @ppisljar , thanks for taking a look and reasonable comments here!
PR updated!
About storing the vis.savedSearchId
, I'm not sure why, but it's presented in the vis
object on creation of a visualization based on saved search:
so would be great if you could get rid of it in your refactoring pr.
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.
code LGTM
@ppisljar FYI |
@elasticmachine merge upstream |
* Fix linked search behavior * Revert relying on savedSearchId in url * Fix comments * Return back savedSearchId into vis object Co-authored-by: Elastic Machine <[email protected]>
* Fix linked search behavior * Revert relying on savedSearchId in url * Fix comments * Return back savedSearchId into vis object Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
* master: (45 commits) skip flaky suite (elastic#59717) UI Metrics use findAll to retrieve all Saved Objects (elastic#59891) [Discover] Migrate Context mocha tests to use Jest (elastic#59658) [Maps] Move redux reducers and store logic to NP (elastic#58294) rebalance x-pack groups (elastic#58930) [Discover] Reimplement $route.reload when index pattern changes (elastic#59877) [Upgrade Assistant Meta] Breaking changes issue template (elastic#59745) Skip CI based on changes in PR (elastic#59939) [ML] Transforms: Replace KqlFilterBar with QueryStringInput. (elastic#59723) [ML] Functional tests - stabilize date_nanos test (elastic#59986) [ML] Typescripting client side endpoint functions (elastic#59928) a11y tests on adding columns to discover table (elastic#59375) fix graph plugin config path (elastic#59540) fix vega config issues (elastic#59737) [Upgrade Assistant] Open And Close Slight Refactor (elastic#59890) [ML] Adding shared services to ml setup contract (elastic#59730) [Visualize] Fix linked search behavior (elastic#59690) [ML] Register NP ML plugin for Kibana management section. (elastic#59762) [Lens] Adds using queries/filters for field existence endpoint (elastic#59033) Delete FilterStateManager and QueryFilter :-D (elastic#59872) ...
💔 Build FailedTest FailuresKibana Pipeline / kibana-oss-agent / Chrome UI Functional Tests.test/functional/apps/discover/_errors·js.discover app errors invalid scripted field error is renderedStandard Out
Stack Trace
Kibana Pipeline / kibana-intake-agent / Jest Integration Tests.packages/kbn-plugin-generator/integration_tests.running the plugin-generator via 'node scripts/generate_plugin.js plugin-name' with default config then running with es instance 'yarn start' should result in the spec plugin being initialized on kibana's stdoutStandard Out
Stack Trace
Kibana Pipeline / kibana-oss-agent / Chrome UI Functional Tests.test/functional/apps/discover/_errors·js.discover app errors invalid scripted field error is renderedStandard Out
Stack Trace
History
To update your PR or re-run it, just comment with: |
Summary
Fixes #57977
This PR fixes the behavior of
linked
/unlinked
saved search while playing with browser history in visualize.The first intention was to rely on
savedSearchId
query parameter in the url:And it was working fine, before I found out, that the saved visualization doesn't have the same url and looks like:
So the previous approach (rely on
linked
param in the appState -_a
piece of url) was saved,but improved handling on browser
back
,forward
,reload
actions. That means you could unlink from the saved search, then go back in history - the state will becomelinked
again, then you could unlink it again with button as usualChecklist
Delete any items that are not applicable to this PR.
For maintainers