-
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
[Saved Object Finder] Move to the component in saved_objects_finder plugin #151764
Conversation
e20d1ae
to
bc34f07
Compare
## Summary This PR is a part of standardizing the `SavedObjectsFinder` component across our codebase. This PR moves the server-side logic from `saved_objects` plugin to `saved_objects_finder` plugin and removes the deprecated `savedObjects.client.find` from the `saved_objects_finder` component. The component in `saved_objects_finder` plugin supports tagging, while the one in `saved_objects` does not. Ideally, we'd move to using that component everywhere. I started working on moving to this component in the follow-up [PR](#151764). ### Checklist Delete any items that are not applicable to this PR. - [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) ~- [] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials~ - [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 ~- [ ] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/))~ ~- [ ] Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))~ ~- [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)~ ~- [ ] 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))~ ~- [ ] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers)~ ### 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) --------- Co-authored-by: kibanamachine <[email protected]>
f47ad16
to
67a8706
Compare
b9b4211
to
39ec7a2
Compare
ae1658e
to
2a64434
Compare
f6855f3
to
c11b0f7
Compare
20649dd
to
0db1f29
Compare
191d856
to
f123ece
Compare
407a6a7
to
1ce60a4
Compare
src/plugins/dashboard/public/dashboard_container/embeddable/api/add_panel_from_library.ts
Outdated
Show resolved
Hide resolved
...ugins/dashboard/public/services/saved_objects_management/saved_objects_management_service.ts
Outdated
Show resolved
Hide resolved
@@ -257,7 +259,7 @@ export class SavedObjectFinderUi extends React.Component< | |||
|
|||
return currentSavedObjectMetaData?.name ?? ''; | |||
}, | |||
'data-test-subj': 'savedObjectFinderType', | |||
'data-test-subj': 'savedObjectFinderFilterButton', |
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.
'data-test-subj': 'savedObjectFinderFilterButton', | |
'data-test-subj': 'savedObjectFinderType', |
As far as I can tell, this selector isn't referenced anywhere else in code anymore. Could we revert it back to the previous data-test-subj
since it makes more sense in the context of this component?
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.
It is referenced in functional tests: https://github.com/elastic/kibana/blob/main/test/examples/embeddables/adding_children.ts#L26
I can change it back, but thought for the sake of minimizing changes to the functional tests, it made more sense to change the dataTestSubj
in the component itself.
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.
It looks like that may have been the only functional that referenced it and it was removed as part of this PR: https://github.com/elastic/kibana/pull/151764/files#diff-efccbf6e6131341694eaf2e5b00ae0160216efdb522c63a5f098ac041312ed08R46-R47.
If I'm missing others though, feel free to disregard. I just couldn't find any other references searching in VS Code.
}; | ||
const response = (await this.props.services.http.get('/internal/saved-objects-finder/find', { | ||
|
||
const { queryText, visibleTypes, selectedTags } = savedObjectsManagement.parseQuery( |
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 don't understand the impact of these changes -- it seems to be the same logic as before but with some of the params
props assigned on separate lines now. Am I missing something here?
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.
Ah, fair point. This is a leftover from when I wanted to make savedObjectsManagement
an optional dependency, so the parameters could have been assigned with or without it. But since now it's a required dependency, will change it 👍
params.search = queryText ? `${queryText}*` : undefined; | ||
params.hasReference = hasReference ? JSON.stringify(hasReference) : undefined; | ||
|
||
const response = (await http.get('/internal/saved-objects-finder/find', { | ||
query: params as Record<string, any>, | ||
})) as FindResponseHTTP<FinderAttributes>; |
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.
As a follow up to my comments on the last PR, could we remove the local FinderAttributes
interface and import from common
instead to avoid the duplicate definition?
@@ -369,6 +371,7 @@ export class SavedObjectFinderUi extends React.Component< | |||
itemId="id" | |||
items={this.state.items} | |||
columns={columns} | |||
data-test-subj="savedObjectsFinder-table" |
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.
data-test-subj="savedObjectsFinder-table" | |
data-test-subj="savedObjectsFinderTable" |
Nit: We don't have to change this if you feel strongly about it, but I just found it a little odd that this is the only test subject in the component that doesn't adhere to the style guide.
savedObjectsTagging?: SavedObjectsTaggingApi | ||
) => { | ||
return (props: SavedObjectFinderProps) => ( | ||
<SavedObjectFinderUi |
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.
<SavedObjectFinderUi | |
<SavedObjectFinder |
Any chance we could use the lazy loaded component here instead to avoid the hit to page load bundles?
@@ -8,6 +8,6 @@ | |||
|
|||
import { SavedObjectsFinderPublicPlugin } from './plugin'; | |||
export type { SavedObjectMetaData, SavedObjectFinderProps } from './finder'; | |||
export { SavedObjectFinder } from './finder'; | |||
export { SavedObjectFinder, SavedObjectFinderUi, getSavedObjectFinder } from './finder'; |
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.
export { SavedObjectFinder, SavedObjectFinderUi, getSavedObjectFinder } from './finder'; | |
export { SavedObjectFinder, getSavedObjectFinder } from './finder'; |
Similar to my other comment about lazy loading, but are we able to just use the lazy loaded component instead of including this export which adds ~4kb to the page load bundle?
src/plugins/dashboard/public/dashboard_container/embeddable/api/add_panel_from_library.ts
Outdated
Show resolved
Hide resolved
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.
kibana-presentation changes LGTM. Thanks for making SavedObjectsFinderService and consolidating all of the logic there.
@@ -257,7 +259,7 @@ export class SavedObjectFinderUi extends React.Component< | |||
|
|||
return currentSavedObjectMetaData?.name ?? ''; | |||
}, | |||
'data-test-subj': 'savedObjectFinderType', | |||
'data-test-subj': 'savedObjectFinderFilterButton', |
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.
It looks like that may have been the only functional that referenced it and it was removed as part of this PR: https://github.com/elastic/kibana/pull/151764/files#diff-efccbf6e6131341694eaf2e5b00ae0160216efdb522c63a5f098ac041312ed08R46-R47.
If I'm missing others though, feel free to disregard. I just couldn't find any other references searching in VS Code.
import type { SavedObjectFinderProps } from './saved_object_finder'; | ||
import SavedObjectFinderUi from './saved_object_finder'; |
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 making this difficult, sorry 😅. It looks like there's still a 4kb bundle increase and I think it's because of this import which is no longer used since we switched to the lazy one for getSavedObjectFinder
. Could we remove this import and its export below and see if that fixes the bundle size increase? If it doesn't fix it, I'll give up and approve anyway -- just want to see if that does it first.
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 should be fine now
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Page load bundle
Unknown metric groupsAPI count
ESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
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.
No more bundle size increase 🙌 Thanks for making those changes! Pulled and tested locally and everything seems to be working as expected, LGTM.
…lugin (elastic#151764) ## Summary This PR replaces the `SavedObjectsFinder` component from `saved_objects` plugin with the one in `saved_objects_finder` plugin. Code changes are pretty straightforward; most of the changes are around modifying the functional tests to work with the selectors from the new component. ### Checklist Delete any items that are not applicable to this PR. ~- [ ] 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)~ ~- [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials~ - [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 ~- [ ] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/))~ ~- [ ] Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))~ ~- [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)~ ~- [ ] 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))~ ~- [ ] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers)~! ### 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) --------- Co-authored-by: kibanamachine <[email protected]>
Summary
This PR replaces the
SavedObjectsFinder
component fromsaved_objects
plugin with the one insaved_objects_finder
plugin. Code changes are pretty straightforward; most of the changes are around modifying the functional tests to work with the selectors from the new component. This is a part of making the component BWCA compliant effortChecklist
Delete any items that are not applicable to this PR.
- [ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support- [ ] Documentation was added for features that require explanation or tutorials- [ ] Any UI touched in this PR is usable by keyboard only (learn more about keyboard accessibility)- [ ] Any UI touched in this PR does not create any new axe failures (run axe in browser: FF, Chrome)- [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the docker list- [ ] This renders correctly on smaller devices using a responsive layout. (You can test this in your browser)- [ ] This was checked for cross-browser compatibility!For maintainers