-
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] Show "unsaved changes" label when in unsaved state of saved search #169548
[Discover] Show "unsaved changes" label when in unsaved state of saved search #169548
Conversation
… into 135887-discover-unsaved-changes
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 changes look great (thanks for using RTL for new tests 🙌), and it's working well overall! I think there are some improvements we could make as followups, like maybe directly saving the search when clicking the "Save" button, but we don't need to add more to this PR and I think it's working great as an initial implementation.
The only issue I encountered other than a stuck popover was that I somehow got the search into a state where the changes had to be reverted twice in order for the badge to disappear. I couldn't reproduce it consistently, but it seemed to happen after I made changes to most of the state and then switched data views:
revert.mp4
...ges/kbn-unsaved-changes-badge/src/components/unsaved_changes_badge/unsaved_changes_badge.tsx
Outdated
Show resolved
Hide resolved
src/plugins/discover/public/application/main/services/discover_saved_search_container.ts
Outdated
Show resolved
Hide resolved
src/plugins/discover/public/application/main/utils/update_saved_search.ts
Outdated
Show resolved
Hide resolved
I made some updates to address it. Could you please set |
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.
With the latest changes I can no longer reproduce the issue I was seeing, and I didn't encounter any other issues while testing. Great job on this, and it's a significant improvement over the reset button! LGTM 👍
@@ -246,26 +247,65 @@ export function isEqualSavedSearch(savedSearchPrev: SavedSearch, savedSearchNext | |||
...Object.keys(prevSavedSearch), |
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.
GitHub updated their comment component and apparently broke multiline suggestions so I can't add it as a suggestion, but could we type keys
so that we can drop all the @ts-expect-error
comments below?
const keys = new Set([
...Object.keys(prevSavedSearch),
...Object.keys(nextSavedSearchWithoutSearchSource),
] as Array<keyof Omit<SavedSearch, 'searchSource'>>);
const savedSearchDiff = [...keys].filter((key: string) => { | ||
|
||
// at least one change in saved search attributes | ||
const hasChangesInSavedSearch = [...keys].some((key: string) => { |
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.
const hasChangesInSavedSearch = [...keys].some((key: string) => { | |
const hasChangesInSavedSearch = [...keys].some((key) => { |
No need to type as string
if we type keys
.
@elasticmachine merge upstream |
Merge queue setting changed
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Public APIs missing exports
Page load bundle
Unknown metric groupsAPI count
History
To update your PR or re-run it, just comment with: cc @jughosta |
- Closes #184379 ## Summary This PR brings back the logic which was edited in #169548 This should allow to reset the saved breakdown field with rather an empty string as `undefined` seems to be ignored. ### 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
…c#184668) - Closes elastic#184379 ## Summary This PR brings back the logic which was edited in elastic#169548 This should allow to reset the saved breakdown field with rather an empty string as `undefined` seems to be ignored. ### 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 132ab34)
…184668) (#184998) # Backport This will backport the following commits from `main` to `8.14`: - [[Discover] Fix resetting of breakdown field in a saved search (#184668)](#184668) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Julia Rechkunova","email":"julia.rechkunova@elastic.co"},"sourceCommit":{"committedDate":"2024-06-07T11:29:16Z","message":"[Discover] Fix resetting of breakdown field in a saved search (#184668)\n\n- Closes https://github.com/elastic/kibana/issues/184379\r\n\r\n## Summary\r\n\r\nThis PR brings back the logic which was edited in\r\nhttps://github.com//pull/169548 This should allow to reset\r\nthe saved breakdown field with rather an empty string as `undefined`\r\nseems to be ignored.\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":"132ab34ba54fbc6d119bc1e31d3838cd72493082","branchLabelMapping":{"^v8.15.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Discover","release_note:fix","Team:DataDiscovery","backport:prev-minor","v8.15.0"],"title":"[Discover] Fix resetting of breakdown field in a saved search","number":184668,"url":"https://github.com/elastic/kibana/pull/184668","mergeCommit":{"message":"[Discover] Fix resetting of breakdown field in a saved search (#184668)\n\n- Closes https://github.com/elastic/kibana/issues/184379\r\n\r\n## Summary\r\n\r\nThis PR brings back the logic which was edited in\r\nhttps://github.com//pull/169548 This should allow to reset\r\nthe saved breakdown field with rather an empty string as `undefined`\r\nseems to be ignored.\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":"132ab34ba54fbc6d119bc1e31d3838cd72493082"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.15.0","branchLabelMappingKey":"^v8.15.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/184668","number":184668,"mergeCommit":{"message":"[Discover] Fix resetting of breakdown field in a saved search (#184668)\n\n- Closes https://github.com/elastic/kibana/issues/184379\r\n\r\n## Summary\r\n\r\nThis PR brings back the logic which was edited in\r\nhttps://github.com//pull/169548 This should allow to reset\r\nthe saved breakdown field with rather an empty string as `undefined`\r\nseems to be ignored.\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":"132ab34ba54fbc6d119bc1e31d3838cd72493082"}}]}] BACKPORT--> Co-authored-by: Julia Rechkunova <julia.rechkunova@elastic.co>
Summary
This PR adds "Unsaved changes" badge to Discover for modified saved searches. It also removes "Reset search" button from the histogram area. Code for the badge is added to a new package
@kbn/unsaved-changes-badge
.Checklist