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

[Saved Object Finder] Move to the component in saved_objects_finder plugin #151764

Merged
merged 37 commits into from
Mar 1, 2023

Conversation

majagrubic
Copy link
Contributor

@majagrubic majagrubic commented Feb 21, 2023

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. This is a part of making the component BWCA compliant effort

Checklist

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

  • Unit or functional tests 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)
    - [ ] 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

majagrubic pushed a commit that referenced this pull request Feb 22, 2023
## 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]>
@majagrubic majagrubic marked this pull request as ready for review February 25, 2023 14:19
@majagrubic majagrubic requested review from a team as code owners February 25, 2023 14:19
@botelastic botelastic bot added the Feature:Embedding Embedding content via iFrame label Feb 27, 2023
@@ -257,7 +259,7 @@ export class SavedObjectFinderUi extends React.Component<

return currentSavedObjectMetaData?.name ?? '';
},
'data-test-subj': 'savedObjectFinderType',
'data-test-subj': 'savedObjectFinderFilterButton',
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
'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?

Copy link
Contributor Author

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.

Copy link
Contributor

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(
Copy link
Contributor

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?

Copy link
Contributor Author

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>;
Copy link
Contributor

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"
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
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
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
<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';
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
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?

Copy link
Contributor

@nreese nreese left a 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',
Copy link
Contributor

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';
Copy link
Contributor

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.

Copy link
Contributor Author

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

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
dashboard 376 377 +1

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
embeddable 430 431 +1
savedObjectsFinder 39 44 +5
total +6

Async chunks

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

id before after diff
canvas 1.0MB 1.0MB +119.0B
dashboard 385.3KB 385.5KB +188.0B
savedObjectsFinder 4.9KB 4.9KB -35.0B
total +272.0B

Page load bundle

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

id before after diff
canvas 13.3KB 13.3KB +6.0B
dashboard 26.3KB 26.4KB +148.0B
embeddable 74.6KB 74.7KB +190.0B
savedObjectsFinder 3.1KB 3.3KB +227.0B
total +571.0B
Unknown metric groups

API count

id before after diff
embeddable 532 533 +1
savedObjectsFinder 39 44 +5
total +6

ESLint disabled line counts

id before after diff
securitySolution 428 430 +2

Total ESLint disabled count

id before after diff
securitySolution 506 508 +2

History

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

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.

No more bundle size increase 🙌 Thanks for making those changes! Pulled and tested locally and everything seems to be working as expected, LGTM.

@majagrubic majagrubic merged commit d4abfa2 into elastic:main Mar 1, 2023
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Mar 1, 2023
@majagrubic majagrubic deleted the so-finder-3 branch March 1, 2023 21:33
bmorelli25 pushed a commit to bmorelli25/kibana that referenced this pull request Mar 10, 2023
…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]>
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:Embedding Embedding content via iFrame release_note:skip Skip the PR/issue when compiling release notes v8.8.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants