From 526edbd06161571f730de357048f295c00bff896 Mon Sep 17 00:00:00 2001 From: Maja Grubic Date: Fri, 10 Mar 2023 19:47:56 +0100 Subject: [PATCH] [ML Plugin] Replace SavedObjectsFinder component (#152939) ## Summary This PR replaces the SavedObjectsFinder component from `saved_objects plugin` with the one in `saved_objects_finder` plugin. This is a part of making the component BWCA compliant (https://github.com/elastic/kibana/issues/150604). ### 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 - [X] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) - [X] 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)~ - [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) ### 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 <42973632+kibanamachine@users.noreply.github.com> --- x-pack/plugins/ml/kibana.jsonc | 5 +++-- x-pack/plugins/ml/public/application/app.tsx | 1 + .../application/contexts/kibana/kibana_context.ts | 2 ++ .../source_selection/source_selection.test.tsx | 7 ++++--- .../source_selection/source_selection.tsx | 13 ++++++++----- .../components/data_view/change_data_view.tsx | 12 ++++++++---- .../jobs/new_job/pages/index_or_search/page.tsx | 13 ++++++++----- x-pack/plugins/ml/public/plugin.ts | 3 +++ x-pack/plugins/ml/tsconfig.json | 2 ++ 9 files changed, 39 insertions(+), 19 deletions(-) diff --git a/x-pack/plugins/ml/kibana.jsonc b/x-pack/plugins/ml/kibana.jsonc index 19c3140de3977..94d24ddf9112b 100644 --- a/x-pack/plugins/ml/kibana.jsonc +++ b/x-pack/plugins/ml/kibana.jsonc @@ -28,7 +28,9 @@ "taskManager", "triggersActionsUi", "uiActions", - "unifiedSearch" + "unifiedSearch", + "savedObjectsFinder", + "savedObjectsManagement" ], "optionalPlugins": [ "alerting", @@ -52,7 +54,6 @@ "kibanaUtils", "lens", "maps", - "savedObjects", "savedSearch", "usageCollection", "unifiedFieldList", diff --git a/x-pack/plugins/ml/public/application/app.tsx b/x-pack/plugins/ml/public/application/app.tsx index b5dafed765ff4..b15abc1d2cddb 100644 --- a/x-pack/plugins/ml/public/application/app.tsx +++ b/x-pack/plugins/ml/public/application/app.tsx @@ -112,6 +112,7 @@ const App: FC = ({ coreStart, deps, appMountParams }) => { unifiedSearch: deps.unifiedSearch, licensing: deps.licensing, lens: deps.lens, + savedObjectsManagement: deps.savedObjectsManagement, ...coreStart, }; diff --git a/x-pack/plugins/ml/public/application/contexts/kibana/kibana_context.ts b/x-pack/plugins/ml/public/application/contexts/kibana/kibana_context.ts index aebe71477c7bc..bf1cdc3d787ec 100644 --- a/x-pack/plugins/ml/public/application/contexts/kibana/kibana_context.ts +++ b/x-pack/plugins/ml/public/application/contexts/kibana/kibana_context.ts @@ -25,6 +25,7 @@ import type { ChartsPluginStart } from '@kbn/charts-plugin/public'; import type { CasesUiStart } from '@kbn/cases-plugin/public'; import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public'; import type { LensPublicStart } from '@kbn/lens-plugin/public'; +import type { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public'; import type { MlServicesContext } from '../../app'; interface StartPlugins { @@ -47,6 +48,7 @@ interface StartPlugins { core: CoreStart; appName: string; lens: LensPublicStart; + savedObjectsManagement: SavedObjectsManagementPluginStart; } export type StartServices = CoreStart & StartPlugins & { diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/source_selection/source_selection.test.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/source_selection/source_selection.test.tsx index d52265634cc23..bd41d70a322f2 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/source_selection/source_selection.test.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/source_selection/source_selection.test.tsx @@ -14,8 +14,8 @@ import { getDataViewAndSavedSearch, DataViewAndSavedSearch } from '../../../../. import { SourceSelection } from './source_selection'; -jest.mock('@kbn/saved-objects-plugin/public', () => { - const SavedObjectFinderUi = ({ +jest.mock('@kbn/saved-objects-finder-plugin/public', () => { + const SavedObjectFinder = ({ onChoose, }: { onChoose: (id: string, type: string, fullName: string, savedObject: object) => void; @@ -63,7 +63,7 @@ jest.mock('@kbn/saved-objects-plugin/public', () => { }; return { - SavedObjectFinderUi, + SavedObjectFinder, }; }); @@ -73,6 +73,7 @@ jest.mock('../../../../../contexts/kibana', () => ({ services: { uiSettings: {}, http: {}, + savedObjectsManagement: {}, }, }), useNavigateToPath: () => mockNavigateToPath, diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/source_selection/source_selection.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/source_selection/source_selection.tsx index ed327eb7dc71b..f6363405cdc71 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/source_selection/source_selection.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/source_selection/source_selection.tsx @@ -16,7 +16,7 @@ import { import { i18n } from '@kbn/i18n'; import { getNestedProperty } from '@kbn/ml-nested-property'; -import { SavedObjectFinderUi } from '@kbn/saved-objects-plugin/public'; +import { SavedObjectFinder } from '@kbn/saved-objects-finder-plugin/public'; import { SavedObjectCommon } from '@kbn/saved-objects-plugin/common'; import { useMlKibana, useNavigateToPath } from '../../../../../contexts/kibana'; @@ -27,7 +27,7 @@ const fixedPageSize: number = 20; export const SourceSelection: FC = () => { const { - services: { http, uiSettings }, + services: { http, uiSettings, savedObjectsManagement }, } = useMlKibana(); const navigateToPath = useNavigateToPath(); @@ -117,7 +117,7 @@ export const SourceSelection: FC = () => { )} - { }, ]} fixedPageSize={fixedPageSize} - uiSettings={uiSettings} - http={http} + services={{ + uiSettings, + http, + savedObjectsManagement, + }} /> diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/datafeed_step/components/data_view/change_data_view.tsx b/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/datafeed_step/components/data_view/change_data_view.tsx index 40a8a3f5a5c4c..71d68b895f605 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/datafeed_step/components/data_view/change_data_view.tsx +++ b/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/datafeed_step/components/data_view/change_data_view.tsx @@ -23,7 +23,7 @@ import { EuiModalBody, } from '@elastic/eui'; -import { SavedObjectFinderUi } from '@kbn/saved-objects-plugin/public'; +import { SavedObjectFinder } from '@kbn/saved-objects-finder-plugin/public'; import { JobCreatorContext } from '../../../job_creator_context'; import { AdvancedJobCreator } from '../../../../../common/job_creator'; import { resetAdvancedJob } from '../../../../../common/job_creator/util/general'; @@ -57,6 +57,7 @@ export const ChangeDataViewModal: FC = ({ onClose }) => { http, uiSettings, data: { dataViews }, + savedObjectsManagement, }, } = useMlKibana(); const navigateToPath = useNavigateToPath(); @@ -146,7 +147,7 @@ export const ChangeDataViewModal: FC = ({ onClose }) => { - = ({ onClose }) => { }, ]} fixedPageSize={fixedPageSize} - uiSettings={uiSettings} - http={http} + services={{ + uiSettings, + http, + savedObjectsManagement, + }} /> )} diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/pages/index_or_search/page.tsx b/x-pack/plugins/ml/public/application/jobs/new_job/pages/index_or_search/page.tsx index 352a2a390fe28..9d2cfa605f50b 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/pages/index_or_search/page.tsx +++ b/x-pack/plugins/ml/public/application/jobs/new_job/pages/index_or_search/page.tsx @@ -9,7 +9,7 @@ import React, { FC } from 'react'; import { EuiPageBody, EuiPageContent_Deprecated as EuiPageContent } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; -import { SavedObjectFinderUi } from '@kbn/saved-objects-plugin/public'; +import { SavedObjectFinder } from '@kbn/saved-objects-finder-plugin/public'; import { useMlKibana, useNavigateToPath } from '../../../../contexts/kibana'; import { MlPageHeader } from '../../../../components/page_header'; @@ -19,7 +19,7 @@ export interface PageProps { export const Page: FC = ({ nextStepPath }) => { const RESULTS_PER_PAGE = 20; - const { uiSettings, http } = useMlKibana().services; + const { uiSettings, http, savedObjectsManagement } = useMlKibana().services; const navigateToPath = useNavigateToPath(); const onObjectSelection = (id: string, type: string) => { @@ -40,7 +40,7 @@ export const Page: FC = ({ nextStepPath }) => { /> - = ({ nextStepPath }) => { }, ]} fixedPageSize={RESULTS_PER_PAGE} - uiSettings={uiSettings} - http={http} + services={{ + uiSettings, + http, + savedObjectsManagement, + }} /> diff --git a/x-pack/plugins/ml/public/plugin.ts b/x-pack/plugins/ml/public/plugin.ts index 06a28d5c749a3..f53e4ecb153b6 100644 --- a/x-pack/plugins/ml/public/plugin.ts +++ b/x-pack/plugins/ml/public/plugin.ts @@ -31,6 +31,7 @@ import type { UiActionsSetup, UiActionsStart } from '@kbn/ui-actions-plugin/publ import type { LicenseManagementUIPluginSetup } from '@kbn/license-management-plugin/public'; import type { LicensingPluginSetup, LicensingPluginStart } from '@kbn/licensing-plugin/public'; import type { SecurityPluginStart } from '@kbn/security-plugin/public'; +import type { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public'; import type { MapsStartApi, MapsSetupApi } from '@kbn/maps-plugin/public'; import { @@ -68,6 +69,7 @@ export interface MlStartDependencies { lens?: LensPublicStart; cases?: CasesUiStart; security: SecurityPluginStart; + savedObjectsManagement: SavedObjectsManagementPluginStart; } export interface MlSetupDependencies { @@ -135,6 +137,7 @@ export class MlPlugin implements Plugin { fieldFormats: pluginsStart.fieldFormats, lens: pluginsStart.lens, cases: pluginsStart.cases, + savedObjectsManagement: pluginsStart.savedObjectsManagement, }, params ); diff --git a/x-pack/plugins/ml/tsconfig.json b/x-pack/plugins/ml/tsconfig.json index dd0d5d0d23ec0..a0bec08acec4c 100644 --- a/x-pack/plugins/ml/tsconfig.json +++ b/x-pack/plugins/ml/tsconfig.json @@ -81,6 +81,8 @@ "@kbn/unified-field-list-plugin", "@kbn/shared-ux-router", "@kbn/saved-search-plugin", + "@kbn/saved-objects-management-plugin", + "@kbn/saved-objects-finder-plugin", "@kbn/monaco", ], }