Skip to content
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

Merged
merged 38 commits into from Nov 13, 2023

Conversation

jughosta
Copy link
Contributor

@jughosta jughosta commented Oct 23, 2023

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.

Screenshot 2023-10-23 at 18 05 34

Oct-23-2023 18-06-39

Checklist

@jughosta jughosta added release_note:enhancement Feature:Discover Discover Application backport:skip This commit does not require backporting Team:DataDiscovery Discover App Team (Document Explorer, Saved Search, Surrounding documents, Graph) labels Oct 23, 2023
@jughosta jughosta self-assigned this Oct 23, 2023
@jughosta jughosta marked this pull request as ready for review October 25, 2023 09:30
@jughosta jughosta requested review from a team as code owners October 25, 2023 09:30
Copy link
Contributor

@tonyghiani tonyghiani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log_explorer changes LGTM

Copy link
Contributor

@davismcphee davismcphee left a 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

@jughosta
Copy link
Contributor Author

@davismcphee

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.

I made some updates to address it. Could you please set window.ELASTIC_DISCOVER_LOGGER = 'debug' when testing? This should help to catch other instances of this problem.

Copy link
Contributor

@davismcphee davismcphee left a 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),
Copy link
Contributor

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) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const hasChangesInSavedSearch = [...keys].some((key: string) => {
const hasChangesInSavedSearch = [...keys].some((key) => {

No need to type as string if we type keys.

@jughosta
Copy link
Contributor Author

jughosta commented Nov 1, 2023

@elasticmachine merge upstream

@jughosta jughosta enabled auto-merge (squash) November 1, 2023 12:56
auto-merge was automatically disabled November 7, 2023 05:06

Merge queue setting changed

@jughosta jughosta requested a review from a team as a code owner November 13, 2023 09:08
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
discover 701 705 +4

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/unsaved-changes-badge - 9 +9
discover 87 89 +2
navigation 34 35 +1
total +12

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
cloudSecurityPosture 402.7KB 402.7KB +28.0B
discover 587.1KB 590.1KB +3.0KB
total +3.0KB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
discover 18 20 +2

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
logExplorer 38.3KB 38.4KB +50.0B
navigation 11.8KB 11.8KB +53.0B
total +103.0B
Unknown metric groups

API count

id before after diff
@kbn/unsaved-changes-badge - 13 +13
discover 130 132 +2
navigation 34 35 +1
total +16

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @jughosta

@jughosta jughosta merged commit 145cc8f into elastic:main Nov 13, 2023
28 checks passed
jillguyonnet pushed a commit to jillguyonnet/kibana that referenced this pull request Nov 16, 2023
…d search (elastic#169548)

- Resolves elastic#135887

## 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`.

<img width="600" alt="Screenshot 2023-10-23 at 18 05 34"
src="https://github.com/elastic/kibana/assets/1415710/ad200a28-79e1-4cc5-8e28-6352d4b85322">

![Oct-23-2023
18-06-39](https://github.com/elastic/kibana/assets/1415710/cacf4ff2-525c-4759-aba9-34ce75089ddd)


### Checklist

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [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
- [x] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Discover Discover Application release_note:enhancement Team:DataDiscovery Discover App Team (Document Explorer, Saved Search, Surrounding documents, Graph) v8.12.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Discover] Show "unsaved changes" label when in unsaved state of saved search
8 participants