Skip to content

Commit

Permalink
[SavedObjectsFinder] Replace savedObjects.client.find (#151549)
Browse files Browse the repository at this point in the history
## 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]>
  • Loading branch information
Maja Grubic and kibanamachine authored Feb 22, 2023
1 parent 6943797 commit 20ee302
Show file tree
Hide file tree
Showing 21 changed files with 269 additions and 215 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function OpenSearchPanel(props: OpenSearchPanelProps) {
<EuiFlyoutBody>
<SavedObjectFinder
services={{
savedObjects: core.savedObjects,
http: core.http,
uiSettings,
savedObjectsManagement,
savedObjectsTagging,
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/saved_objects/kibana.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"owner": "@elastic/kibana-core",
"plugin": {
"id": "savedObjects",
"server": true,
"server": false,
"browser": true,
"requiredPlugins": [
"data",
Expand Down
1 change: 0 additions & 1 deletion src/plugins/saved_objects/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"@kbn/i18n-react",
"@kbn/test-jest-helpers",
"@kbn/utility-types",
"@kbn/config-schema",
"@kbn/core-saved-objects-server",
],
"exclude": [
Expand Down
11 changes: 11 additions & 0 deletions src/plugins/saved_objects_finder/common/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export const PER_PAGE_SETTING = 'savedObjects:perPage';
export const LISTING_LIMIT_SETTING = 'savedObjects:listingLimit';
export type { SavedObjectCommon, FindQueryHTTP, FindResponseHTTP, FinderAttributes } from './types';
36 changes: 36 additions & 0 deletions src/plugins/saved_objects_finder/common/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { SavedObject } from '@kbn/core-saved-objects-server';

export type SavedObjectCommon<T = unknown> = SavedObject<T>;

export interface FindQueryHTTP {
perPage?: number;
page?: number;
type: string | string[];
search?: string;
searchFields?: string[];
defaultSearchOperator?: 'AND' | 'OR';
sortField?: string;
sortOrder?: 'asc' | 'desc';
fields?: string | string[];
hasReference?: string;
}

export interface FinderAttributes {
title?: string;
name?: string;
type: string;
}

export interface FindResponseHTTP<T> {
saved_objects: Array<SavedObjectCommon<T>>;
total: number;
page: number;
per_page: number;
}
2 changes: 1 addition & 1 deletion src/plugins/saved_objects_finder/kibana.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"owner": "@elastic/kibana-data-discovery",
"plugin": {
"id": "savedObjectsFinder",
"server": false,
"server": true,
"browser": true,
"requiredBundles": [
"savedObjects"
Expand Down
Loading

0 comments on commit 20ee302

Please sign in to comment.