-
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
[Discover] Address reverting unsaved changes issue to unpin filters #172063
[Discover] Address reverting unsaved changes issue to unpin filters #172063
Conversation
|
||
savedSearch.searchSource | ||
.setField('query', state.query ?? undefined) | ||
.setField('filter', [...appFilters, ...globalFilters]); | ||
.setField('filter', [...appFilters, ...cleanedGlobalFilters]); |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
src/plugins/discover/public/application/main/services/discover_saved_search_container.ts
Outdated
Show resolved
Hide resolved
…_saved_search_container.ts
src/plugins/discover/public/application/main/services/discover_saved_search_container.ts
Outdated
Show resolved
Hide resolved
…_saved_search_container.ts
@@ -52,7 +52,7 @@ export function updateSavedSearch({ | |||
|
|||
savedSearch.searchSource | |||
.setField('query', state.query ?? undefined) | |||
.setField('filter', [...appFilters, ...globalFilters]); | |||
.setField('filter', [...globalFilters, ...appFilters]); |
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.
In UI pinned filters are rendered first, then app filters. So we better pass them to Elasticsearch in the same order.
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.
Following up about this topic, I just wanted to add some information, because it seems the order of query / filters doesn't matter from ES side, according to https://www.elastic.co/de/blog/elasticsearch-query-execution-order
Q: Does the order in which I put my queries/filters in the query DSL matter?
A: No, because they will be automatically reordered anyway based on their respective costs and match costs.
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.
Thanks, @kertal! Then it's just helpful for the diffing logic.
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
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.
The code changes look good and it works as described in the summary, but I'm not sure I understand why a change in filter order should trigger the unsaved changes badge if it doesn't impact the request?
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.
Thanks for adding to serverless too!
It's not a change for the request but it is a visual change in the UI. There could be another case when user adds a filter and disables it right away - also it would not impact the request but it's a change nevertheless. So I would rather show the badge then and let the user to revert modifications. |
I can understand the thinking here, and maybe this is more in line with most user's expectations, but as a user I found it difficult to understand why sometimes pinning a filter would trigger unsaved changes and other times not. To phrase it better, I think more importantly than if it affects the request would be if it affects the saved state of the current saved search. The pinned states and order of filters don't, but a disabled filter would, which is why I view these situations differently. Since @bhavyarm reported the issue, maybe we could get some feedback on what you think would make more sense for users? Pinning/unpinning filters doesn't affect the saved search state, but it will sometimes change the visual order of the filters in the UI. Do you think it makes sense to show the unsaved changes badge only when a pinning/unpinning action changes the visual order of filters, or do you think it would be better to always ignore pinning/unpinning since it doesn't affect the underlying state? We can also quickly validate with the team tomorrow in our sync. If others agree that the visual order change should trigger the badge, I'm happy to move forward with merging this. |
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: cc @jughosta |
I think it can be still worth merging as the PR provides an improvement and fixes the "Revert" action. We could revisit whether the filters order should trigger the badge or not later based on users feedback. |
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 it can be still worth merging as the PR provides an improvement and fixes the "Revert" action. We could revisit whether the filters order should trigger the badge or not later based on users feedback.
I agree 👍 We discussed this as a team, and while I think it would be ideal if filter order didn't matter, there are some technical constraints that make this more difficult, so I think this is fine for now. It solves the more significant issue of the revert not working, and we can revisit later if needed. LGTM, thanks!
…lastic#172063) - Closes elastic#172025 ## Summary This PR changes filters diffing logic for the "Unsaved changes" badge and fixes "Revert changes" action of it. What to expect when testing: - If user pins a filter and the order of filters does not change, then the badge should not appear. - If user has 2 filters for example and pins the second one, then this action would change filters order and the badge would appear. - If user presses "Revert changes" action, then newly pinned filters would become unpinned. ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios (cherry picked from commit c89c990)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…lters (#172063) (#172999) # Backport This will backport the following commits from `main` to `8.12`: - [[Discover] Address reverting unsaved changes issue to unpin filters (#172063)](#172063) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Julia Rechkunova","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-12-08T21:45:31Z","message":"[Discover] Address reverting unsaved changes issue to unpin filters (#172063)\n\n- Closes https://github.com/elastic/kibana/issues/172025\r\n\r\n## Summary\r\n\r\nThis PR changes filters diffing logic for the \"Unsaved changes\" badge\r\nand fixes \"Revert changes\" action of it. What to expect when testing:\r\n\r\n- If user pins a filter and the order of filters does not change, then\r\nthe badge should not appear.\r\n- If user has 2 filters for example and pins the second one, then this\r\naction would change filters order and the badge would appear.\r\n- If user presses \"Revert changes\" action, then newly pinned filters\r\nwould become unpinned.\r\n\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"c89c990f30ea1e01bc29438aa48995fa2477119c","branchLabelMapping":{"^v8.13.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Discover","release_note:skip","Team:DataDiscovery","backport:prev-minor","v8.13.0"],"number":172063,"url":"https://github.com/elastic/kibana/pull/172063","mergeCommit":{"message":"[Discover] Address reverting unsaved changes issue to unpin filters (#172063)\n\n- Closes https://github.com/elastic/kibana/issues/172025\r\n\r\n## Summary\r\n\r\nThis PR changes filters diffing logic for the \"Unsaved changes\" badge\r\nand fixes \"Revert changes\" action of it. What to expect when testing:\r\n\r\n- If user pins a filter and the order of filters does not change, then\r\nthe badge should not appear.\r\n- If user has 2 filters for example and pins the second one, then this\r\naction would change filters order and the badge would appear.\r\n- If user presses \"Revert changes\" action, then newly pinned filters\r\nwould become unpinned.\r\n\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"c89c990f30ea1e01bc29438aa48995fa2477119c"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.13.0","labelRegex":"^v8.13.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/172063","number":172063,"mergeCommit":{"message":"[Discover] Address reverting unsaved changes issue to unpin filters (#172063)\n\n- Closes https://github.com/elastic/kibana/issues/172025\r\n\r\n## Summary\r\n\r\nThis PR changes filters diffing logic for the \"Unsaved changes\" badge\r\nand fixes \"Revert changes\" action of it. What to expect when testing:\r\n\r\n- If user pins a filter and the order of filters does not change, then\r\nthe badge should not appear.\r\n- If user has 2 filters for example and pins the second one, then this\r\naction would change filters order and the badge would appear.\r\n- If user presses \"Revert changes\" action, then newly pinned filters\r\nwould become unpinned.\r\n\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"c89c990f30ea1e01bc29438aa48995fa2477119c"}}]}] BACKPORT--> Co-authored-by: Julia Rechkunova <[email protected]>
@davismcphee I am so sorry I missed your ping here. Thanks very much :) I read through the comments and the fix looks good to me. Thanks @jughosta. |
Summary
This PR changes filters diffing logic for the "Unsaved changes" badge and fixes "Revert changes" action of it. What to expect when testing:
Checklist