-
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
[Embeddable Rebuild] [Saved Search] Migrate saved search embeddable to new embeddable framework #180536
[Embeddable Rebuild] [Saved Search] Migrate saved search embeddable to new embeddable framework #180536
Conversation
575a44b
to
e58fe5a
Compare
/ci |
1 similar comment
/ci |
7f18c4c
to
15a0544
Compare
d74f53a
to
0b3fc47
Compare
…er/kibana into refactor-saved-search_2024-04-05
…er/kibana into refactor-saved-search_2024-04-05
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 addressing the feedback! I tested basically all combinations of saved searches I could think of including data view, ad hoc data view, ES|QL, by ref/value, etc. and it seems to be working great 👍 I noticed a few minor bugs, but they all seem to be in main
too so I'll make separate issues for those. There were just two things I noticed that might need to be addressed before I think it's good to merge:
- When I add a by ref search panel in
main
, the panel title/description sync to the saved search when modified in Discover unless I've manually changed the panel title/description. In this PR the panel title/description don't seem to sync with the saved search at all. Should it still behave how it does inmain
or is this working as intended? - When I unlink a search panel from the library in
main
, it keeps all of the SO properties and passes them to Discover when clicking the edit dropdown link. In this PR it looks like some of the properties are dropped when unlinking, so clicking edit doesn't carry over some state like the breakdown field. I feel like it might be best to keep all of the state if possible in case we decide to use it in the embeddable in the future.
src/plugins/discover/public/embeddable/initialize_search_embeddable_api.tsx
Show resolved
Hide resolved
src/plugins/discover/public/embeddable/get_search_embeddable_factory.tsx
Show resolved
Hide resolved
src/plugins/discover/public/embeddable/get_search_embeddable_factory.test.tsx
Show resolved
Hide resolved
Looks like this is a bug with all by-reference React embeddables, not just saved searches (I just tested with Maps and I am seeing similar behaviour) - would it be okay if we fix this in a follow up, since it is technically unrelated to this PR? I've created an issue here. Our plan is to solve this in a more generic way so we don't see this bug popup in the future.
Interesting - I removed the |
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]Module Count
Public APIs missing comments
Async chunks
Public APIs missing exports
Page load bundle
Unknown metric groupsAPI count
ESLint disabled line counts
References to deprecated APIs
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: cc @Heenawter |
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.
Looks like this is a bug with all by-reference React embeddables, not just saved searches (I just tested with Maps and I am seeing similar behaviour) - would it be okay if we fix this in a follow up, since it is technically unrelated to this PR?
Yes sounds great, thanks!
Interesting - I removed the
breakdownField
in 72c6f7c because @jughosta noted that it wasn't used for the embeddable. Do we want to keep state around even if the embeddable doesn't use it?
Hmm I agree that we don't need the breakdown field as part of the embeddable runtime state since it's not currently used by the embeddable, but I would expect unlinking a panel from the library to clone and persist the linked SO in its entirety, not just the runtime state the embeddable uses. That way all of the properties would be there if the embeddable is later updated to use them, plus actions like "Open in Discover" would include all search properties, which can be useful when starting a Discover investigation from a Dashboard panel (similarly save & return functionality wouldn't result in lost state if an embeddable doesn't use it directly).
Maybe this is different from how the Presentation team thinks about it, but it felt unexpected to me when testing. That said, I don't think it's a major issue and agree it doesn't need to block this PR. I'll add it to #188550 for us to look into as a followup.
And in that case this LGTM, thanks for all the work on it! I know it was a huge task and we greatly appreciate it 🙏 I'm approving now, but I just have one more tiny request if possible before merging 😅 It looks like the Discover page load bundle increased 20% from this PR. Is there a way we could knock this down some before merging, maybe with dynamic imports? We try our best to keep the page load bundle as small as possible when we can.
Sorry yeah, this is 100% something we are aware of. The This is definitely something on our mind (since all React embeddables are dealing with this), so stay tuned for changes here - but unfortunately will have to merge this PR as-is because that will be a larger discussion with the team 🙈 Hopefully that is okay!! cc @nreese |
@Heenawter No problem! Thanks for the explanation and glad to hear it's on your radar already 🙂 |
## Summary This PR is a follow up to #180536, where `8.8KB` was added to the Discover bundle size - now, after async importing from the `presentation-publishing` package where necessary, I've reduced that increase to `3.4KB` (a decrease of `5.4KB` from the previous PR). ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
…189717) - Follow up for #180536 ## Summary This PR fixes an issue with `rowsPerPage` Advanced Setting: after the refactoring it was ignored. To test: Change `rowsPerPage` on Advanced Setting page, navigate to Dashboard and add a saved search panel. It should use the configured value by default. The default value can be overwritten by custom panel settings or saved search own settings. ### 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
Closes #174959
Summary
This PR converts the Saved Search embeddable to the new React embeddable framework. There should not be any changes in user-facing behaviour (except for the intentional change described here) - therefore, testing of this PR should be focused on ensuring that no behaviour is changed and/or broken with this refactor.
Warning
The saved search embeddable takes many forms and so, while I tried my best to test everything thoroughly, it is very, very likely that I missed some test cases due to not being the expert in this area. It is important that @elastic/kibana-data-discovery in particular approaches this PR review with a fine-tooth comb 🙇 Thanks so much.
Notes about the embeddable state:
As part of this refactor, I made three significant changes to how the state is managed:
Once the embeddable is being built in
buildEmbeddable
, the only difference between the runtime state of a by reference and a by value panel is that the by reference one will have three saved object-specific keys:savedObjectId
,savedObjectDescription
, andsavedObjectTitle
.Number 1 made it possible for me to "flatten out" the runtime state of the embeddable by removing the
attributes
key, which makes it easier to access the pieces of state that you need.Previously, the
savedSearch
element of the Saved Search embeddable object was never modified; instead, changes made to the columns, sort, sample size, etc. from the dashboard were stored inexplicitInput
. This essentially created two sources of truth.With the new embeddable system, we only ever want one source of truth - so, the saved search is now modified directly when making changes from the dashboard. However, in order to keep behaviour consistent with the old embeddable, changes made from the dashboard to a by reference saved search should not modify the underlying saved object (this behaviour will have to change if we ever want inline editing for saved searches, but that is another discussion) - therefore, when serializing the runtime state (which happens when the dashboard is saved), we only serialize state that has changed from the initial state; then, on deserialization, we take this "changed" state and overwrite the state of the saved search with it.
Note that this only applies to by reference saved searches - with by value saved searches, we don't have to worry about this and can freely modify the state.
I also had to make changes to how the search source is stored in runtime state. Previously, when initializing the embeddable, fetching the saved search saved object also created and returned an unserializable search source object. However, in the new system, runtime state most always be serializable (see #186052) - therefore, I've had to instead use the serialized search source in my runtime state saved search - therefore, I've had to make changes to
toSavedSearch
method to allow for a serializable saved search to be returned.input
) beforeChecklist
For maintainers