From d93c44e8b6861ad56b2e94592145a177ce5ca4f4 Mon Sep 17 00:00:00 2001 From: Maja Grubic Date: Wed, 1 Mar 2023 22:33:18 +0100 Subject: [PATCH] [Saved Object Finder] Move to the component in saved_objects_finder plugin (#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 <42973632+kibanamachine@users.noreply.github.com> --- src/plugins/dashboard/kibana.jsonc | 2 + .../public/dashboard_actions/index.ts | 6 +- .../embeddable/api/add_panel_from_library.ts | 9 ++- src/plugins/dashboard/public/plugin.tsx | 2 + .../public/services/plugin_services.stub.ts | 2 + .../public/services/plugin_services.ts | 2 + .../saved_objects_management_service.stub.ts | 17 +++++ .../saved_objects_management_service.ts | 24 +++++++ .../dashboard/public/services/types.ts | 2 + src/plugins/dashboard/tsconfig.json | 2 + src/plugins/embeddable/kibana.jsonc | 4 +- src/plugins/embeddable/public/mocks.tsx | 23 ++++++ src/plugins/embeddable/public/plugin.tsx | 12 +++- .../embeddable/public/tests/test_plugin.ts | 25 ++++++- src/plugins/embeddable/tsconfig.json | 3 + src/plugins/saved_objects_finder/kibana.jsonc | 4 +- .../public/finder/index.tsx | 18 +++++ .../public/finder/saved_object_finder.tsx | 47 ++++++------ .../saved_objects_finder/public/index.ts | 2 +- .../saved_objects_finder/tsconfig.json | 2 + test/examples/embeddables/adding_children.ts | 25 ++++++- .../dashboard/group2/embeddable_library.ts | 5 +- .../apps/dashboard/group3/panel_replacing.ts | 2 +- .../services/dashboard/add_panel.ts | 54 +++++--------- .../services/dashboard/replace_panel.ts | 18 +---- test/functional/services/index.ts | 2 + .../services/saved_objects_finder.ts | 71 +++++++++++++++++++ x-pack/plugins/canvas/kibana.jsonc | 10 +-- .../embeddable_flyout/flyout.component.tsx | 13 ++-- x-pack/plugins/canvas/public/plugin.tsx | 2 + .../canvas/public/services/kibana/platform.ts | 1 + .../canvas/public/services/platform.ts | 2 + .../canvas/public/services/stubs/platform.ts | 1 + x-pack/plugins/canvas/tsconfig.json | 3 +- 34 files changed, 310 insertions(+), 107 deletions(-) create mode 100644 src/plugins/dashboard/public/services/saved_objects_management/saved_objects_management_service.stub.ts create mode 100644 src/plugins/dashboard/public/services/saved_objects_management/saved_objects_management_service.ts create mode 100644 test/functional/services/saved_objects_finder.ts diff --git a/src/plugins/dashboard/kibana.jsonc b/src/plugins/dashboard/kibana.jsonc index ae5194d662c2b..aba26ca66ed7d 100644 --- a/src/plugins/dashboard/kibana.jsonc +++ b/src/plugins/dashboard/kibana.jsonc @@ -16,6 +16,8 @@ "inspector", "navigation", "savedObjects", + "savedObjectsFinder", + "savedObjectsManagement", "share", "screenshotMode", "uiActions", diff --git a/src/plugins/dashboard/public/dashboard_actions/index.ts b/src/plugins/dashboard/public/dashboard_actions/index.ts index 652b66b2ad195..199854710f1f2 100644 --- a/src/plugins/dashboard/public/dashboard_actions/index.ts +++ b/src/plugins/dashboard/public/dashboard_actions/index.ts @@ -8,7 +8,7 @@ import { CONTEXT_MENU_TRIGGER, PANEL_NOTIFICATION_TRIGGER } from '@kbn/embeddable-plugin/public'; import { CoreStart } from '@kbn/core/public'; -import { getSavedObjectFinder } from '@kbn/saved-objects-plugin/public'; +import { getSavedObjectFinder } from '@kbn/saved-objects-finder-plugin/public'; import { ExportCSVAction } from './export_csv_action'; import { ClonePanelAction } from './clone_panel_action'; @@ -33,13 +33,13 @@ export const buildAllDashboardActions = async ({ allowByValueEmbeddables, }: BuildAllDashboardActionsProps) => { const { uiSettings } = core; - const { uiActions, share, presentationUtil } = plugins; + const { uiActions, share, presentationUtil, savedObjectsManagement } = plugins; const clonePanelAction = new ClonePanelAction(core.savedObjects); uiActions.registerAction(clonePanelAction); uiActions.attachAction(CONTEXT_MENU_TRIGGER, clonePanelAction.id); - const SavedObjectFinder = getSavedObjectFinder(uiSettings, core.http); + const SavedObjectFinder = getSavedObjectFinder(uiSettings, core.http, savedObjectsManagement); const changeViewAction = new ReplacePanelAction(SavedObjectFinder); uiActions.registerAction(changeViewAction); uiActions.attachAction(CONTEXT_MENU_TRIGGER, changeViewAction.id); diff --git a/src/plugins/dashboard/public/dashboard_container/embeddable/api/add_panel_from_library.ts b/src/plugins/dashboard/public/dashboard_container/embeddable/api/add_panel_from_library.ts index 79a3caeafba17..06389afc2a576 100644 --- a/src/plugins/dashboard/public/dashboard_container/embeddable/api/add_panel_from_library.ts +++ b/src/plugins/dashboard/public/dashboard_container/embeddable/api/add_panel_from_library.ts @@ -8,7 +8,7 @@ import { HttpStart } from '@kbn/core/public'; import { isErrorEmbeddable, openAddPanelFlyout } from '@kbn/embeddable-plugin/public'; -import { getSavedObjectFinder } from '@kbn/saved-objects-plugin/public'; +import { getSavedObjectFinder } from '@kbn/saved-objects-finder-plugin/public'; import { pluginServices } from '../../../services/plugin_services'; import { DashboardContainer } from '../dashboard_container'; @@ -21,12 +21,17 @@ export function addFromLibrary(this: DashboardContainer) { settings: { uiSettings, theme }, embeddable: { getEmbeddableFactories, getEmbeddableFactory }, http, + savedObjectsManagement, } = pluginServices.getServices(); if (isErrorEmbeddable(this)) return; this.openOverlay( openAddPanelFlyout({ - SavedObjectFinder: getSavedObjectFinder(uiSettings, http as HttpStart), + SavedObjectFinder: getSavedObjectFinder( + uiSettings, + http as HttpStart, + savedObjectsManagement + ), reportUiCounter: usageCollection.reportUiCounter, getAllFactories: getEmbeddableFactories, getFactory: getEmbeddableFactory, diff --git a/src/plugins/dashboard/public/plugin.tsx b/src/plugins/dashboard/public/plugin.tsx index cb13afd4aabf7..3c4031072ca92 100644 --- a/src/plugins/dashboard/public/plugin.tsx +++ b/src/plugins/dashboard/public/plugin.tsx @@ -50,6 +50,7 @@ import type { UrlForwardingSetup, UrlForwardingStart } from '@kbn/url-forwarding import type { SavedObjectTaggingOssPluginStart } from '@kbn/saved-objects-tagging-oss-plugin/public'; import { CustomBrandingStart } from '@kbn/core-custom-branding-browser'; +import { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public'; import { DashboardContainerFactoryDefinition } from './dashboard_container/embeddable/dashboard_container_factory'; import { type DashboardAppLocator, @@ -90,6 +91,7 @@ export interface DashboardStartDependencies { presentationUtil: PresentationUtilPluginStart; savedObjects: SavedObjectsStart; savedObjectsClient: SavedObjectsClientContract; + savedObjectsManagement: SavedObjectsManagementPluginStart; savedObjectsTaggingOss?: SavedObjectTaggingOssPluginStart; screenshotMode: ScreenshotModePluginStart; share?: SharePluginStart; diff --git a/src/plugins/dashboard/public/services/plugin_services.stub.ts b/src/plugins/dashboard/public/services/plugin_services.stub.ts index eabe85288687a..f0ec4a91f3fd6 100644 --- a/src/plugins/dashboard/public/services/plugin_services.stub.ts +++ b/src/plugins/dashboard/public/services/plugin_services.stub.ts @@ -39,6 +39,7 @@ import { urlForwardingServiceFactory } from './url_forwarding/url_fowarding.stub import { visualizationsServiceFactory } from './visualizations/visualizations.stub'; import { dashboardSavedObjectServiceFactory } from './dashboard_saved_object/dashboard_saved_object.stub'; import { customBrandingServiceFactory } from './custom_branding/custom_branding.stub'; +import { savedObjectsManagementServiceFactory } from './saved_objects_management/saved_objects_management_service.stub'; export const providers: PluginServiceProviders = { dashboardSavedObject: new PluginServiceProvider(dashboardSavedObjectServiceFactory), @@ -66,6 +67,7 @@ export const providers: PluginServiceProviders = { usageCollection: new PluginServiceProvider(usageCollectionServiceFactory), visualizations: new PluginServiceProvider(visualizationsServiceFactory), customBranding: new PluginServiceProvider(customBrandingServiceFactory), + savedObjectsManagement: new PluginServiceProvider(savedObjectsManagementServiceFactory), }; export const registry = new PluginServiceRegistry(providers); diff --git a/src/plugins/dashboard/public/services/plugin_services.ts b/src/plugins/dashboard/public/services/plugin_services.ts index 4382506a37948..599eb6a5b7249 100644 --- a/src/plugins/dashboard/public/services/plugin_services.ts +++ b/src/plugins/dashboard/public/services/plugin_services.ts @@ -40,6 +40,7 @@ import { usageCollectionServiceFactory } from './usage_collection/usage_collecti import { analyticsServiceFactory } from './analytics/analytics_service'; import { dashboardSavedObjectServiceFactory } from './dashboard_saved_object/dashboard_saved_object_service'; import { customBrandingServiceFactory } from './custom_branding/custom_branding_service'; +import { savedObjectsManagementServiceFactory } from './saved_objects_management/saved_objects_management_service'; const providers: PluginServiceProviders = { dashboardSavedObject: new PluginServiceProvider(dashboardSavedObjectServiceFactory, [ @@ -80,6 +81,7 @@ const providers: PluginServiceProviders(); diff --git a/src/plugins/dashboard/public/services/saved_objects_management/saved_objects_management_service.stub.ts b/src/plugins/dashboard/public/services/saved_objects_management/saved_objects_management_service.stub.ts new file mode 100644 index 0000000000000..b5ea444e702a8 --- /dev/null +++ b/src/plugins/dashboard/public/services/saved_objects_management/saved_objects_management_service.stub.ts @@ -0,0 +1,17 @@ +/* + * 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 { PluginServiceFactory } from '@kbn/presentation-util-plugin/public'; +import { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public'; +import { savedObjectsManagementPluginMock } from '@kbn/saved-objects-management-plugin/public/mocks'; + +type SavedObjectsManagementServiceFactory = PluginServiceFactory; + +export const savedObjectsManagementServiceFactory: SavedObjectsManagementServiceFactory = () => { + return savedObjectsManagementPluginMock.createStartContract(); +}; diff --git a/src/plugins/dashboard/public/services/saved_objects_management/saved_objects_management_service.ts b/src/plugins/dashboard/public/services/saved_objects_management/saved_objects_management_service.ts new file mode 100644 index 0000000000000..271a056948687 --- /dev/null +++ b/src/plugins/dashboard/public/services/saved_objects_management/saved_objects_management_service.ts @@ -0,0 +1,24 @@ +/* + * 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 { KibanaPluginServiceFactory } from '@kbn/presentation-util-plugin/public'; +import { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public'; +import { DashboardStartDependencies } from '../../plugin'; + +export type SavedObjectsManagementServiceFactory = KibanaPluginServiceFactory< + SavedObjectsManagementPluginStart, + DashboardStartDependencies +>; + +export const savedObjectsManagementServiceFactory: SavedObjectsManagementServiceFactory = ({ + startPlugins, +}) => { + const { savedObjectsManagement } = startPlugins; + + return savedObjectsManagement; +}; diff --git a/src/plugins/dashboard/public/services/types.ts b/src/plugins/dashboard/public/services/types.ts index fc7e0acf1b5c4..1992cd83d4b6d 100644 --- a/src/plugins/dashboard/public/services/types.ts +++ b/src/plugins/dashboard/public/services/types.ts @@ -8,6 +8,7 @@ import { PluginInitializerContext } from '@kbn/core/public'; import { KibanaPluginServiceParams } from '@kbn/presentation-util-plugin/public'; +import { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public'; import { DashboardStartDependencies } from '../plugin'; import { DashboardAnalyticsService } from './analytics/types'; @@ -66,4 +67,5 @@ export interface DashboardServices { usageCollection: DashboardUsageCollectionService; // TODO: make this optional in follow up visualizations: DashboardVisualizationsService; customBranding: DashboardCustomBrandingService; + savedObjectsManagement: SavedObjectsManagementPluginStart; } diff --git a/src/plugins/dashboard/tsconfig.json b/src/plugins/dashboard/tsconfig.json index 17ec86d25e6ef..4bfb899c5301d 100644 --- a/src/plugins/dashboard/tsconfig.json +++ b/src/plugins/dashboard/tsconfig.json @@ -53,6 +53,8 @@ "@kbn/core-execution-context-common", "@kbn/core-custom-branding-browser", "@kbn/shared-ux-router", + "@kbn/saved-objects-finder-plugin", + "@kbn/saved-objects-management-plugin", "@kbn/shared-ux-button-toolbar", ], "exclude": [ diff --git a/src/plugins/embeddable/kibana.jsonc b/src/plugins/embeddable/kibana.jsonc index 89aa3e41026a6..b7a164b459d77 100644 --- a/src/plugins/embeddable/kibana.jsonc +++ b/src/plugins/embeddable/kibana.jsonc @@ -10,7 +10,9 @@ "requiredPlugins": [ "data", "inspector", - "uiActions" + "uiActions", + "savedObjectsFinder", + "savedObjectsManagement" ], "requiredBundles": [ "savedObjects", diff --git a/src/plugins/embeddable/public/mocks.tsx b/src/plugins/embeddable/public/mocks.tsx index 25ccb141cd356..478845cf66f6d 100644 --- a/src/plugins/embeddable/public/mocks.tsx +++ b/src/plugins/embeddable/public/mocks.tsx @@ -14,6 +14,11 @@ import { type AggregateQuery, type Filter, type Query } from '@kbn/es-query'; import { inspectorPluginMock } from '@kbn/inspector-plugin/public/mocks'; import { uiActionsPluginMock } from '@kbn/ui-actions-plugin/public/mocks'; +import { + SavedObjectManagementTypeInfo, + SavedObjectsManagementPluginStart, +} from '@kbn/saved-objects-management-plugin/public'; +import { SavedObjectsTaggingApi } from '@kbn/saved-objects-tagging-oss-plugin/public'; import { UiActionsService } from './lib/ui_actions'; import { EmbeddablePublicPlugin } from './plugin'; import { @@ -156,10 +161,28 @@ const createInstance = (setupPlugins: Partial = {}) const setup = plugin.setup(coreMock.createSetup(), { uiActions: setupPlugins.uiActions || uiActionsPluginMock.createSetupContract(), }); + const savedObjectsManagementMock = { + parseQuery: (query: Query, types: SavedObjectManagementTypeInfo[]) => { + return { + queryText: 'some search', + }; + }, + getTagFindReferences: ({ + selectedTags, + taggingApi, + }: { + selectedTags?: string[]; + taggingApi?: SavedObjectsTaggingApi; + }) => { + return undefined; + }, + }; const doStart = (startPlugins: Partial = {}) => plugin.start(coreMock.createStart(), { uiActions: startPlugins.uiActions || uiActionsPluginMock.createStartContract(), inspector: inspectorPluginMock.createStartContract(), + savedObjectsManagement: + savedObjectsManagementMock as unknown as SavedObjectsManagementPluginStart, }); return { plugin, diff --git a/src/plugins/embeddable/public/plugin.tsx b/src/plugins/embeddable/public/plugin.tsx index 1ea92fe129ccf..b064ae3f77592 100644 --- a/src/plugins/embeddable/public/plugin.tsx +++ b/src/plugins/embeddable/public/plugin.tsx @@ -11,7 +11,7 @@ import { Subscription } from 'rxjs'; import { identity } from 'lodash'; import { UI_SETTINGS } from '@kbn/data-plugin/public'; import type { SerializableRecord } from '@kbn/utility-types'; -import { getSavedObjectFinder } from '@kbn/saved-objects-plugin/public'; +import { getSavedObjectFinder } from '@kbn/saved-objects-finder-plugin/public'; import { UiActionsSetup, UiActionsStart } from '@kbn/ui-actions-plugin/public'; import { Start as InspectorStart } from '@kbn/inspector-plugin/public'; import { @@ -23,6 +23,7 @@ import { } from '@kbn/core/public'; import { Storage } from '@kbn/kibana-utils-plugin/public'; import { migrateToLatest, PersistableStateService } from '@kbn/kibana-utils-plugin/common'; +import { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public'; import { EmbeddableFactoryRegistry, EmbeddableFactoryProvider, @@ -64,6 +65,7 @@ export interface EmbeddableSetupDependencies { export interface EmbeddableStartDependencies { uiActions: UiActionsStart; inspector: InspectorStart; + savedObjectsManagement: SavedObjectsManagementPluginStart; } export interface EmbeddableSetup { @@ -143,7 +145,7 @@ export class EmbeddablePublicPlugin implements Plugin { this.embeddableFactories.set( @@ -207,7 +209,11 @@ export class EmbeddablePublicPlugin implements Plugin diff --git a/src/plugins/embeddable/public/tests/test_plugin.ts b/src/plugins/embeddable/public/tests/test_plugin.ts index 6587d42dfda12..09412d973ec78 100644 --- a/src/plugins/embeddable/public/tests/test_plugin.ts +++ b/src/plugins/embeddable/public/tests/test_plugin.ts @@ -11,8 +11,13 @@ import { UiActionsStart } from '@kbn/ui-actions-plugin/public'; import { uiActionsPluginMock } from '@kbn/ui-actions-plugin/public/mocks'; import { inspectorPluginMock } from '@kbn/inspector-plugin/public/mocks'; import { coreMock } from '@kbn/core/public/mocks'; +import { + SavedObjectManagementTypeInfo, + SavedObjectsManagementPluginStart, +} from '@kbn/saved-objects-management-plugin/public'; +import { Query } from '@kbn/es-query'; +import { SavedObjectsTaggingApi } from '@kbn/saved-objects-tagging-oss-plugin/public'; import { EmbeddablePublicPlugin, EmbeddableSetup, EmbeddableStart } from '../plugin'; - export interface TestPluginReturn { plugin: EmbeddablePublicPlugin; coreSetup: CoreSetup; @@ -32,6 +37,22 @@ export const testPlugin = ( const setup = plugin.setup(coreSetup, { uiActions: uiActions.setup, }); + const savedObjectsManagementMock = { + parseQuery: (query: Query, types: SavedObjectManagementTypeInfo[]) => { + return { + queryText: 'some search', + }; + }, + getTagFindReferences: ({ + selectedTags, + taggingApi, + }: { + selectedTags?: string[]; + taggingApi?: SavedObjectsTaggingApi; + }) => { + return undefined; + }, + }; return { plugin, @@ -42,6 +63,8 @@ export const testPlugin = ( const start = plugin.start(anotherCoreStart, { inspector: inspectorPluginMock.createStartContract(), uiActions: uiActionsPluginMock.createStartContract(), + savedObjectsManagement: + savedObjectsManagementMock as unknown as SavedObjectsManagementPluginStart, }); return start; }, diff --git a/src/plugins/embeddable/tsconfig.json b/src/plugins/embeddable/tsconfig.json index 67102414915d9..6f8a146187b2a 100644 --- a/src/plugins/embeddable/tsconfig.json +++ b/src/plugins/embeddable/tsconfig.json @@ -30,6 +30,9 @@ "@kbn/data-plugin", "@kbn/core-overlays-browser-mocks", "@kbn/core-theme-browser-mocks", + "@kbn/saved-objects-management-plugin", + "@kbn/saved-objects-tagging-oss-plugin", + "@kbn/saved-objects-finder-plugin", ], "exclude": [ "target/**/*", diff --git a/src/plugins/saved_objects_finder/kibana.jsonc b/src/plugins/saved_objects_finder/kibana.jsonc index bfe35d688b9cf..9373ef8d5f9de 100644 --- a/src/plugins/saved_objects_finder/kibana.jsonc +++ b/src/plugins/saved_objects_finder/kibana.jsonc @@ -6,8 +6,6 @@ "id": "savedObjectsFinder", "server": true, "browser": true, - "requiredBundles": [ - "savedObjects" - ] + "requiredBundles": ["savedObjects"] } } diff --git a/src/plugins/saved_objects_finder/public/finder/index.tsx b/src/plugins/saved_objects_finder/public/finder/index.tsx index 0819ebf8141b6..789d09ec520b1 100644 --- a/src/plugins/saved_objects_finder/public/finder/index.tsx +++ b/src/plugins/saved_objects_finder/public/finder/index.tsx @@ -8,6 +8,10 @@ import { EuiDelayRender, EuiLoadingContent } from '@elastic/eui'; import React from 'react'; +import { IUiSettingsClient } from '@kbn/core-ui-settings-browser'; +import { HttpStart } from '@kbn/core-http-browser'; +import { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public'; +import { SavedObjectsTaggingApi } from '@kbn/saved-objects-tagging-oss-plugin/public'; import type { SavedObjectFinderProps } from './saved_object_finder'; const LazySavedObjectFinder = React.lazy(() => import('./saved_object_finder')); @@ -23,5 +27,19 @@ const SavedObjectFinder = (props: SavedObjectFinderProps) => ( ); +export const getSavedObjectFinder = ( + uiSettings: IUiSettingsClient, + http: HttpStart, + savedObjectsManagement: SavedObjectsManagementPluginStart, + savedObjectsTagging?: SavedObjectsTaggingApi +) => { + return (props: SavedObjectFinderProps) => ( + + ); +}; + export type { SavedObjectMetaData, SavedObjectFinderProps } from './saved_object_finder'; export { SavedObjectFinder }; diff --git a/src/plugins/saved_objects_finder/public/finder/saved_object_finder.tsx b/src/plugins/saved_objects_finder/public/finder/saved_object_finder.tsx index 570890e015409..2db81716876c9 100644 --- a/src/plugins/saved_objects_finder/public/finder/saved_object_finder.tsx +++ b/src/plugins/saved_objects_finder/public/finder/saved_object_finder.tsx @@ -28,7 +28,7 @@ import { i18n } from '@kbn/i18n'; import type { IUiSettingsClient, HttpStart } from '@kbn/core/public'; import type { SavedObjectsTaggingApi } from '@kbn/saved-objects-tagging-oss-plugin/public'; import { LISTING_LIMIT_SETTING } from '@kbn/saved-objects-plugin/public'; -import { SavedObjectCommon, FindQueryHTTP, FindResponseHTTP } from '../../common'; +import { SavedObjectCommon, FindQueryHTTP, FindResponseHTTP, FinderAttributes } from '../../common'; export interface SavedObjectMetaData { type: string; @@ -41,12 +41,6 @@ export interface SavedObjectMetaData { defaultSearchField?: string; } -interface FinderAttributes { - title?: string; - name?: string; - type: string; -} - interface SavedObjectFinderItem extends SavedObjectCommon { title: string | null; name: string | null; @@ -64,7 +58,7 @@ interface SavedObjectFinderServices { http: HttpStart; uiSettings: IUiSettingsClient; savedObjectsManagement: SavedObjectsManagementPluginStart; - savedObjectsTagging: SavedObjectsTaggingApi | undefined; + savedObjectsTagging?: SavedObjectsTaggingApi; } interface BaseSavedObjectFinder { @@ -109,16 +103,7 @@ export class SavedObjectFinderUi extends React.Component< private debouncedFetch = debounce(async (query: Query) => { const metaDataMap = this.getSavedObjectMetaDataMap(); - const { queryText, visibleTypes, selectedTags } = - this.props.services.savedObjectsManagement.parseQuery( - query, - Object.values(metaDataMap).map((metadata) => ({ - name: metadata.type, - namespaceType: 'single', - hidden: false, - displayName: metadata.name, - })) - ); + const { savedObjectsManagement, uiSettings, http } = this.props.services; const fields = Object.values(metaDataMap) .map((metaData) => metaData.includeFields || []) @@ -131,22 +116,32 @@ export class SavedObjectFinderUi extends React.Component< return col; }, []); - const perPage = this.props.services.uiSettings.get(LISTING_LIMIT_SETTING); - const hasReference = this.props.services.savedObjectsManagement.getTagFindReferences({ + const perPage = uiSettings.get(LISTING_LIMIT_SETTING); + const { queryText, visibleTypes, selectedTags } = savedObjectsManagement.parseQuery( + query, + Object.values(metaDataMap).map((metadata) => ({ + name: metadata.type, + namespaceType: 'single', + hidden: false, + displayName: metadata.name, + })) + ); + const hasReference = savedObjectsManagement.getTagFindReferences({ selectedTags, taggingApi: this.props.services.savedObjectsTagging, }); const params: FindQueryHTTP = { type: visibleTypes ?? Object.keys(metaDataMap), - fields: [...new Set(fields)], search: queryText ? `${queryText}*` : undefined, + fields: [...new Set(fields)], page: 1, perPage, searchFields: ['title^3', 'description', ...additionalSearchFields], defaultSearchOperator: 'AND', hasReference: hasReference ? JSON.stringify(hasReference) : undefined, }; - const response = (await this.props.services.http.get('/internal/saved-objects-finder/find', { + + const response = (await http.get('/internal/saved-objects-finder/find', { query: params as Record, })) as FindResponseHTTP; @@ -156,7 +151,7 @@ export class SavedObjectFinderUi extends React.Component< attributes: { name, title }, } = savedObject; const titleToUse = typeof title === 'string' ? title : ''; - const nameToUse = name && typeof name === 'string' ? name : titleToUse; + const nameToUse = name ? name : titleToUse; return { ...savedObject, version: savedObject.version, @@ -169,9 +164,8 @@ export class SavedObjectFinderUi extends React.Component< const metaData = metaDataMap[savedObject.type]; if (metaData.showSavedObject) { return metaData.showSavedObject(savedObject.simple); - } else { - return true; } + return true; }); if (!this.isComponentMounted) { @@ -289,7 +283,7 @@ export class SavedObjectFinderUi extends React.Component< name: i18n.translate('savedObjectsFinder.titleName', { defaultMessage: 'Title', }), - width: '55%', + width: tagColumn ? '55%' : '100%', description: i18n.translate('savedObjectsFinder.titleDescription', { defaultMessage: 'Title of the saved object', }), @@ -369,6 +363,7 @@ export class SavedObjectFinderUi extends React.Component< itemId="id" items={this.state.items} columns={columns} + data-test-subj="savedObjectsFinderTable" message={this.props.noItemsMessage} search={search} pagination={pagination} diff --git a/src/plugins/saved_objects_finder/public/index.ts b/src/plugins/saved_objects_finder/public/index.ts index b266860185365..ada561d5ccb0d 100644 --- a/src/plugins/saved_objects_finder/public/index.ts +++ b/src/plugins/saved_objects_finder/public/index.ts @@ -8,6 +8,6 @@ import { SavedObjectsFinderPublicPlugin } from './plugin'; export type { SavedObjectMetaData, SavedObjectFinderProps } from './finder'; -export { SavedObjectFinder } from './finder'; +export { SavedObjectFinder, getSavedObjectFinder } from './finder'; export const plugin = () => new SavedObjectsFinderPublicPlugin(); diff --git a/src/plugins/saved_objects_finder/tsconfig.json b/src/plugins/saved_objects_finder/tsconfig.json index 02aa4bf8208ea..8725d23a5ea14 100644 --- a/src/plugins/saved_objects_finder/tsconfig.json +++ b/src/plugins/saved_objects_finder/tsconfig.json @@ -13,6 +13,8 @@ "@kbn/saved-objects-plugin", "@kbn/core-saved-objects-server", "@kbn/config-schema", + "@kbn/core-ui-settings-browser", + "@kbn/core-http-browser", ], "exclude": [ "target/**/*", diff --git a/test/examples/embeddables/adding_children.ts b/test/examples/embeddables/adding_children.ts index 1b99413b184f7..7b3e48151fd17 100644 --- a/test/examples/embeddables/adding_children.ts +++ b/test/examples/embeddables/adding_children.ts @@ -12,8 +12,29 @@ import { PluginFunctionalProviderContext } from '../../plugin_functional/service // eslint-disable-next-line import/no-default-export export default function ({ getService }: PluginFunctionalProviderContext) { const testSubjects = getService('testSubjects'); + const find = getService('find'); const flyout = getService('flyout'); + const toggleFilterPopover = async () => { + const filtersHolder = await find.byClassName('euiSearchBar__filtersHolder'); + const filtersButton = await filtersHolder.findByCssSelector('button'); + await filtersButton.click(); + }; + + const clickFilter = async (type: string) => { + const list = await testSubjects.find('euiSelectableList'); + const listItems = await list.findAllByCssSelector('li'); + for (let i = 0; i < listItems.length; i++) { + const listItem = await listItems[i].findByClassName('euiSelectableListItem__text'); + const text = await listItem.getVisibleText(); + if (text.includes(type)) { + await listItem.click(); + await toggleFilterPopover(); + break; + } + } + }; + describe('adding children', () => { before(async () => { await testSubjects.click('embeddablePanelExample'); @@ -23,8 +44,8 @@ export default function ({ getService }: PluginFunctionalProviderContext) { await testSubjects.click('embeddablePanelToggleMenuIcon'); await testSubjects.click('embeddablePanelAction-ACTION_ADD_PANEL'); await testSubjects.waitForDeleted('savedObjectFinderLoadingIndicator'); - await testSubjects.click('savedObjectFinderFilterButton'); - await testSubjects.click('savedObjectFinderFilter-todo'); + await toggleFilterPopover(); + await clickFilter('Todo'); await testSubjects.click('savedObjectTitleGarbage'); await testSubjects.moveMouseTo('euiFlyoutCloseButton'); await flyout.ensureClosed('dashboardAddPanel'); diff --git a/test/functional/apps/dashboard/group2/embeddable_library.ts b/test/functional/apps/dashboard/group2/embeddable_library.ts index ca52eaecaf46e..472a2a890c978 100644 --- a/test/functional/apps/dashboard/group2/embeddable_library.ts +++ b/test/functional/apps/dashboard/group2/embeddable_library.ts @@ -17,6 +17,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const dashboardAddPanel = getService('dashboardAddPanel'); const panelActions = getService('dashboardPanelActions'); + const savedObjectsFinder = getService('savedObjectsFinder'); describe('embeddable library', () => { before(async () => { @@ -35,7 +36,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('unlink visualize panel from embeddable library', async () => { // add heatmap panel from library await dashboardAddPanel.clickOpenAddPanel(); - await dashboardAddPanel.filterEmbeddableNames('Rendering Test: heatmap'); + await savedObjectsFinder.filterEmbeddableNames('Rendering Test: heatmap'); await find.clickByButtonText('Rendering Test: heatmap'); await dashboardAddPanel.closeAddPanel(); @@ -51,7 +52,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(libraryActionExists).to.be(false); await dashboardAddPanel.clickOpenAddPanel(); - await dashboardAddPanel.filterEmbeddableNames('Rendering Test: heatmap'); + await savedObjectsFinder.filterEmbeddableNames('Rendering Test: heatmap'); await find.existsByLinkText('Rendering Test: heatmap'); await dashboardAddPanel.closeAddPanel(); }); diff --git a/test/functional/apps/dashboard/group3/panel_replacing.ts b/test/functional/apps/dashboard/group3/panel_replacing.ts index e6ff8c4f940bb..1cb344748594f 100644 --- a/test/functional/apps/dashboard/group3/panel_replacing.ts +++ b/test/functional/apps/dashboard/group3/panel_replacing.ts @@ -80,7 +80,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await PageObjects.dashboard.switchToEditMode(); } await dashboardPanelActions.replacePanelByTitle(AREA_CHART_VIS_NAME); - await dashboardReplacePanel.replaceEmbeddable(replacedSearch, 'search'); + await dashboardReplacePanel.replaceEmbeddable(replacedSearch, 'Saved search'); await PageObjects.header.waitUntilLoadingHasFinished(); await PageObjects.dashboard.waitForRenderComplete(); const panelTitles = await PageObjects.dashboard.getPanelTitles(); diff --git a/test/functional/services/dashboard/add_panel.ts b/test/functional/services/dashboard/add_panel.ts index a29fd8046e7ec..7af97ef7ff32f 100644 --- a/test/functional/services/dashboard/add_panel.ts +++ b/test/functional/services/dashboard/add_panel.ts @@ -5,7 +5,6 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ - import { FtrService } from '../../ftr_provider_context'; export class DashboardAddPanelService extends FtrService { @@ -15,6 +14,7 @@ export class DashboardAddPanelService extends FtrService { private readonly flyout = this.ctx.getService('flyout'); private readonly common = this.ctx.getPageObject('common'); private readonly header = this.ctx.getPageObject('header'); + private readonly savedObjectsFinder = this.ctx.getService('savedObjectsFinder'); async clickOpenAddPanel() { this.log.debug('DashboardAddPanel.clickOpenAddPanel'); @@ -77,34 +77,20 @@ export class DashboardAddPanelService extends FtrService { await this.testSubjects.click(`createNew-${type}`); } - async toggleFilterPopover() { - this.log.debug('DashboardAddPanel.toggleFilter'); - await this.testSubjects.click('savedObjectFinderFilterButton'); - } - - async toggleFilter(type: string) { - this.log.debug(`DashboardAddPanel.addToFilter(${type})`); - await this.waitForListLoading(); - await this.toggleFilterPopover(); - await this.testSubjects.click(`savedObjectFinderFilter-${type}`); - await this.toggleFilterPopover(); - } - async addEveryEmbeddableOnCurrentPage() { this.log.debug('addEveryEmbeddableOnCurrentPage'); - const itemList = await this.testSubjects.find('savedObjectFinderItemList'); + const itemList = await this.testSubjects.find('savedObjectsFinderTable'); const embeddableList: string[] = []; await this.retry.try(async () => { - const embeddableRows = await itemList.findAllByCssSelector('li'); + const embeddableListBody = await itemList.findByTagName('tbody'); + const embeddableRows = await embeddableListBody.findAllByCssSelector('tr'); for (let i = 0; i < embeddableRows.length; i++) { - const name = await embeddableRows[i].getVisibleText(); - + const { name, button } = await this.savedObjectsFinder.getRowAtIndex(embeddableRows, i); if (embeddableList.includes(name)) { // already added this one continue; } - - await embeddableRows[i].click(); + await button.click(); await this.common.closeToast(); embeddableList.push(name); } @@ -159,21 +145,21 @@ export class DashboardAddPanelService extends FtrService { } } - async waitForListLoading() { - await this.testSubjects.waitForDeleted('savedObjectFinderLoadingIndicator'); - } - async closeAddPanel() { await this.flyout.ensureClosed('dashboardAddPanel'); } + async filterEmbeddableNames(name: string) { + await this.savedObjectsFinder.filterEmbeddableNames(name); + } + async addEveryVisualization(filter: string) { this.log.debug('DashboardAddPanel.addEveryVisualization'); await this.ensureAddPanelIsShowing(); - await this.toggleFilter('visualization'); if (filter) { await this.filterEmbeddableNames(filter.replace('-', ' ')); } + await this.savedObjectsFinder.waitForFilter('Visualization', 'search'); let morePages = true; const vizList: string[][] = []; while (morePages) { @@ -187,11 +173,11 @@ export class DashboardAddPanelService extends FtrService { async addEverySavedSearch(filter: string) { this.log.debug('DashboardAddPanel.addEverySavedSearch'); await this.ensureAddPanelIsShowing(); - await this.toggleFilter('search'); const searchList = []; if (filter) { await this.filterEmbeddableNames(filter.replace('-', ' ')); } + await this.savedObjectsFinder.waitForFilter('Saved search', 'visualization'); let morePages = true; while (morePages) { searchList.push(await this.addEveryEmbeddableOnCurrentPage()); @@ -222,7 +208,8 @@ export class DashboardAddPanelService extends FtrService { } async addVisualization(vizName: string) { - return this.addEmbeddable(vizName, 'visualization'); + this.log.debug(`DashboardAddPanel.addVisualization, ${vizName}`); + return this.addEmbeddable(vizName, 'Visualization'); } async addEmbeddable(embeddableName: string, embeddableType: string) { @@ -230,25 +217,18 @@ export class DashboardAddPanelService extends FtrService { `DashboardAddPanel.addEmbeddable, name: ${embeddableName}, type: ${embeddableType}` ); await this.ensureAddPanelIsShowing(); - await this.toggleFilter(embeddableType); - await this.filterEmbeddableNames(`"${embeddableName.replace('-', ' ')}"`); + await this.savedObjectsFinder.toggleFilter(embeddableType); + await this.savedObjectsFinder.filterEmbeddableNames(`"${embeddableName.replace('-', ' ')}"`); await this.testSubjects.click(`savedObjectTitle${embeddableName.split(' ').join('-')}`); await this.testSubjects.exists('addObjectToDashboardSuccess'); await this.closeAddPanel(); return embeddableName; } - async filterEmbeddableNames(name: string) { - // The search input field may be disabled while the table is loading so wait for it - await this.waitForListLoading(); - await this.testSubjects.setValue('savedObjectFinderSearchInput', name); - await this.waitForListLoading(); - } - async panelAddLinkExists(name: string) { this.log.debug(`DashboardAddPanel.panelAddLinkExists(${name})`); await this.ensureAddPanelIsShowing(); - await this.filterEmbeddableNames(`"${name}"`); + await this.savedObjectsFinder.filterEmbeddableNames(`"${name}"`); return await this.testSubjects.exists(`savedObjectTitle${name.split(' ').join('-')}`); } } diff --git a/test/functional/services/dashboard/replace_panel.ts b/test/functional/services/dashboard/replace_panel.ts index 8f8f680b839bf..915e65467a7a5 100644 --- a/test/functional/services/dashboard/replace_panel.ts +++ b/test/functional/services/dashboard/replace_panel.ts @@ -12,19 +12,7 @@ export class DashboardReplacePanelService extends FtrService { private readonly log = this.ctx.getService('log'); private readonly testSubjects = this.ctx.getService('testSubjects'); private readonly flyout = this.ctx.getService('flyout'); - - async toggleFilterPopover() { - this.log.debug('DashboardReplacePanel.toggleFilter'); - await this.testSubjects.click('savedObjectFinderFilterButton'); - } - - async toggleFilter(type: string) { - this.log.debug(`DashboardReplacePanel.replaceToFilter(${type})`); - await this.waitForListLoading(); - await this.toggleFilterPopover(); - await this.testSubjects.click(`savedObjectFinderFilter-${type}`); - await this.toggleFilterPopover(); - } + private readonly savedObjectsFinder = this.ctx.getService('savedObjectsFinder'); async isReplacePanelOpen() { this.log.debug('DashboardReplacePanel.isReplacePanelOpen'); @@ -66,10 +54,10 @@ export class DashboardReplacePanelService extends FtrService { `DashboardReplacePanel.replaceEmbeddable, name: ${embeddableName}, type: ${embeddableType}` ); await this.ensureReplacePanelIsShowing(); + await this.filterEmbeddableNames(`"${embeddableName.replace('-', ' ')}"`); if (embeddableType) { - await this.toggleFilter(embeddableType); + await this.savedObjectsFinder.toggleFilter(embeddableType); } - await this.filterEmbeddableNames(`"${embeddableName.replace('-', ' ')}"`); await this.testSubjects.click(`savedObjectTitle${embeddableName.split(' ').join('-')}`); await this.testSubjects.exists('addObjectToDashboardSuccess'); await this.closeReplacePanel(); diff --git a/test/functional/services/index.ts b/test/functional/services/index.ts index 80b80ada9a979..e13cac581ce52 100644 --- a/test/functional/services/index.ts +++ b/test/functional/services/index.ts @@ -55,6 +55,7 @@ import { KibanaSupertestProvider } from './supertest'; import { MenuToggleService } from './menu_toggle'; import { MonacoEditorService } from './monaco_editor'; import { UsageCollectionService } from './usage_collection'; +import { SavedObjectsFinderService } from './saved_objects_finder'; export const services = { ...commonServiceProviders, @@ -100,4 +101,5 @@ export const services = { menuToggle: MenuToggleService, retryOnStale: RetryOnStaleProvider, usageCollection: UsageCollectionService, + savedObjectsFinder: SavedObjectsFinderService, }; diff --git a/test/functional/services/saved_objects_finder.ts b/test/functional/services/saved_objects_finder.ts new file mode 100644 index 0000000000000..12e06fe8a1710 --- /dev/null +++ b/test/functional/services/saved_objects_finder.ts @@ -0,0 +1,71 @@ +/* + * 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 expect from '@kbn/expect'; +import { FtrService } from '../ftr_provider_context'; +import { WebElementWrapper } from './lib/web_element_wrapper'; + +export class SavedObjectsFinderService extends FtrService { + private readonly testSubjects = this.ctx.getService('testSubjects'); + private readonly find = this.ctx.getService('find'); + private readonly log = this.ctx.getService('log'); + private readonly retry = this.ctx.getService('retry'); + + public async toggleFilterPopover() { + this.log.debug('SavedObjectsFinder.toggleFilter'); + const filtersHolder = await this.find.byClassName('euiSearchBar__filtersHolder'); + const filtersButton = await filtersHolder.findByCssSelector('button'); + await filtersButton.click(); + } + + public async toggleFilter(type: string) { + this.log.debug(`SavedObjectsFinder.addToFilter(${type})`); + await this.waitForListLoading(); + await this.toggleFilterPopover(); + const list = await this.testSubjects.find('euiSelectableList'); + const listItems = await list.findAllByCssSelector('li'); + for (let i = 0; i < listItems.length; i++) { + const listItem = await listItems[i].findByClassName('euiSelectableListItem__text'); + const text = await listItem.getVisibleText(); + if (text.includes(type)) { + await listItem.click(); + await this.toggleFilterPopover(); + break; + } + } + } + + public async waitForFilter(type: string, expectCondition: string) { + await this.toggleFilter(type); + const itemList = await this.testSubjects.find('savedObjectsFinderTable'); + await this.retry.try(async () => { + const embeddableListBody = await itemList.findByTagName('tbody'); + const embeddableRows = await embeddableListBody.findAllByCssSelector('tr'); + const { name } = await this.getRowAtIndex(embeddableRows, 0); + expect(name.includes(expectCondition)).to.be(false); + }); + } + + public async filterEmbeddableNames(name: string) { + // The search input field may be disabled while the table is loading so wait for it + await this.waitForListLoading(); + await this.testSubjects.setValue('savedObjectFinderSearchInput', name); + await this.waitForListLoading(); + } + + public async getRowAtIndex(rows: WebElementWrapper[], rowIndex: number) { + const cell = await rows[rowIndex].findByTestSubject('savedObjectFinderTitle'); + const button = await cell.findByTagName('button'); + const name = await button.getVisibleText(); + return { button, name }; + } + + private async waitForListLoading() { + await this.testSubjects.waitForDeleted('savedObjectFinderLoadingIndicator'); + } +} diff --git a/x-pack/plugins/canvas/kibana.jsonc b/x-pack/plugins/canvas/kibana.jsonc index 3ef7326dcd460..c52f6628b4fad 100644 --- a/x-pack/plugins/canvas/kibana.jsonc +++ b/x-pack/plugins/canvas/kibana.jsonc @@ -29,13 +29,16 @@ "presentationUtil", "visualizations", "uiActions", - "share" + "share", + "savedObjectsManagement", + "savedObjectsFinder" ], "optionalPlugins": [ "home", "reporting", "spaces", - "usageCollection" + "usageCollection", + "savedObjects", ], "requiredBundles": [ "discover", @@ -43,9 +46,8 @@ "kibanaUtils", "lens", "maps", - "savedObjects", "visualizations", "fieldFormats" - ] + ], } } diff --git a/x-pack/plugins/canvas/public/components/embeddable_flyout/flyout.component.tsx b/x-pack/plugins/canvas/public/components/embeddable_flyout/flyout.component.tsx index e92c8277488ca..d9c665646e2b4 100644 --- a/x-pack/plugins/canvas/public/components/embeddable_flyout/flyout.component.tsx +++ b/x-pack/plugins/canvas/public/components/embeddable_flyout/flyout.component.tsx @@ -9,7 +9,7 @@ import React, { FC, useCallback } from 'react'; import { EuiFlyout, EuiFlyoutHeader, EuiFlyoutBody, EuiTitle } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { SavedObjectFinderUi, SavedObjectMetaData } from '@kbn/saved-objects-plugin/public'; +import { SavedObjectFinder, SavedObjectMetaData } from '@kbn/saved-objects-finder-plugin/public'; import { useEmbeddablesService, usePlatformService } from '../../services'; const strings = { @@ -38,7 +38,7 @@ export const AddEmbeddableFlyout: FC = ({ const embeddablesService = useEmbeddablesService(); const platformService = usePlatformService(); const { getEmbeddableFactories } = embeddablesService; - const { getHttp, getUISettings } = platformService; + const { getHttp, getUISettings, getSavedObjectsManagement } = platformService; const onAddPanel = useCallback( (id: string, savedObjectType: string) => { @@ -77,13 +77,16 @@ export const AddEmbeddableFlyout: FC = ({ - diff --git a/x-pack/plugins/canvas/public/plugin.tsx b/x-pack/plugins/canvas/public/plugin.tsx index 18facb65202f3..20dee0bf5fa75 100644 --- a/x-pack/plugins/canvas/public/plugin.tsx +++ b/x-pack/plugins/canvas/public/plugin.tsx @@ -30,6 +30,7 @@ import { Start as InspectorStart } from '@kbn/inspector-plugin/public'; import { BfetchPublicSetup } from '@kbn/bfetch-plugin/public'; import { PresentationUtilPluginStart } from '@kbn/presentation-util-plugin/public'; import { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public'; +import { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public'; import { featureCatalogueEntry } from './feature_catalogue_entry'; import { CanvasAppLocatorDefinition } from '../common/locator'; import { SESSIONSTORAGE_LASTPATH, CANVAS_APP } from '../common/lib/constants'; @@ -67,6 +68,7 @@ export interface CanvasStartDeps { presentationUtil: PresentationUtilPluginStart; visualizations: VisualizationsStart; spaces?: SpacesPluginStart; + savedObjectsManagement: SavedObjectsManagementPluginStart; } /** diff --git a/x-pack/plugins/canvas/public/services/kibana/platform.ts b/x-pack/plugins/canvas/public/services/kibana/platform.ts index 0b51963eeee31..ab5fb175bd6d1 100644 --- a/x-pack/plugins/canvas/public/services/kibana/platform.ts +++ b/x-pack/plugins/canvas/public/services/kibana/platform.ts @@ -46,5 +46,6 @@ export const platformServiceFactory: CanvaPlatformServiceFactory = ({ getSavedObjectsClient: () => coreStart.savedObjects.client, getUISettings: () => coreStart.uiSettings, getHttp: () => coreStart.http, + getSavedObjectsManagement: () => startPlugins.savedObjectsManagement, }; }; diff --git a/x-pack/plugins/canvas/public/services/platform.ts b/x-pack/plugins/canvas/public/services/platform.ts index b436f51bb33f9..77649a8fa0592 100644 --- a/x-pack/plugins/canvas/public/services/platform.ts +++ b/x-pack/plugins/canvas/public/services/platform.ts @@ -17,6 +17,7 @@ import { } from '@kbn/core/public'; import { SpacesPluginStart } from '@kbn/spaces-plugin/public'; +import { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public'; export interface CanvasPlatformService { getBasePath: () => string; @@ -39,4 +40,5 @@ export interface CanvasPlatformService { getSavedObjectsClient: () => SavedObjectsClientContract; getUISettings: () => IUiSettingsClient; getHttp: () => HttpStart; + getSavedObjectsManagement: () => SavedObjectsManagementPluginStart; } diff --git a/x-pack/plugins/canvas/public/services/stubs/platform.ts b/x-pack/plugins/canvas/public/services/stubs/platform.ts index d96599257f9b6..cdb75dc96322b 100644 --- a/x-pack/plugins/canvas/public/services/stubs/platform.ts +++ b/x-pack/plugins/canvas/public/services/stubs/platform.ts @@ -37,4 +37,5 @@ export const platformServiceFactory: CanvasPlatformServiceFactory = () => ({ redirectLegacyUrl: noop, getLegacyUrlConflict: undefined, getHttp: noop, + getSavedObjectsManagement: noop, }); diff --git a/x-pack/plugins/canvas/tsconfig.json b/x-pack/plugins/canvas/tsconfig.json index ef10a58a1e65b..228ae010ddf43 100644 --- a/x-pack/plugins/canvas/tsconfig.json +++ b/x-pack/plugins/canvas/tsconfig.json @@ -45,7 +45,6 @@ "@kbn/kibana-react-plugin", "@kbn/kibana-utils-plugin", "@kbn/presentation-util-plugin", - "@kbn/saved-objects-plugin", "@kbn/ui-actions-plugin", "@kbn/usage-collection-plugin", "@kbn/visualizations-plugin", @@ -79,6 +78,8 @@ "@kbn/shared-ux-router", "@kbn/babel-register", "@kbn/shared-ux-button-toolbar", + "@kbn/saved-objects-finder-plugin", + "@kbn/saved-objects-management-plugin", ], "exclude": [ "target/**/*",