From 6bbdddc314246457745358a169e096caaaf73d32 Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Wed, 4 Dec 2019 12:01:26 +0100 Subject: [PATCH 1/8] start removing stateful saved object finder --- .../dashboard/dashboard_app_controller.tsx | 6 +- .../kibana/public/dashboard/legacy_imports.ts | 1 - .../search_selection/search_selection.tsx | 10 +- .../public/embeddable/grid/dashboard_grid.tsx | 2 +- .../embeddable_child_panel.test.tsx | 6 +- .../lib/containers/embeddable_child_panel.tsx | 6 +- .../public/lib/panel/embeddable_panel.tsx | 6 +- .../add_panel/add_panel_action.ts | 8 +- .../add_panel/add_panel_flyout.tsx | 9 +- .../add_panel/open_add_panel_flyout.tsx | 11 +- .../public/np_ready/public/legacy.ts | 3 - .../public/np_ready/public/plugin.tsx | 13 +- .../renderers/embeddable.tsx | 4 +- .../new_job/pages/index_or_search/page.tsx | 5 +- .../components/embeddables/embedded_map.tsx | 4 +- .../search_selection/search_selection.tsx | 115 ++++++++++-------- .../legacy/plugins/transform/public/plugin.ts | 13 +- .../legacy/plugins/transform/public/shim.ts | 2 +- 18 files changed, 132 insertions(+), 92 deletions(-) diff --git a/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app_controller.tsx b/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app_controller.tsx index 7972c7603d311..d4aa3c6aa625d 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app_controller.tsx +++ b/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app_controller.tsx @@ -35,7 +35,6 @@ import { AppStateClass as TAppStateClass, KbnUrl, SaveOptions, - SavedObjectFinder, unhashUrl, } from './legacy_imports'; import { FilterStateManager, IndexPattern } from '../../../data/public'; @@ -115,7 +114,7 @@ export class DashboardAppController { timefilter: { timefilter }, }, }, - core: { notifications, overlays, chrome, injectedMetadata }, + core: { notifications, overlays, chrome, injectedMetadata, uiSettings, savedObjects }, }: DashboardAppControllerDependencies) { new FilterStateManager(globalState, getAppState, filterManager); const queryFilter = filterManager; @@ -728,7 +727,8 @@ export class DashboardAppController { getFactory: embeddables.getEmbeddableFactory, notifications, overlays, - SavedObjectFinder, + uiSettings, + savedObjects, }); } }; diff --git a/src/legacy/core_plugins/kibana/public/dashboard/legacy_imports.ts b/src/legacy/core_plugins/kibana/public/dashboard/legacy_imports.ts index 7c3c389330887..f02c252e2108d 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/legacy_imports.ts +++ b/src/legacy/core_plugins/kibana/public/dashboard/legacy_imports.ts @@ -65,4 +65,3 @@ export { stateMonitorFactory, StateMonitor } from 'ui/state_management/state_mon export { ensureDefaultIndexPattern } from 'ui/legacy_compat'; export { unhashUrl } from 'ui/state_management/state_hashing'; export { IInjector } from 'ui/chrome'; -export { SavedObjectFinder } from 'ui/saved_objects/components/saved_object_finder'; diff --git a/src/legacy/core_plugins/kibana/public/visualize/wizard/search_selection/search_selection.tsx b/src/legacy/core_plugins/kibana/public/visualize/wizard/search_selection/search_selection.tsx index 88dbbb8de7df9..41607bdea7503 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/wizard/search_selection/search_selection.tsx +++ b/src/legacy/core_plugins/kibana/public/visualize/wizard/search_selection/search_selection.tsx @@ -22,9 +22,8 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import React from 'react'; -import { SavedObjectFinder } from 'ui/saved_objects/components/saved_object_finder'; - -import { VisType } from '../../kibana_services'; +import { VisType, getServices } from '../../kibana_services'; +import { SavedObjectFinder } from '../../../../../../../plugins/kibana_react/public'; interface SearchSelectionProps { onSearchSelected: (searchId: string, searchType: string) => void; @@ -35,6 +34,9 @@ export class SearchSelection extends React.Component { private fixedPageSize: number = 8; public render() { + const { + core: { uiSettings, savedObjects }, + } = getServices(); return ( @@ -85,6 +87,8 @@ export class SearchSelection extends React.Component { }, ]} fixedPageSize={this.fixedPageSize} + uiSettings={uiSettings} + savedObjects={savedObjects} /> diff --git a/src/plugins/dashboard_embeddable_container/public/embeddable/grid/dashboard_grid.tsx b/src/plugins/dashboard_embeddable_container/public/embeddable/grid/dashboard_grid.tsx index 40db43427339d..2b905626d0db5 100644 --- a/src/plugins/dashboard_embeddable_container/public/embeddable/grid/dashboard_grid.tsx +++ b/src/plugins/dashboard_embeddable_container/public/embeddable/grid/dashboard_grid.tsx @@ -276,7 +276,7 @@ class DashboardGridUi extends React.Component { overlays={this.props.kibana.services.overlays} notifications={this.props.kibana.services.notifications} inspector={this.props.kibana.services.inspector} - SavedObjectFinder={this.props.kibana.services.SavedObjectFinder} + uiSettings={this.props.kibana.services.} /> ); diff --git a/src/plugins/embeddable/public/lib/containers/embeddable_child_panel.test.tsx b/src/plugins/embeddable/public/lib/containers/embeddable_child_panel.test.tsx index 3c9e6e31220b2..c5eb7f17e9ccb 100644 --- a/src/plugins/embeddable/public/lib/containers/embeddable_child_panel.test.tsx +++ b/src/plugins/embeddable/public/lib/containers/embeddable_child_panel.test.tsx @@ -68,8 +68,9 @@ test('EmbeddableChildPanel renders an embeddable when it is done loading', async getEmbeddableFactory={(() => undefined) as any} notifications={{} as any} overlays={{} as any} + uiSettings={{} as any} + savedObjects={{} as any} inspector={inspector} - SavedObjectFinder={() => null} /> ); @@ -106,8 +107,9 @@ test(`EmbeddableChildPanel renders an error message if the factory doesn't exist getEmbeddableFactory={(() => undefined) as any} notifications={{} as any} overlays={{} as any} + uiSettings={{} as any} + savedObjects={{} as any} inspector={inspector} - SavedObjectFinder={() => null} /> ); diff --git a/src/plugins/embeddable/public/lib/containers/embeddable_child_panel.tsx b/src/plugins/embeddable/public/lib/containers/embeddable_child_panel.tsx index d3f9b07be4754..2432b97ddd749 100644 --- a/src/plugins/embeddable/public/lib/containers/embeddable_child_panel.tsx +++ b/src/plugins/embeddable/public/lib/containers/embeddable_child_panel.tsx @@ -40,8 +40,9 @@ export interface EmbeddableChildPanelProps { getAllEmbeddableFactories: GetEmbeddableFactories; overlays: CoreStart['overlays']; notifications: CoreStart['notifications']; + uiSettings: CoreStart['uiSettings']; + savedObjects: CoreStart['savedObjects']; inspector: InspectorStartContract; - SavedObjectFinder: React.ComponentType; } interface State { @@ -102,8 +103,9 @@ export class EmbeddableChildPanel extends React.Component )} diff --git a/src/plugins/embeddable/public/lib/panel/embeddable_panel.tsx b/src/plugins/embeddable/public/lib/panel/embeddable_panel.tsx index 2b48bf237829c..764384759553c 100644 --- a/src/plugins/embeddable/public/lib/panel/embeddable_panel.tsx +++ b/src/plugins/embeddable/public/lib/panel/embeddable_panel.tsx @@ -48,8 +48,9 @@ interface Props { getAllEmbeddableFactories: GetEmbeddableFactories; overlays: CoreStart['overlays']; notifications: CoreStart['notifications']; + uiSettings: CoreStart['uiSettings']; + savedObjects: CoreStart['savedObjects']; inspector: InspectorStartContract; - SavedObjectFinder: React.ComponentType; hideHeader?: boolean; } @@ -233,7 +234,8 @@ export class EmbeddablePanel extends React.Component { this.props.getAllEmbeddableFactories, this.props.overlays, this.props.notifications, - this.props.SavedObjectFinder + this.props.uiSettings, + this.props.savedObjects ), new InspectPanelAction(this.props.inspector), new RemovePanelAction(), diff --git a/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_action.ts b/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_action.ts index 9ecc4686c21b6..e4a1929ad815b 100644 --- a/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_action.ts +++ b/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_action.ts @@ -18,7 +18,7 @@ */ import { i18n } from '@kbn/i18n'; import { IAction } from 'src/plugins/ui_actions/public'; -import { NotificationsStart, OverlayStart } from 'src/core/public'; +import { CoreStart, NotificationsStart, OverlayStart } from 'src/core/public'; import { ViewMode, GetEmbeddableFactory, GetEmbeddableFactories } from '../../../../types'; import { openAddPanelFlyout } from './open_add_panel_flyout'; import { IContainer } from '../../../../containers'; @@ -38,7 +38,8 @@ export class AddPanelAction implements IAction { private readonly getAllFactories: GetEmbeddableFactories, private readonly overlays: OverlayStart, private readonly notifications: NotificationsStart, - private readonly SavedObjectFinder: React.ComponentType + private readonly uiSettings: CoreStart['uiSettings'], + private readonly savedObjects: CoreStart['savedObjects'] ) {} public getDisplayName() { @@ -66,7 +67,8 @@ export class AddPanelAction implements IAction { getAllFactories: this.getAllFactories, overlays: this.overlays, notifications: this.notifications, - SavedObjectFinder: this.SavedObjectFinder, + savedObjects: this.savedObjects, + uiSettings: this.uiSettings, }); } } diff --git a/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_flyout.tsx b/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_flyout.tsx index 4f2ae7ab19bcb..73b2433c3d51e 100644 --- a/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_flyout.tsx +++ b/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_flyout.tsx @@ -19,7 +19,7 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import React from 'react'; -import { CoreSetup } from 'src/core/public'; +import { CoreSetup, CoreStart } from 'src/core/public'; import { EuiButton, @@ -36,6 +36,7 @@ import { import { IContainer } from '../../../../containers'; import { EmbeddableFactoryNotFoundError } from '../../../../errors'; import { GetEmbeddableFactories, GetEmbeddableFactory } from '../../../../types'; +import { SavedObjectFinder } from '../../../../../../../kibana_react/public'; interface Props { onClose: () => void; @@ -43,7 +44,8 @@ interface Props { getFactory: GetEmbeddableFactory; getAllFactories: GetEmbeddableFactories; notifications: CoreSetup['notifications']; - SavedObjectFinder: React.ComponentType; + savedObjects: CoreStart['savedObjects']; + uiSettings: CoreSetup['uiSettings']; } interface State { @@ -131,7 +133,6 @@ export class AddPanelFlyout extends React.Component { } public render() { - const SavedObjectFinder = this.props.SavedObjectFinder; const savedObjectsFinder = ( { noItemsMessage={i18n.translate('embeddableApi.addPanel.noMatchingObjectsMessage', { defaultMessage: 'No matching objects found.', })} + savedObjects={this.props.savedObjects} + uiSettings={this.props.uiSettings} /> ); diff --git a/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/open_add_panel_flyout.tsx b/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/open_add_panel_flyout.tsx index 481693501066c..1101f71e1d466 100644 --- a/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/open_add_panel_flyout.tsx +++ b/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/open_add_panel_flyout.tsx @@ -17,7 +17,7 @@ * under the License. */ import React from 'react'; -import { NotificationsStart, OverlayStart } from 'src/core/public'; +import { CoreSetup, CoreStart, NotificationsStart, OverlayStart } from 'src/core/public'; import { toMountPoint } from '../../../../../../../kibana_react/public'; import { IContainer } from '../../../../containers'; import { AddPanelFlyout } from './add_panel_flyout'; @@ -29,7 +29,8 @@ export async function openAddPanelFlyout(options: { getAllFactories: GetEmbeddableFactories; overlays: OverlayStart; notifications: NotificationsStart; - SavedObjectFinder: React.ComponentType; + savedObjects: CoreStart['savedObjects']; + uiSettings: CoreSetup['uiSettings']; }) { const { embeddable, @@ -37,7 +38,8 @@ export async function openAddPanelFlyout(options: { getAllFactories, overlays, notifications, - SavedObjectFinder, + savedObjects, + uiSettings, } = options; const flyoutSession = overlays.openFlyout( toMountPoint( @@ -51,7 +53,8 @@ export async function openAddPanelFlyout(options: { getFactory={getFactory} getAllFactories={getAllFactories} notifications={notifications} - SavedObjectFinder={SavedObjectFinder} + savedObjects={savedObjects} + uiSettings={uiSettings} /> ), { diff --git a/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/legacy.ts b/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/legacy.ts index a310403c86b5d..1928d7ac72313 100644 --- a/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/legacy.ts +++ b/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/legacy.ts @@ -22,7 +22,6 @@ import 'uiExports/embeddableFactories'; import 'uiExports/embeddableActions'; import { npSetup, npStart } from 'ui/new_platform'; -import { SavedObjectFinder } from 'ui/saved_objects/components/saved_object_finder'; import { ExitFullScreenButton } from 'ui/exit_full_screen'; import uiRoutes from 'ui/routes'; // @ts-ignore @@ -39,7 +38,6 @@ export const setup = pluginInstance.setup(npSetup.core, { embeddable: npSetup.plugins.embeddable, inspector: npSetup.plugins.inspector, __LEGACY: { - SavedObjectFinder, ExitFullScreenButton, }, }); @@ -64,7 +62,6 @@ export const start = pluginInstance.start(npStart.core, { inspector: npStart.plugins.inspector, uiActions: npStart.plugins.uiActions, __LEGACY: { - SavedObjectFinder, ExitFullScreenButton, onRenderComplete: (renderCompleteListener: () => void) => { if (rendered) { diff --git a/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/plugin.tsx b/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/plugin.tsx index 6b82a67b9fcda..5245935c191ee 100644 --- a/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/plugin.tsx +++ b/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/plugin.tsx @@ -38,6 +38,7 @@ import { ContactCardEmbeddableFactory, } from './embeddable_api'; import { App } from './app'; +import { SavedObjectFinder as SavedObjectFinderNP } from '../../../../../../../src/plugins/kibana_react/public'; import { IEmbeddableStart, IEmbeddableSetup, @@ -47,7 +48,6 @@ export interface SetupDependencies { embeddable: IEmbeddableSetup; inspector: InspectorSetupContract; __LEGACY: { - SavedObjectFinder: React.ComponentType; ExitFullScreenButton: React.ComponentType; }; } @@ -57,7 +57,6 @@ interface StartDependencies { uiActions: IUiActionsStart; inspector: InspectorStartContract; __LEGACY: { - SavedObjectFinder: React.ComponentType; ExitFullScreenButton: React.ComponentType; onRenderComplete: (onRenderComplete: () => void) => void; }; @@ -97,6 +96,14 @@ export class EmbeddableExplorerPublicPlugin contactCardEmbeddableFactory ); + const SavedObjectFinder = (props: any) => ( + + ); + plugins.__LEGACY.onRenderComplete(() => { const root = document.getElementById(REACT_ROOT_ID); ReactDOM.render( @@ -107,8 +114,8 @@ export class EmbeddableExplorerPublicPlugin notifications={core.notifications} overlays={core.overlays} inspector={plugins.inspector} - SavedObjectFinder={plugins.__LEGACY.SavedObjectFinder} I18nContext={core.i18n.Context} + SavedObjectFinder={SavedObjectFinder} />, root ); diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/embeddable.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/embeddable.tsx index 8810871e9161b..e24b438bb9d4d 100644 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/embeddable.tsx +++ b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/embeddable.tsx @@ -16,7 +16,6 @@ import { } from '../../../../../../src/legacy/core_plugins/embeddable_api/public/np_ready/public'; import { start } from '../../../../../../src/legacy/core_plugins/embeddable_api/public/np_ready/public/legacy'; import { EmbeddableExpression } from '../expression_types/embeddable'; -import { SavedObjectFinder } from '../../../../../../src/legacy/ui/public/saved_objects/components/saved_object_finder'; import { RendererStrings } from '../../i18n'; const { embeddable: strings } = RendererStrings; @@ -48,7 +47,8 @@ const renderEmbeddable = (embeddableObject: IEmbeddable, domNode: HTMLElement) = notifications={npStart.core.notifications} overlays={npStart.core.overlays} inspector={npStart.plugins.inspector} - SavedObjectFinder={SavedObjectFinder} + uiSettings={npStart.core.uiSettings} + savedObjects={npStart.core.savedObjects} /> diff --git a/x-pack/legacy/plugins/ml/public/application/jobs/new_job/pages/index_or_search/page.tsx b/x-pack/legacy/plugins/ml/public/application/jobs/new_job/pages/index_or_search/page.tsx index 68013bd243a91..22904b5efdfc2 100644 --- a/x-pack/legacy/plugins/ml/public/application/jobs/new_job/pages/index_or_search/page.tsx +++ b/x-pack/legacy/plugins/ml/public/application/jobs/new_job/pages/index_or_search/page.tsx @@ -15,7 +15,8 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import { SavedObjectFinder } from 'ui/saved_objects/components/saved_object_finder'; +import { npStart } from 'ui/new_platform'; +import { SavedObjectFinder } from '../../../../../../../../../../src/plugins/kibana_react/public'; export interface PageProps { nextStepPath: string; @@ -76,6 +77,8 @@ export const Page: FC = ({ nextStepPath }) => { }, ]} fixedPageSize={RESULTS_PER_PAGE} + uiSettings={npStart.core.uiSettings} + savedObjects={npStart.core.savedObjects} /> diff --git a/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.tsx b/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.tsx index 5a3a689e12d83..35fe367c30780 100644 --- a/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.tsx +++ b/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.tsx @@ -9,7 +9,6 @@ import React, { useEffect, useState } from 'react'; import { createPortalNode, InPortal } from 'react-reverse-portal'; import styled, { css } from 'styled-components'; import { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } from 'ui/documentation_links'; -import { SavedObjectFinder } from 'ui/saved_objects/components/saved_object_finder'; import { EmbeddablePanel } from '../../../../../../../src/legacy/core_plugins/embeddable_api/public/np_ready/public'; import { start } from '../../../../../../../src/legacy/core_plugins/embeddable_api/public/np_ready/public/legacy'; @@ -213,9 +212,10 @@ export const EmbeddedMapComponent = ({ getEmbeddableFactory={start.getEmbeddableFactory} getAllEmbeddableFactories={start.getEmbeddableFactories} notifications={core.notifications} + uiSettings={core.uiSettings} + savedObjects={core.savedObjects} overlays={core.overlays} inspector={plugins.inspector} - SavedObjectFinder={SavedObjectFinder} /> ) : !isLoading && isIndexError ? ( diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/search_selection/search_selection.tsx b/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/search_selection/search_selection.tsx index 1a270505d61a6..23d1a70f1840b 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/search_selection/search_selection.tsx +++ b/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/search_selection/search_selection.tsx @@ -8,8 +8,8 @@ import { EuiModalBody, EuiModalHeader, EuiModalHeaderTitle } from '@elastic/eui' import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import React, { FC } from 'react'; - -import { SavedObjectFinder } from 'ui/saved_objects/components/saved_object_finder'; +import { SavedObjectFinder } from '../../../../../../../../../../src/plugins/kibana_react/public'; +import { useAppDependencies } from '../../../../app_dependencies'; interface SearchSelectionProps { onSearchSelected: (searchId: string, searchType: string) => void; @@ -17,56 +17,63 @@ interface SearchSelectionProps { const fixedPageSize: number = 8; -export const SearchSelection: FC = ({ onSearchSelected }) => ( - <> - - - {' '} - /{' '} - = ({ onSearchSelected }) => { + const { + core: { uiSettings, savedObjects }, + } = useAppDependencies(); + return ( + <> + + + {' '} + /{' '} + + + + + 'search', + name: i18n.translate( + 'xpack.transform.newTransform.searchSelection.savedObjectType.search', + { + defaultMessage: 'Saved search', + } + ), + }, + { + type: 'index-pattern', + getIconForSavedObject: () => 'indexPatternApp', + name: i18n.translate( + 'xpack.transform.newTransform.searchSelection.savedObjectType.indexPattern', + { + defaultMessage: 'Index pattern', + } + ), + }, + ]} + fixedPageSize={fixedPageSize} + uiSettings={uiSettings} + savedObjects={savedObjects} /> - - - - 'search', - name: i18n.translate( - 'xpack.transform.newTransform.searchSelection.savedObjectType.search', - { - defaultMessage: 'Saved search', - } - ), - }, - { - type: 'index-pattern', - getIconForSavedObject: () => 'indexPatternApp', - name: i18n.translate( - 'xpack.transform.newTransform.searchSelection.savedObjectType.indexPattern', - { - defaultMessage: 'Index pattern', - } - ), - }, - ]} - fixedPageSize={fixedPageSize} - /> - - -); + + + ); +}; diff --git a/x-pack/legacy/plugins/transform/public/plugin.ts b/x-pack/legacy/plugins/transform/public/plugin.ts index e7cc83d16b3b9..08a3a06fc24fc 100644 --- a/x-pack/legacy/plugins/transform/public/plugin.ts +++ b/x-pack/legacy/plugins/transform/public/plugin.ts @@ -27,12 +27,21 @@ const template = `
; +export type AppCore = Pick; export interface AppPlugins { management: { From a2fbc4727a089a8ecd7aad5502f455d929b964c8 Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Wed, 4 Dec 2019 15:25:17 +0100 Subject: [PATCH 2/8] remove legacy saved object finder --- .../components/top_nav/open_search_panel.js | 11 +- .../search_selection/search_selection.tsx | 4 +- .../components/saved_object_finder.tsx | 108 ------------------ .../actions/expand_panel_action.test.tsx | 3 +- .../actions/open_replace_panel_flyout.tsx | 16 +-- .../actions/replace_panel_action.test.tsx | 48 ++------ .../public/actions/replace_panel_action.tsx | 4 - .../public/actions/replace_panel_flyout.tsx | 11 +- .../embeddable/dashboard_container.test.tsx | 3 +- .../public/embeddable/dashboard_container.tsx | 3 +- .../embeddable/grid/dashboard_grid.test.tsx | 3 +- .../public/embeddable/grid/dashboard_grid.tsx | 3 +- .../viewport/dashboard_viewport.test.tsx | 3 +- .../public/plugin.tsx | 20 +--- .../public/tests/dashboard_container.test.tsx | 6 +- .../lib/panel/embeddable_panel.test.tsx | 15 ++- .../add_panel/add_panel_action.test.tsx | 6 +- .../add_panel/add_panel_flyout.test.tsx | 6 +- .../add_panel/add_panel_flyout.tsx | 4 +- .../embeddables/hello_world_container.tsx | 6 +- .../hello_world_container_component.tsx | 6 +- .../public/tests/apply_filter_action.test.ts | 6 +- .../embeddable/public/tests/container.test.ts | 24 ++-- .../tests/customize_panel_modal.test.tsx | 3 +- .../public/tests/explicit_input.test.ts | 6 +- .../saved_object_finder.test.tsx | 2 +- .../saved_objects/saved_object_finder.tsx | 28 ++++- .../public/np_ready/public/app/app.tsx | 12 +- .../app/dashboard_container_example.tsx | 6 +- .../app/hello_world_container_example.tsx | 9 +- .../app/hello_world_embeddable_example.tsx | 6 +- .../public/np_ready/public/plugin.tsx | 12 +- .../components/embeddable_flyout/flyout.tsx | 4 +- .../graph/public/components/source_picker.tsx | 4 +- .../new_job/pages/index_or_search/page.tsx | 4 +- .../search_selection/search_selection.tsx | 4 +- 36 files changed, 158 insertions(+), 261 deletions(-) delete mode 100644 src/legacy/ui/public/saved_objects/components/saved_object_finder.tsx diff --git a/src/legacy/core_plugins/kibana/public/discover/components/top_nav/open_search_panel.js b/src/legacy/core_plugins/kibana/public/discover/components/top_nav/open_search_panel.js index 0c3b52fbf0640..ec1763f44f25f 100644 --- a/src/legacy/core_plugins/kibana/public/discover/components/top_nav/open_search_panel.js +++ b/src/legacy/core_plugins/kibana/public/discover/components/top_nav/open_search_panel.js @@ -32,11 +32,16 @@ import { EuiFlyoutBody, EuiTitle, } from '@elastic/eui'; -import { SavedObjectFinder } from 'ui/saved_objects/components/saved_object_finder'; +import { SavedObjectFinderUi } from '../../../../../../../plugins/kibana_react/public'; +import { getServices } from '../../kibana_services'; const SEARCH_OBJECT_TYPE = 'search'; export function OpenSearchPanel(props) { + const { + core: { uiSettings, savedObjects }, + } = getServices(); + return ( @@ -50,7 +55,7 @@ export function OpenSearchPanel(props) { - diff --git a/src/legacy/core_plugins/kibana/public/visualize/wizard/search_selection/search_selection.tsx b/src/legacy/core_plugins/kibana/public/visualize/wizard/search_selection/search_selection.tsx index 41607bdea7503..338623975e4c5 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/wizard/search_selection/search_selection.tsx +++ b/src/legacy/core_plugins/kibana/public/visualize/wizard/search_selection/search_selection.tsx @@ -23,7 +23,7 @@ import { FormattedMessage } from '@kbn/i18n/react'; import React from 'react'; import { VisType, getServices } from '../../kibana_services'; -import { SavedObjectFinder } from '../../../../../../../plugins/kibana_react/public'; +import { SavedObjectFinderUi } from '../../../../../../../plugins/kibana_react/public'; interface SearchSelectionProps { onSearchSelected: (searchId: string, searchType: string) => void; @@ -54,7 +54,7 @@ export class SearchSelection extends React.Component { - { - type: string; - name: string; - getIconForSavedObject(savedObject: SimpleSavedObject): IconType; - getTooltipForSavedObject?(savedObject: SimpleSavedObject): string; - showSavedObject?(savedObject: SimpleSavedObject): boolean; -} - -interface BaseSavedObjectFinder { - /** - * @deprecated - * - * Use component in `src/plugins/kibana_react` instead. - */ - onChoose?: ( - id: SimpleSavedObject['id'], - type: SimpleSavedObject['type'], - name: string - ) => void; - /** - * @deprecated - * - * Use component in `src/plugins/kibana_react` instead. - */ - noItemsMessage?: React.ReactNode; - /** - * @deprecated - * - * Use component in `src/plugins/kibana_react` instead. - */ - savedObjectMetaData: Array>; - /** - * @deprecated - * - * Use component in `src/plugins/kibana_react` instead. - */ - showFilter?: boolean; -} - -interface SavedObjectFinderFixedPage extends BaseSavedObjectFinder { - /** - * @deprecated - * - * Use component in `src/plugins/kibana_react` instead. - */ - initialPageSize?: undefined; - /** - * @deprecated - * - * Use component in `src/plugins/kibana_react` instead. - */ - fixedPageSize: number; -} - -interface SavedObjectFinderInitialPageSize extends BaseSavedObjectFinder { - /** - * @deprecated - * - * Use component in `src/plugins/kibana_react` instead. - */ - initialPageSize?: 5 | 10 | 15 | 25; - /** - * @deprecated - * - * Use component in `src/plugins/kibana_react` instead. - */ - fixedPageSize?: undefined; -} -type SavedObjectFinderProps = SavedObjectFinderFixedPage | SavedObjectFinderInitialPageSize; - -export const SavedObjectFinder: React.FC = props => ( - -); diff --git a/src/plugins/dashboard_embeddable_container/public/actions/expand_panel_action.test.tsx b/src/plugins/dashboard_embeddable_container/public/actions/expand_panel_action.test.tsx index f8c05170e8f67..69e1eb86b71ec 100644 --- a/src/plugins/dashboard_embeddable_container/public/actions/expand_panel_action.test.tsx +++ b/src/plugins/dashboard_embeddable_container/public/actions/expand_panel_action.test.tsx @@ -42,7 +42,6 @@ let embeddable: ContactCardEmbeddable; beforeEach(async () => { const options: DashboardOptions = { ExitFullScreenButton: () => null, - SavedObjectFinder: () => null, application: {} as any, embeddable: { getEmbeddableFactory: (id: string) => embeddableFactories.get(id)!, @@ -52,6 +51,8 @@ beforeEach(async () => { overlays: {} as any, savedObjectMetaData: {} as any, uiActions: {} as any, + uiSettings: {} as any, + savedObjects: {} as any, }; const input = getSampleDashboardInput({ panels: { diff --git a/src/plugins/dashboard_embeddable_container/public/actions/open_replace_panel_flyout.tsx b/src/plugins/dashboard_embeddable_container/public/actions/open_replace_panel_flyout.tsx index f15d538703e21..1a17962ad4e58 100644 --- a/src/plugins/dashboard_embeddable_container/public/actions/open_replace_panel_flyout.tsx +++ b/src/plugins/dashboard_embeddable_container/public/actions/open_replace_panel_flyout.tsx @@ -31,19 +31,10 @@ import { export async function openReplacePanelFlyout(options: { embeddable: IContainer; core: CoreStart; - savedObjectFinder: React.ComponentType; - notifications: CoreStart['notifications']; panelToRemove: IEmbeddable; getEmbeddableFactories: IEmbeddableStart['getEmbeddableFactories']; }) { - const { - embeddable, - core, - panelToRemove, - savedObjectFinder, - notifications, - getEmbeddableFactories, - } = options; + const { embeddable, core, panelToRemove, getEmbeddableFactories } = options; const flyoutSession = core.overlays.openFlyout( toMountPoint( ), diff --git a/src/plugins/dashboard_embeddable_container/public/actions/replace_panel_action.test.tsx b/src/plugins/dashboard_embeddable_container/public/actions/replace_panel_action.test.tsx index de29e1dec85a8..64b62e236bbcf 100644 --- a/src/plugins/dashboard_embeddable_container/public/actions/replace_panel_action.test.tsx +++ b/src/plugins/dashboard_embeddable_container/public/actions/replace_panel_action.test.tsx @@ -43,7 +43,6 @@ let embeddable: ContactCardEmbeddable; beforeEach(async () => { const options: DashboardOptions = { ExitFullScreenButton: () => null, - SavedObjectFinder: () => null, application: {} as any, embeddable: { getEmbeddableFactory: (id: string) => embeddableFactories.get(id)!, @@ -51,6 +50,8 @@ beforeEach(async () => { inspector: {} as any, notifications: {} as any, overlays: {} as any, + uiSettings: {} as any, + savedObjects: {} as any, savedObjectMetaData: {} as any, uiActions: {} as any, }; @@ -81,27 +82,13 @@ beforeEach(async () => { test('Executes the replace panel action', async () => { let core: any; - let SavedObjectFinder: any; - let notifications: any; - const action = new ReplacePanelAction( - core, - SavedObjectFinder, - notifications, - getEmbeddableFactories - ); + const action = new ReplacePanelAction(core, getEmbeddableFactories); action.execute({ embeddable }); }); test('Is not compatible when embeddable is not in a dashboard container', async () => { let core: any; - let SavedObjectFinder: any; - let notifications: any; - const action = new ReplacePanelAction( - core, - SavedObjectFinder, - notifications, - getEmbeddableFactories - ); + const action = new ReplacePanelAction(core, getEmbeddableFactories); expect( await action.isCompatible({ embeddable: new ContactCardEmbeddable( @@ -114,14 +101,7 @@ test('Is not compatible when embeddable is not in a dashboard container', async test('Execute throws an error when called with an embeddable not in a parent', async () => { let core: any; - let SavedObjectFinder: any; - let notifications: any; - const action = new ReplacePanelAction( - core, - SavedObjectFinder, - notifications, - getEmbeddableFactories - ); + const action = new ReplacePanelAction(core, getEmbeddableFactories); async function check() { await action.execute({ embeddable: container }); } @@ -130,26 +110,12 @@ test('Execute throws an error when called with an embeddable not in a parent', a test('Returns title', async () => { let core: any; - let SavedObjectFinder: any; - let notifications: any; - const action = new ReplacePanelAction( - core, - SavedObjectFinder, - notifications, - getEmbeddableFactories - ); + const action = new ReplacePanelAction(core, getEmbeddableFactories); expect(action.getDisplayName({ embeddable })).toBeDefined(); }); test('Returns an icon', async () => { let core: any; - let SavedObjectFinder: any; - let notifications: any; - const action = new ReplacePanelAction( - core, - SavedObjectFinder, - notifications, - getEmbeddableFactories - ); + const action = new ReplacePanelAction(core, getEmbeddableFactories); expect(action.getIconType({ embeddable })).toBeDefined(); }); diff --git a/src/plugins/dashboard_embeddable_container/public/actions/replace_panel_action.tsx b/src/plugins/dashboard_embeddable_container/public/actions/replace_panel_action.tsx index 78ce6bdc4c58f..f06e578b8a10f 100644 --- a/src/plugins/dashboard_embeddable_container/public/actions/replace_panel_action.tsx +++ b/src/plugins/dashboard_embeddable_container/public/actions/replace_panel_action.tsx @@ -41,8 +41,6 @@ export class ReplacePanelAction implements IAction { constructor( private core: CoreStart, - private savedobjectfinder: React.ComponentType, - private notifications: CoreStart['notifications'], private getEmbeddableFactories: IEmbeddableStart['getEmbeddableFactories'] ) {} @@ -82,8 +80,6 @@ export class ReplacePanelAction implements IAction { openReplacePanelFlyout({ embeddable: dash, core: this.core, - savedObjectFinder: this.savedobjectfinder, - notifications: this.notifications, panelToRemove: view, getEmbeddableFactories: this.getEmbeddableFactories, }); diff --git a/src/plugins/dashboard_embeddable_container/public/actions/replace_panel_flyout.tsx b/src/plugins/dashboard_embeddable_container/public/actions/replace_panel_flyout.tsx index 36313353e3c33..885d0bfaec254 100644 --- a/src/plugins/dashboard_embeddable_container/public/actions/replace_panel_flyout.tsx +++ b/src/plugins/dashboard_embeddable_container/public/actions/replace_panel_flyout.tsx @@ -22,14 +22,16 @@ import React from 'react'; import { EuiFlyout, EuiFlyoutBody, EuiFlyoutHeader, EuiTitle } from '@elastic/eui'; import { GetEmbeddableFactories } from 'src/plugins/embeddable/public'; import { DashboardPanelState } from '../embeddable'; -import { NotificationsStart, Toast } from '../../../../core/public'; +import { CoreStart, NotificationsStart, Toast } from '../../../../core/public'; import { IContainer, IEmbeddable, EmbeddableInput, EmbeddableOutput } from '../embeddable_plugin'; +import { SavedObjectFinderUi } from '../../../kibana_react/public'; interface Props { container: IContainer; - savedObjectsFinder: React.ComponentType; onClose: () => void; notifications: NotificationsStart; + uiSettings: CoreStart['uiSettings']; + savedObjects: CoreStart['savedObjects']; panelToRemove: IEmbeddable; getEmbeddableFactories: GetEmbeddableFactories; } @@ -94,9 +96,8 @@ export class ReplacePanelFlyout extends React.Component { }; public render() { - const SavedObjectFinder = this.props.savedObjectsFinder; const savedObjectsFinder = ( - { .map(({ savedObjectMetaData }) => savedObjectMetaData as any)} showFilter={true} onChoose={this.onReplacePanel} + uiSettings={this.props.uiSettings} + savedObjects={this.props.savedObjects} /> ); diff --git a/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container.test.tsx b/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container.test.tsx index 770c46c62e42f..1dd5c6ab15c7f 100644 --- a/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container.test.tsx +++ b/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container.test.tsx @@ -41,9 +41,10 @@ const options: DashboardContainerOptions = { notifications: {} as any, overlays: {} as any, inspector: {} as any, - SavedObjectFinder: () => null, ExitFullScreenButton: () => null, uiActions: {} as any, + uiSettings: {} as any, + savedObjects: {} as any, }; beforeEach(() => { diff --git a/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container.tsx b/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container.tsx index 684aa93779bc1..b9866f3a71733 100644 --- a/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container.tsx +++ b/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container.tsx @@ -77,9 +77,10 @@ export interface DashboardContainerOptions { application: CoreStart['application']; overlays: CoreStart['overlays']; notifications: CoreStart['notifications']; + savedObjects: CoreStart['savedObjects']; + uiSettings: CoreStart['uiSettings']; embeddable: IEmbeddableStart; inspector: InspectorStartContract; - SavedObjectFinder: React.ComponentType; ExitFullScreenButton: React.ComponentType; uiActions: IUiActionsStart; } diff --git a/src/plugins/dashboard_embeddable_container/public/embeddable/grid/dashboard_grid.test.tsx b/src/plugins/dashboard_embeddable_container/public/embeddable/grid/dashboard_grid.test.tsx index e4338dc89153d..4581aa1f0a421 100644 --- a/src/plugins/dashboard_embeddable_container/public/embeddable/grid/dashboard_grid.test.tsx +++ b/src/plugins/dashboard_embeddable_container/public/embeddable/grid/dashboard_grid.test.tsx @@ -66,9 +66,10 @@ function prepare(props?: Partial) { notifications: {} as any, overlays: {} as any, inspector: {} as any, - SavedObjectFinder: () => null, ExitFullScreenButton: () => null, uiActions: {} as any, + uiSettings: {} as any, + savedObjects: {} as any, }; dashboardContainer = new DashboardContainer(initialInput, options); const defaultTestProps: DashboardGridProps = { diff --git a/src/plugins/dashboard_embeddable_container/public/embeddable/grid/dashboard_grid.tsx b/src/plugins/dashboard_embeddable_container/public/embeddable/grid/dashboard_grid.tsx index 2b905626d0db5..6a8ee13e2a971 100644 --- a/src/plugins/dashboard_embeddable_container/public/embeddable/grid/dashboard_grid.tsx +++ b/src/plugins/dashboard_embeddable_container/public/embeddable/grid/dashboard_grid.tsx @@ -276,7 +276,8 @@ class DashboardGridUi extends React.Component { overlays={this.props.kibana.services.overlays} notifications={this.props.kibana.services.notifications} inspector={this.props.kibana.services.inspector} - uiSettings={this.props.kibana.services.} + uiSettings={this.props.kibana.services.uiSettings} + savedObjects={this.props.kibana.services.savedObjects} />
); diff --git a/src/plugins/dashboard_embeddable_container/public/embeddable/viewport/dashboard_viewport.test.tsx b/src/plugins/dashboard_embeddable_container/public/embeddable/viewport/dashboard_viewport.test.tsx index 7b83407bf8063..c40384acfa3a7 100644 --- a/src/plugins/dashboard_embeddable_container/public/embeddable/viewport/dashboard_viewport.test.tsx +++ b/src/plugins/dashboard_embeddable_container/public/embeddable/viewport/dashboard_viewport.test.tsx @@ -57,7 +57,8 @@ function getProps( notifications: {} as any, overlays: {} as any, inspector: {} as any, - SavedObjectFinder: () => null, + uiSettings: {} as any, + savedObjects: {} as any, ExitFullScreenButton, uiActions: {} as any, }; diff --git a/src/plugins/dashboard_embeddable_container/public/plugin.tsx b/src/plugins/dashboard_embeddable_container/public/plugin.tsx index 79cc9b6980545..9753e7fcae5a5 100644 --- a/src/plugins/dashboard_embeddable_container/public/plugin.tsx +++ b/src/plugins/dashboard_embeddable_container/public/plugin.tsx @@ -27,8 +27,6 @@ import { ExpandPanelAction, ReplacePanelAction } from '.'; import { DashboardContainerFactory } from './embeddable/dashboard_container_factory'; import { Start as InspectorStartContract } from '../../../plugins/inspector/public'; import { - SavedObjectFinder as SavedObjectFinderUi, - SavedObjectFinderProps, ExitFullScreenButton as ExitFullScreenButtonUi, ExitFullScreenButtonProps, } from '../../../plugins/kibana_react/public'; @@ -58,20 +56,9 @@ export class DashboardEmbeddableContainerPublicPlugin } public start(core: CoreStart, plugins: StartDependencies): Start { - const { application, notifications, overlays } = core; + const { application, notifications, overlays, uiSettings, savedObjects } = core; const { embeddable, inspector, uiActions } = plugins; - const SavedObjectFinder: React.FC> = props => ( - - ); - const useHideChrome = () => { React.useEffect(() => { core.chrome.setIsVisible(false); @@ -86,8 +73,6 @@ export class DashboardEmbeddableContainerPublicPlugin const changeViewAction = new ReplacePanelAction( core, - SavedObjectFinder, - notifications, plugins.embeddable.getEmbeddableFactories ); uiActions.registerAction(changeViewAction); @@ -99,9 +84,10 @@ export class DashboardEmbeddableContainerPublicPlugin overlays, embeddable, inspector, - SavedObjectFinder, ExitFullScreenButton, uiActions, + uiSettings, + savedObjects, }); embeddable.registerEmbeddableFactory(factory.type, factory); diff --git a/src/plugins/dashboard_embeddable_container/public/tests/dashboard_container.test.tsx b/src/plugins/dashboard_embeddable_container/public/tests/dashboard_container.test.tsx index 6a3b69af60d6b..fd2b294663642 100644 --- a/src/plugins/dashboard_embeddable_container/public/tests/dashboard_container.test.tsx +++ b/src/plugins/dashboard_embeddable_container/public/tests/dashboard_container.test.tsx @@ -64,7 +64,8 @@ test('DashboardContainer in edit mode shows edit mode actions', async () => { notifications: {} as any, overlays: {} as any, inspector: {} as any, - SavedObjectFinder: () => null, + uiSettings: {} as any, + savedObjects: {} as any, ExitFullScreenButton: () => null, uiActions: {} as any, }; @@ -89,7 +90,8 @@ test('DashboardContainer in edit mode shows edit mode actions', async () => { notifications={{} as any} overlays={{} as any} inspector={inspector} - SavedObjectFinder={() => null} + uiSettings={{} as any} + savedObjects={{} as any} /> diff --git a/src/plugins/embeddable/public/lib/panel/embeddable_panel.test.tsx b/src/plugins/embeddable/public/lib/panel/embeddable_panel.test.tsx index 9eed400daf9c9..01d087875a3d7 100644 --- a/src/plugins/embeddable/public/lib/panel/embeddable_panel.test.tsx +++ b/src/plugins/embeddable/public/lib/panel/embeddable_panel.test.tsx @@ -161,8 +161,9 @@ test('HelloWorldContainer in view mode hides edit mode actions', async () => { getEmbeddableFactory={(() => undefined) as any} notifications={{} as any} overlays={{} as any} + uiSettings={{} as any} + savedObjects={{} as any} inspector={inspector} - SavedObjectFinder={() => null} /> ); @@ -199,7 +200,8 @@ test('HelloWorldContainer in edit mode shows edit mode actions', async () => { notifications={{} as any} overlays={{} as any} inspector={inspector} - SavedObjectFinder={() => null} + uiSettings={{} as any} + savedObjects={{} as any} /> ); @@ -261,7 +263,8 @@ test('Updates when hidePanelTitles is toggled', async () => { notifications={{} as any} overlays={{} as any} inspector={inspector} - SavedObjectFinder={() => null} + uiSettings={{} as any} + savedObjects={{} as any} /> ); @@ -313,7 +316,8 @@ test('Check when hide header option is false', async () => { notifications={{} as any} overlays={{} as any} inspector={inspector} - SavedObjectFinder={() => null} + uiSettings={{} as any} + savedObjects={{} as any} hideHeader={false} /> @@ -350,7 +354,8 @@ test('Check when hide header option is true', async () => { notifications={{} as any} overlays={{} as any} inspector={inspector} - SavedObjectFinder={() => null} + uiSettings={{} as any} + savedObjects={{} as any} hideHeader={true} /> diff --git a/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_action.test.tsx b/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_action.test.tsx index 47113ffc59561..b0c9e16cc4dce 100644 --- a/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_action.test.tsx +++ b/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_action.test.tsx @@ -48,7 +48,8 @@ beforeEach(async () => { () => [] as any, start.overlays, start.notifications, - () => null + start.uiSettings, + start.savedObjects ); const derivedFilter: esFilters.Filter = { @@ -83,7 +84,8 @@ test('Is not compatible when container is in view mode', async () => { () => [] as any, start.overlays, start.notifications, - () => null + start.uiSettings, + start.savedObjects ); container.updateInput({ viewMode: ViewMode.VIEW }); expect(await addPanelAction.isCompatible({ embeddable: container })).toBe(false); diff --git a/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_flyout.test.tsx b/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_flyout.test.tsx index fd8f286a9d8f6..c69c25837f80e 100644 --- a/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_flyout.test.tsx +++ b/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_flyout.test.tsx @@ -63,7 +63,8 @@ test('createNewEmbeddable() add embeddable to container', async () => { getFactory={getEmbeddableFactory} getAllFactories={() => new Set([contactCardEmbeddableFactory]).values()} notifications={core.notifications} - SavedObjectFinder={() => null} + uiSettings={core.uiSettings} + savedObjects={core.savedObjects} /> ) as ReactWrapper; @@ -108,7 +109,8 @@ test('selecting embeddable in "Create new ..." list calls createNewEmbeddable()' getFactory={getEmbeddableFactory} getAllFactories={() => new Set([contactCardEmbeddableFactory]).values()} notifications={core.notifications} - SavedObjectFinder={() => null} + uiSettings={core.uiSettings} + savedObjects={core.savedObjects} /> ) as ReactWrapper; diff --git a/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_flyout.tsx b/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_flyout.tsx index 73b2433c3d51e..cc49e0d8777ab 100644 --- a/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_flyout.tsx +++ b/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_flyout.tsx @@ -36,7 +36,7 @@ import { import { IContainer } from '../../../../containers'; import { EmbeddableFactoryNotFoundError } from '../../../../errors'; import { GetEmbeddableFactories, GetEmbeddableFactory } from '../../../../types'; -import { SavedObjectFinder } from '../../../../../../../kibana_react/public'; +import { SavedObjectFinderUi } from '../../../../../../../kibana_react/public'; interface Props { onClose: () => void; @@ -134,7 +134,7 @@ export class AddPanelFlyout extends React.Component { public render() { const savedObjectsFinder = ( - ; } export class HelloWorldContainer extends Container { @@ -83,7 +84,8 @@ export class HelloWorldContainer extends Container , node diff --git a/src/plugins/embeddable/public/lib/test_samples/embeddables/hello_world_container_component.tsx b/src/plugins/embeddable/public/lib/test_samples/embeddables/hello_world_container_component.tsx index 7c0e09eff1d50..8cd30cde42f94 100644 --- a/src/plugins/embeddable/public/lib/test_samples/embeddables/hello_world_container_component.tsx +++ b/src/plugins/embeddable/public/lib/test_samples/embeddables/hello_world_container_component.tsx @@ -34,7 +34,8 @@ interface Props { overlays: CoreStart['overlays']; notifications: CoreStart['notifications']; inspector: InspectorStartContract; - SavedObjectFinder: React.ComponentType; + uiSettings: CoreStart['uiSettings']; + savedObjects: CoreStart['savedObjects']; } interface State { @@ -112,8 +113,9 @@ export class HelloWorldContainerComponent extends Component { getAllEmbeddableFactories={this.props.getAllEmbeddableFactories} overlays={this.props.overlays} notifications={this.props.notifications} + uiSettings={this.props.uiSettings} + savedObjects={this.props.savedObjects} inspector={this.props.inspector} - SavedObjectFinder={this.props.SavedObjectFinder} /> ); diff --git a/src/plugins/embeddable/public/tests/apply_filter_action.test.ts b/src/plugins/embeddable/public/tests/apply_filter_action.test.ts index 0721acb1a1fba..2c3299f3bc630 100644 --- a/src/plugins/embeddable/public/tests/apply_filter_action.test.ts +++ b/src/plugins/embeddable/public/tests/apply_filter_action.test.ts @@ -106,8 +106,9 @@ test('ApplyFilterAction is incompatible if the root container does not accept a getAllEmbeddableFactories: api.getEmbeddableFactories, overlays: coreStart.overlays, notifications: coreStart.notifications, + uiSettings: coreStart.uiSettings, + savedObjects: coreStart.savedObjects, inspector, - SavedObjectFinder: () => null, } ); @@ -146,7 +147,8 @@ test('trying to execute on incompatible context throws an error ', async () => { overlays: coreStart.overlays, notifications: coreStart.notifications, inspector, - SavedObjectFinder: () => null, + uiSettings: coreStart.uiSettings, + savedObjects: coreStart.savedObjects, } ); diff --git a/src/plugins/embeddable/public/tests/container.test.ts b/src/plugins/embeddable/public/tests/container.test.ts index f97c26a41b901..3385bf9354a91 100644 --- a/src/plugins/embeddable/public/tests/container.test.ts +++ b/src/plugins/embeddable/public/tests/container.test.ts @@ -73,7 +73,8 @@ async function creatHelloWorldContainerAndEmbeddable( overlays: coreStart.overlays, notifications: coreStart.notifications, inspector: {} as any, - SavedObjectFinder: () => null, + uiSettings: coreStart.uiSettings, + savedObjects: coreStart.savedObjects, }); const embeddable = await container.addNewEmbeddable< ContactCardEmbeddableInput, @@ -146,7 +147,8 @@ test('Container.removeEmbeddable removes and cleans up', async done => { overlays: coreStart.overlays, notifications: coreStart.notifications, inspector: {} as any, - SavedObjectFinder: () => null, + uiSettings: coreStart.uiSettings, + savedObjects: coreStart.savedObjects, } ); const embeddable = await container.addNewEmbeddable< @@ -326,7 +328,8 @@ test(`Container updates its state when a child's input is updated`, async done = notifications: coreStart.notifications, overlays: coreStart.overlays, inspector: {} as any, - SavedObjectFinder: () => null, + uiSettings: coreStart.uiSettings, + savedObjects: coreStart.savedObjects, }); const cloneSubscription = Rx.merge( containerClone.getOutput$(), @@ -576,7 +579,8 @@ test('Container changes made directly after adding a new embeddable are propagat overlays: coreStart.overlays, notifications: coreStart.notifications, inspector: {} as any, - SavedObjectFinder: () => null, + uiSettings: coreStart.uiSettings, + savedObjects: coreStart.savedObjects, } ); @@ -708,7 +712,8 @@ test('untilEmbeddableLoaded() throws an error if there is no such child panel in overlays: coreStart.overlays, notifications: coreStart.notifications, inspector: {} as any, - SavedObjectFinder: () => null, + uiSettings: coreStart.uiSettings, + savedObjects: coreStart.savedObjects, } ); @@ -742,7 +747,8 @@ test('untilEmbeddableLoaded() resolves if child is loaded in the container', asy overlays: coreStart.overlays, notifications: coreStart.notifications, inspector: {} as any, - SavedObjectFinder: () => null, + uiSettings: coreStart.uiSettings, + savedObjects: coreStart.savedObjects, } ); @@ -780,7 +786,8 @@ test('untilEmbeddableLoaded resolves with undefined if child is subsequently rem overlays: coreStart.overlays, notifications: coreStart.notifications, inspector: {} as any, - SavedObjectFinder: () => null, + uiSettings: coreStart.uiSettings, + savedObjects: coreStart.savedObjects, } ); @@ -820,7 +827,8 @@ test('adding a panel then subsequently removing it before its loaded removes the overlays: coreStart.overlays, notifications: coreStart.notifications, inspector: {} as any, - SavedObjectFinder: () => null, + uiSettings: coreStart.uiSettings, + savedObjects: coreStart.savedObjects, } ); diff --git a/src/plugins/embeddable/public/tests/customize_panel_modal.test.tsx b/src/plugins/embeddable/public/tests/customize_panel_modal.test.tsx index 70d7c99d3fb9d..a1b85384d9b6b 100644 --- a/src/plugins/embeddable/public/tests/customize_panel_modal.test.tsx +++ b/src/plugins/embeddable/public/tests/customize_panel_modal.test.tsx @@ -65,7 +65,8 @@ beforeEach(async () => { overlays: coreStart.overlays, notifications: coreStart.notifications, inspector: {} as any, - SavedObjectFinder: () => null, + uiSettings: coreStart.uiSettings, + savedObjects: coreStart.savedObjects, } ); const contactCardEmbeddable = await container.addNewEmbeddable< diff --git a/src/plugins/embeddable/public/tests/explicit_input.test.ts b/src/plugins/embeddable/public/tests/explicit_input.test.ts index 47c4b0944cef2..a7fbc4c96b69b 100644 --- a/src/plugins/embeddable/public/tests/explicit_input.test.ts +++ b/src/plugins/embeddable/public/tests/explicit_input.test.ts @@ -86,7 +86,8 @@ test('Explicit embeddable input mapped to undefined with no inherited value will notifications: coreStart.notifications, overlays: coreStart.overlays, inspector: {} as any, - SavedObjectFinder: () => null, + uiSettings: coreStart.uiSettings, + savedObjects: coreStart.savedObjects, } ); @@ -134,7 +135,8 @@ test('Explicit input tests in async situations', (done: () => void) => { notifications: coreStart.notifications, overlays: coreStart.overlays, inspector: {} as any, - SavedObjectFinder: () => null, + uiSettings: coreStart.uiSettings, + savedObjects: coreStart.savedObjects, } ); diff --git a/src/plugins/kibana_react/public/saved_objects/saved_object_finder.test.tsx b/src/plugins/kibana_react/public/saved_objects/saved_object_finder.test.tsx index 5b3d638f9e935..c1125fcf7355b 100644 --- a/src/plugins/kibana_react/public/saved_objects/saved_object_finder.test.tsx +++ b/src/plugins/kibana_react/public/saved_objects/saved_object_finder.test.tsx @@ -35,7 +35,7 @@ import { IconType } from '@elastic/eui'; import { shallow } from 'enzyme'; import React from 'react'; import * as sinon from 'sinon'; -import { SavedObjectFinder } from './saved_object_finder'; +import { SavedObjectFinderUi as SavedObjectFinder } from './saved_object_finder'; // eslint-disable-next-line import { coreMock } from '../../../../core/public/mocks'; diff --git a/src/plugins/kibana_react/public/saved_objects/saved_object_finder.tsx b/src/plugins/kibana_react/public/saved_objects/saved_object_finder.tsx index c65d428958767..51fbbd2ba3046 100644 --- a/src/plugins/kibana_react/public/saved_objects/saved_object_finder.tsx +++ b/src/plugins/kibana_react/public/saved_objects/saved_object_finder.tsx @@ -46,6 +46,7 @@ import { i18n } from '@kbn/i18n'; import { SavedObjectAttributes } from '../../../../core/server'; import { SimpleSavedObject, CoreStart } from '../../../../core/public'; +import { useKibana } from '../context'; // TODO the typings for EuiListGroup are incorrect - maxWidth is missing. This can be removed when the types are adjusted const FixedEuiListGroup = (EuiListGroup as any) as React.FunctionComponent< @@ -104,12 +105,18 @@ interface SavedObjectFinderInitialPageSize extends BaseSavedObjectFinder { initialPageSize?: 5 | 10 | 15 | 25; fixedPageSize?: undefined; } -export type SavedObjectFinderProps = { + +export type SavedObjectFinderProps = SavedObjectFinderFixedPage | SavedObjectFinderInitialPageSize; + +export type SavedObjectFinderUiProps = { savedObjects: CoreStart['savedObjects']; uiSettings: CoreStart['uiSettings']; -} & (SavedObjectFinderFixedPage | SavedObjectFinderInitialPageSize); +} & SavedObjectFinderProps; -class SavedObjectFinder extends React.Component { +class SavedObjectFinderUi extends React.Component< + SavedObjectFinderUiProps, + SavedObjectFinderState +> { public static propTypes = { onChoose: PropTypes.func, noItemsMessage: PropTypes.node, @@ -174,7 +181,7 @@ class SavedObjectFinder extends React.Component { + const { services } = useKibana(); + return ( + + ); +}; + +export { SavedObjectFinder, SavedObjectFinderUi }; diff --git a/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/app/app.tsx b/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/app/app.tsx index c0ed2b027f0e4..1c8cbde566859 100644 --- a/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/app/app.tsx +++ b/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/app/app.tsx @@ -36,7 +36,8 @@ export interface AppProps { overlays: CoreStart['overlays']; notifications: CoreStart['notifications']; inspector: InspectorStartContract; - SavedObjectFinder: React.ComponentType; + uiSettings: CoreStart['uiSettings']; + savedObjects: CoreStart['savedObjects']; I18nContext: CoreStart['i18n']['Context']; } @@ -105,7 +106,8 @@ export class App extends Component { overlays={this.props.overlays} notifications={this.props.notifications} inspector={this.props.inspector} - SavedObjectFinder={this.props.SavedObjectFinder} + uiSettings={this.props.uiSettings} + savedObjects={this.props.savedObjects} /> ); } @@ -118,7 +120,8 @@ export class App extends Component { overlays={this.props.overlays} notifications={this.props.notifications} inspector={this.props.inspector} - SavedObjectFinder={this.props.SavedObjectFinder} + uiSettings={this.props.uiSettings} + savedObjects={this.props.savedObjects} /> ); } @@ -131,7 +134,8 @@ export class App extends Component { overlays={this.props.overlays} notifications={this.props.notifications} inspector={this.props.inspector} - SavedObjectFinder={this.props.SavedObjectFinder} + uiSettings={this.props.uiSettings} + savedObjects={this.props.savedObjects} /> ); } diff --git a/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/app/dashboard_container_example.tsx b/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/app/dashboard_container_example.tsx index 5cfaa1c22f4e5..d8a569d367bcc 100644 --- a/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/app/dashboard_container_example.tsx +++ b/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/app/dashboard_container_example.tsx @@ -43,8 +43,9 @@ interface Props { getAllEmbeddableFactories: GetEmbeddableFactories; overlays: CoreStart['overlays']; notifications: CoreStart['notifications']; + uiSettings: CoreStart['uiSettings']; + savedObjects: CoreStart['savedObjects']; inspector: InspectorStartContract; - SavedObjectFinder: React.ComponentType; } interface State { @@ -114,7 +115,8 @@ export class DashboardContainerExample extends React.Component { overlays={this.props.overlays} notifications={this.props.notifications} inspector={this.props.inspector} - SavedObjectFinder={this.props.SavedObjectFinder} + uiSettings={this.props.uiSettings} + savedObjects={this.props.savedObjects} /> )} diff --git a/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/app/hello_world_container_example.tsx b/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/app/hello_world_container_example.tsx index efd700552ec32..45b36d3a27718 100644 --- a/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/app/hello_world_container_example.tsx +++ b/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/app/hello_world_container_example.tsx @@ -41,7 +41,8 @@ interface Props { overlays: CoreStart['overlays']; notifications: CoreStart['notifications']; inspector: InspectorStartContract; - SavedObjectFinder: React.ComponentType; + uiSettings: CoreStart['uiSettings']; + savedObjects: CoreStart['savedObjects']; } export class HelloWorldContainerExample extends React.Component { @@ -80,7 +81,8 @@ export class HelloWorldContainerExample extends React.Component ); diff --git a/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/app/hello_world_embeddable_example.tsx b/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/app/hello_world_embeddable_example.tsx index 78b122cb1baf5..4f1456f136c0a 100644 --- a/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/app/hello_world_embeddable_example.tsx +++ b/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/app/hello_world_embeddable_example.tsx @@ -35,7 +35,8 @@ interface Props { overlays: CoreStart['overlays']; notifications: CoreStart['notifications']; inspector: InspectorStartContract; - SavedObjectFinder: React.ComponentType; + uiSettings: CoreStart['uiSettings']; + savedObjects: CoreStart['savedObjects']; } export class ContactCardEmbeddableExample extends React.Component { @@ -64,7 +65,8 @@ export class ContactCardEmbeddableExample extends React.Component { overlays={this.props.overlays} notifications={this.props.notifications} inspector={this.props.inspector} - SavedObjectFinder={this.props.SavedObjectFinder} + uiSettings={this.props.uiSettings} + savedObjects={this.props.savedObjects} /> ); diff --git a/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/plugin.tsx b/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/plugin.tsx index 5245935c191ee..8cf74dbdf8a5a 100644 --- a/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/plugin.tsx +++ b/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/plugin.tsx @@ -38,7 +38,6 @@ import { ContactCardEmbeddableFactory, } from './embeddable_api'; import { App } from './app'; -import { SavedObjectFinder as SavedObjectFinderNP } from '../../../../../../../src/plugins/kibana_react/public'; import { IEmbeddableStart, IEmbeddableSetup, @@ -96,14 +95,6 @@ export class EmbeddableExplorerPublicPlugin contactCardEmbeddableFactory ); - const SavedObjectFinder = (props: any) => ( - - ); - plugins.__LEGACY.onRenderComplete(() => { const root = document.getElementById(REACT_ROOT_ID); ReactDOM.render( @@ -115,7 +106,8 @@ export class EmbeddableExplorerPublicPlugin overlays={core.overlays} inspector={plugins.inspector} I18nContext={core.i18n.Context} - SavedObjectFinder={SavedObjectFinder} + uiSettings={core.uiSettings} + savedObjects={core.savedObjects} />, root ); diff --git a/x-pack/legacy/plugins/canvas/public/components/embeddable_flyout/flyout.tsx b/x-pack/legacy/plugins/canvas/public/components/embeddable_flyout/flyout.tsx index d09ef53f65fbb..786403f2748fa 100644 --- a/x-pack/legacy/plugins/canvas/public/components/embeddable_flyout/flyout.tsx +++ b/x-pack/legacy/plugins/canvas/public/components/embeddable_flyout/flyout.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { EuiFlyout, EuiFlyoutHeader, EuiFlyoutBody, EuiTitle } from '@elastic/eui'; import { - SavedObjectFinder, + SavedObjectFinderUi, SavedObjectMetaData, } from '../../../../../../../src/plugins/kibana_react/public/saved_objects'; // eslint-disable-line import { start } from '../../../../../../../src/legacy/core_plugins/embeddable_api/public/np_ready/public/legacy'; @@ -64,7 +64,7 @@ export class AddEmbeddableFlyout extends React.Component { - { diff --git a/x-pack/legacy/plugins/ml/public/application/jobs/new_job/pages/index_or_search/page.tsx b/x-pack/legacy/plugins/ml/public/application/jobs/new_job/pages/index_or_search/page.tsx index 22904b5efdfc2..cb311f04dd1d7 100644 --- a/x-pack/legacy/plugins/ml/public/application/jobs/new_job/pages/index_or_search/page.tsx +++ b/x-pack/legacy/plugins/ml/public/application/jobs/new_job/pages/index_or_search/page.tsx @@ -16,7 +16,7 @@ import { import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { npStart } from 'ui/new_platform'; -import { SavedObjectFinder } from '../../../../../../../../../../src/plugins/kibana_react/public'; +import { SavedObjectFinderUi } from '../../../../../../../../../../src/plugins/kibana_react/public'; export interface PageProps { nextStepPath: string; @@ -47,7 +47,7 @@ export const Page: FC = ({ nextStepPath }) => { - = ({ onSearchSelected }) - Date: Thu, 5 Dec 2019 14:33:00 +0100 Subject: [PATCH 3/8] fix unit test --- .../discover/components/top_nav/open_search_panel.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/legacy/core_plugins/kibana/public/discover/components/top_nav/open_search_panel.test.js b/src/legacy/core_plugins/kibana/public/discover/components/top_nav/open_search_panel.test.js index ea5c0ef39604d..0c82aeea95294 100644 --- a/src/legacy/core_plugins/kibana/public/discover/components/top_nav/open_search_panel.test.js +++ b/src/legacy/core_plugins/kibana/public/discover/components/top_nav/open_search_panel.test.js @@ -23,7 +23,7 @@ import { shallow } from 'enzyme'; jest.mock('../../kibana_services', () => { return { getServices: () => ({ - SavedObjectFinder: jest.fn() + core: { uiSettings: {}, savedObjects: {} }, }), }; }); From 944780853a8a318297c599f2fb7025d33eb0adfa Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Thu, 5 Dec 2019 16:39:50 +0100 Subject: [PATCH 4/8] fix typings --- .../embeddable/public/lib/panel/embeddable_panel.test.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/embeddable/public/lib/panel/embeddable_panel.test.tsx b/src/plugins/embeddable/public/lib/panel/embeddable_panel.test.tsx index f25b0a4f8643f..1073dcc04d211 100644 --- a/src/plugins/embeddable/public/lib/panel/embeddable_panel.test.tsx +++ b/src/plugins/embeddable/public/lib/panel/embeddable_panel.test.tsx @@ -201,8 +201,9 @@ const renderInEditModeAndOpenContextMenu = async ( getEmbeddableFactory={(() => undefined) as any} notifications={{} as any} overlays={{} as any} + uiSettings={{} as any} + savedObjects={{} as any} inspector={inspector} - SavedObjectFinder={() => null} /> ); From 751a1856b5717a4a277e70cc8154fe56a27417b8 Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Fri, 6 Dec 2019 10:17:38 +0100 Subject: [PATCH 5/8] update snapshot --- .../top_nav/__snapshots__/open_search_panel.test.js.snap | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/legacy/core_plugins/kibana/public/discover/components/top_nav/__snapshots__/open_search_panel.test.js.snap b/src/legacy/core_plugins/kibana/public/discover/components/top_nav/__snapshots__/open_search_panel.test.js.snap index cc53e4bdcdcf9..2878b11040cf3 100644 --- a/src/legacy/core_plugins/kibana/public/discover/components/top_nav/__snapshots__/open_search_panel.test.js.snap +++ b/src/legacy/core_plugins/kibana/public/discover/components/top_nav/__snapshots__/open_search_panel.test.js.snap @@ -26,7 +26,7 @@ exports[`render 1`] = ` - From db4ae45d0ff70aece34cf8ea916fa06d972d18d4 Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Mon, 9 Dec 2019 14:05:46 +0100 Subject: [PATCH 6/8] revert embeddable changes and create stateful wrapper on the boundaries --- .../dashboard/dashboard_app_controller.tsx | 11 ++++- .../actions/expand_panel_action.test.tsx | 3 +- .../actions/open_replace_panel_flyout.tsx | 16 +++++-- .../actions/replace_panel_action.test.tsx | 48 ++++++++++++++++--- .../public/actions/replace_panel_action.tsx | 4 ++ .../public/actions/replace_panel_flyout.tsx | 11 ++--- .../embeddable/dashboard_container.test.tsx | 3 +- .../public/embeddable/dashboard_container.tsx | 3 +- .../embeddable/grid/dashboard_grid.test.tsx | 3 +- .../public/embeddable/grid/dashboard_grid.tsx | 3 +- .../viewport/dashboard_viewport.test.tsx | 3 +- .../public/plugin.tsx | 20 ++++++-- .../public/tests/dashboard_container.test.tsx | 6 +-- .../embeddable_child_panel.test.tsx | 6 +-- .../lib/containers/embeddable_child_panel.tsx | 6 +-- .../lib/panel/embeddable_panel.test.tsx | 18 +++---- .../public/lib/panel/embeddable_panel.tsx | 6 +-- .../add_panel/add_panel_action.test.tsx | 6 +-- .../add_panel/add_panel_action.ts | 8 ++-- .../add_panel/add_panel_flyout.test.tsx | 6 +-- .../add_panel/add_panel_flyout.tsx | 11 ++--- .../add_panel/open_add_panel_flyout.tsx | 11 ++--- .../embeddables/hello_world_container.tsx | 6 +-- .../hello_world_container_component.tsx | 6 +-- .../public/tests/apply_filter_action.test.ts | 6 +-- .../embeddable/public/tests/container.test.ts | 24 ++++------ .../tests/customize_panel_modal.test.tsx | 3 +- .../public/tests/explicit_input.test.ts | 6 +-- .../public/np_ready/public/app/app.tsx | 12 ++--- .../app/dashboard_container_example.tsx | 6 +-- .../app/hello_world_container_example.tsx | 9 ++-- .../app/hello_world_embeddable_example.tsx | 6 +-- .../public/np_ready/public/plugin.tsx | 14 +++++- .../renderers/embeddable.tsx | 14 +++++- .../components/embeddables/embedded_map.tsx | 11 ++++- 35 files changed, 183 insertions(+), 152 deletions(-) diff --git a/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app_controller.tsx b/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app_controller.tsx index 1670154351419..a46364abf5c59 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app_controller.tsx +++ b/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app_controller.tsx @@ -70,6 +70,10 @@ import { DashboardAppScope } from './dashboard_app'; import { VISUALIZE_EMBEDDABLE_TYPE } from '../visualize/embeddable'; import { convertSavedDashboardPanelToPanelState } from './lib/embeddable_saved_object_converters'; import { RenderDeps } from './application'; +import { + SavedObjectFinderProps, + SavedObjectFinderUi, +} from '../../../../../plugins/kibana_react/public'; export interface DashboardAppControllerDependencies extends RenderDeps { $scope: DashboardAppScope; @@ -717,14 +721,17 @@ export class DashboardAppController { }; navActions[TopNavIds.ADD] = () => { if (dashboardContainer && !isErrorEmbeddable(dashboardContainer)) { + const SavedObjectFinder = (props: SavedObjectFinderProps) => ( + + ); + openAddPanelFlyout({ embeddable: dashboardContainer, getAllFactories: embeddables.getEmbeddableFactories, getFactory: embeddables.getEmbeddableFactory, notifications, overlays, - uiSettings, - savedObjects, + SavedObjectFinder, }); } }; diff --git a/src/plugins/dashboard_embeddable_container/public/actions/expand_panel_action.test.tsx b/src/plugins/dashboard_embeddable_container/public/actions/expand_panel_action.test.tsx index 69e1eb86b71ec..f8c05170e8f67 100644 --- a/src/plugins/dashboard_embeddable_container/public/actions/expand_panel_action.test.tsx +++ b/src/plugins/dashboard_embeddable_container/public/actions/expand_panel_action.test.tsx @@ -42,6 +42,7 @@ let embeddable: ContactCardEmbeddable; beforeEach(async () => { const options: DashboardOptions = { ExitFullScreenButton: () => null, + SavedObjectFinder: () => null, application: {} as any, embeddable: { getEmbeddableFactory: (id: string) => embeddableFactories.get(id)!, @@ -51,8 +52,6 @@ beforeEach(async () => { overlays: {} as any, savedObjectMetaData: {} as any, uiActions: {} as any, - uiSettings: {} as any, - savedObjects: {} as any, }; const input = getSampleDashboardInput({ panels: { diff --git a/src/plugins/dashboard_embeddable_container/public/actions/open_replace_panel_flyout.tsx b/src/plugins/dashboard_embeddable_container/public/actions/open_replace_panel_flyout.tsx index 1a17962ad4e58..f15d538703e21 100644 --- a/src/plugins/dashboard_embeddable_container/public/actions/open_replace_panel_flyout.tsx +++ b/src/plugins/dashboard_embeddable_container/public/actions/open_replace_panel_flyout.tsx @@ -31,10 +31,19 @@ import { export async function openReplacePanelFlyout(options: { embeddable: IContainer; core: CoreStart; + savedObjectFinder: React.ComponentType; + notifications: CoreStart['notifications']; panelToRemove: IEmbeddable; getEmbeddableFactories: IEmbeddableStart['getEmbeddableFactories']; }) { - const { embeddable, core, panelToRemove, getEmbeddableFactories } = options; + const { + embeddable, + core, + panelToRemove, + savedObjectFinder, + notifications, + getEmbeddableFactories, + } = options; const flyoutSession = core.overlays.openFlyout( toMountPoint( ), diff --git a/src/plugins/dashboard_embeddable_container/public/actions/replace_panel_action.test.tsx b/src/plugins/dashboard_embeddable_container/public/actions/replace_panel_action.test.tsx index 7858d2cd0f2f8..4438a6c997126 100644 --- a/src/plugins/dashboard_embeddable_container/public/actions/replace_panel_action.test.tsx +++ b/src/plugins/dashboard_embeddable_container/public/actions/replace_panel_action.test.tsx @@ -45,14 +45,13 @@ beforeEach(async () => { coreStart = coreMock.createStart(); const options: DashboardOptions = { ExitFullScreenButton: () => null, + SavedObjectFinder: () => null, application: {} as any, embeddable: { getEmbeddableFactory: (id: string) => embeddableFactories.get(id)!, } as any, inspector: {} as any, notifications: {} as any, - uiSettings: coreStart.uiSettings, - savedObjects: coreStart.savedObjects, overlays: coreStart.overlays, savedObjectMetaData: {} as any, uiActions: {} as any, @@ -83,12 +82,26 @@ beforeEach(async () => { }); test('Executes the replace panel action', async () => { - const action = new ReplacePanelAction(coreStart, getEmbeddableFactories); + let SavedObjectFinder: any; + let notifications: any; + const action = new ReplacePanelAction( + coreStart, + SavedObjectFinder, + notifications, + getEmbeddableFactories + ); action.execute({ embeddable }); }); test('Is not compatible when embeddable is not in a dashboard container', async () => { - const action = new ReplacePanelAction(coreStart, getEmbeddableFactories); + let SavedObjectFinder: any; + let notifications: any; + const action = new ReplacePanelAction( + coreStart, + SavedObjectFinder, + notifications, + getEmbeddableFactories + ); expect( await action.isCompatible({ embeddable: new ContactCardEmbeddable( @@ -100,7 +113,14 @@ test('Is not compatible when embeddable is not in a dashboard container', async }); test('Execute throws an error when called with an embeddable not in a parent', async () => { - const action = new ReplacePanelAction(coreStart, getEmbeddableFactories); + let SavedObjectFinder: any; + let notifications: any; + const action = new ReplacePanelAction( + coreStart, + SavedObjectFinder, + notifications, + getEmbeddableFactories + ); async function check() { await action.execute({ embeddable: container }); } @@ -108,11 +128,25 @@ test('Execute throws an error when called with an embeddable not in a parent', a }); test('Returns title', async () => { - const action = new ReplacePanelAction(coreStart, getEmbeddableFactories); + let SavedObjectFinder: any; + let notifications: any; + const action = new ReplacePanelAction( + coreStart, + SavedObjectFinder, + notifications, + getEmbeddableFactories + ); expect(action.getDisplayName({ embeddable })).toBeDefined(); }); test('Returns an icon', async () => { - const action = new ReplacePanelAction(coreStart, getEmbeddableFactories); + let SavedObjectFinder: any; + let notifications: any; + const action = new ReplacePanelAction( + coreStart, + SavedObjectFinder, + notifications, + getEmbeddableFactories + ); expect(action.getIconType({ embeddable })).toBeDefined(); }); diff --git a/src/plugins/dashboard_embeddable_container/public/actions/replace_panel_action.tsx b/src/plugins/dashboard_embeddable_container/public/actions/replace_panel_action.tsx index f06e578b8a10f..78ce6bdc4c58f 100644 --- a/src/plugins/dashboard_embeddable_container/public/actions/replace_panel_action.tsx +++ b/src/plugins/dashboard_embeddable_container/public/actions/replace_panel_action.tsx @@ -41,6 +41,8 @@ export class ReplacePanelAction implements IAction { constructor( private core: CoreStart, + private savedobjectfinder: React.ComponentType, + private notifications: CoreStart['notifications'], private getEmbeddableFactories: IEmbeddableStart['getEmbeddableFactories'] ) {} @@ -80,6 +82,8 @@ export class ReplacePanelAction implements IAction { openReplacePanelFlyout({ embeddable: dash, core: this.core, + savedObjectFinder: this.savedobjectfinder, + notifications: this.notifications, panelToRemove: view, getEmbeddableFactories: this.getEmbeddableFactories, }); diff --git a/src/plugins/dashboard_embeddable_container/public/actions/replace_panel_flyout.tsx b/src/plugins/dashboard_embeddable_container/public/actions/replace_panel_flyout.tsx index 885d0bfaec254..36313353e3c33 100644 --- a/src/plugins/dashboard_embeddable_container/public/actions/replace_panel_flyout.tsx +++ b/src/plugins/dashboard_embeddable_container/public/actions/replace_panel_flyout.tsx @@ -22,16 +22,14 @@ import React from 'react'; import { EuiFlyout, EuiFlyoutBody, EuiFlyoutHeader, EuiTitle } from '@elastic/eui'; import { GetEmbeddableFactories } from 'src/plugins/embeddable/public'; import { DashboardPanelState } from '../embeddable'; -import { CoreStart, NotificationsStart, Toast } from '../../../../core/public'; +import { NotificationsStart, Toast } from '../../../../core/public'; import { IContainer, IEmbeddable, EmbeddableInput, EmbeddableOutput } from '../embeddable_plugin'; -import { SavedObjectFinderUi } from '../../../kibana_react/public'; interface Props { container: IContainer; + savedObjectsFinder: React.ComponentType; onClose: () => void; notifications: NotificationsStart; - uiSettings: CoreStart['uiSettings']; - savedObjects: CoreStart['savedObjects']; panelToRemove: IEmbeddable; getEmbeddableFactories: GetEmbeddableFactories; } @@ -96,8 +94,9 @@ export class ReplacePanelFlyout extends React.Component { }; public render() { + const SavedObjectFinder = this.props.savedObjectsFinder; const savedObjectsFinder = ( - { .map(({ savedObjectMetaData }) => savedObjectMetaData as any)} showFilter={true} onChoose={this.onReplacePanel} - uiSettings={this.props.uiSettings} - savedObjects={this.props.savedObjects} /> ); diff --git a/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container.test.tsx b/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container.test.tsx index 1dd5c6ab15c7f..770c46c62e42f 100644 --- a/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container.test.tsx +++ b/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container.test.tsx @@ -41,10 +41,9 @@ const options: DashboardContainerOptions = { notifications: {} as any, overlays: {} as any, inspector: {} as any, + SavedObjectFinder: () => null, ExitFullScreenButton: () => null, uiActions: {} as any, - uiSettings: {} as any, - savedObjects: {} as any, }; beforeEach(() => { diff --git a/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container.tsx b/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container.tsx index b9866f3a71733..684aa93779bc1 100644 --- a/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container.tsx +++ b/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container.tsx @@ -77,10 +77,9 @@ export interface DashboardContainerOptions { application: CoreStart['application']; overlays: CoreStart['overlays']; notifications: CoreStart['notifications']; - savedObjects: CoreStart['savedObjects']; - uiSettings: CoreStart['uiSettings']; embeddable: IEmbeddableStart; inspector: InspectorStartContract; + SavedObjectFinder: React.ComponentType; ExitFullScreenButton: React.ComponentType; uiActions: IUiActionsStart; } diff --git a/src/plugins/dashboard_embeddable_container/public/embeddable/grid/dashboard_grid.test.tsx b/src/plugins/dashboard_embeddable_container/public/embeddable/grid/dashboard_grid.test.tsx index e8114ca729408..c1a3d88979f49 100644 --- a/src/plugins/dashboard_embeddable_container/public/embeddable/grid/dashboard_grid.test.tsx +++ b/src/plugins/dashboard_embeddable_container/public/embeddable/grid/dashboard_grid.test.tsx @@ -68,12 +68,11 @@ function prepare(props?: Partial) { inspector: { isAvailable: jest.fn(), } as any, + SavedObjectFinder: () => null, ExitFullScreenButton: () => null, uiActions: { getTriggerCompatibleActions: (() => []) as any, } as any, - uiSettings: {} as any, - savedObjects: {} as any, }; dashboardContainer = new DashboardContainer(initialInput, options); const defaultTestProps: DashboardGridProps = { diff --git a/src/plugins/dashboard_embeddable_container/public/embeddable/grid/dashboard_grid.tsx b/src/plugins/dashboard_embeddable_container/public/embeddable/grid/dashboard_grid.tsx index 6a8ee13e2a971..40db43427339d 100644 --- a/src/plugins/dashboard_embeddable_container/public/embeddable/grid/dashboard_grid.tsx +++ b/src/plugins/dashboard_embeddable_container/public/embeddable/grid/dashboard_grid.tsx @@ -276,8 +276,7 @@ class DashboardGridUi extends React.Component { overlays={this.props.kibana.services.overlays} notifications={this.props.kibana.services.notifications} inspector={this.props.kibana.services.inspector} - uiSettings={this.props.kibana.services.uiSettings} - savedObjects={this.props.kibana.services.savedObjects} + SavedObjectFinder={this.props.kibana.services.SavedObjectFinder} /> ); diff --git a/src/plugins/dashboard_embeddable_container/public/embeddable/viewport/dashboard_viewport.test.tsx b/src/plugins/dashboard_embeddable_container/public/embeddable/viewport/dashboard_viewport.test.tsx index efb6d95683cbe..a2f7b8dc28fb0 100644 --- a/src/plugins/dashboard_embeddable_container/public/embeddable/viewport/dashboard_viewport.test.tsx +++ b/src/plugins/dashboard_embeddable_container/public/embeddable/viewport/dashboard_viewport.test.tsx @@ -59,8 +59,7 @@ function getProps( inspector: { isAvailable: jest.fn(), } as any, - uiSettings: {} as any, - savedObjects: {} as any, + SavedObjectFinder: () => null, ExitFullScreenButton, uiActions: { getTriggerCompatibleActions: (() => []) as any, diff --git a/src/plugins/dashboard_embeddable_container/public/plugin.tsx b/src/plugins/dashboard_embeddable_container/public/plugin.tsx index 9753e7fcae5a5..d18fbba239ec0 100644 --- a/src/plugins/dashboard_embeddable_container/public/plugin.tsx +++ b/src/plugins/dashboard_embeddable_container/public/plugin.tsx @@ -27,6 +27,8 @@ import { ExpandPanelAction, ReplacePanelAction } from '.'; import { DashboardContainerFactory } from './embeddable/dashboard_container_factory'; import { Start as InspectorStartContract } from '../../../plugins/inspector/public'; import { + SavedObjectFinderUi, + SavedObjectFinderProps, ExitFullScreenButton as ExitFullScreenButtonUi, ExitFullScreenButtonProps, } from '../../../plugins/kibana_react/public'; @@ -56,9 +58,20 @@ export class DashboardEmbeddableContainerPublicPlugin } public start(core: CoreStart, plugins: StartDependencies): Start { - const { application, notifications, overlays, uiSettings, savedObjects } = core; + const { application, notifications, overlays } = core; const { embeddable, inspector, uiActions } = plugins; + const SavedObjectFinder: React.FC> = props => ( + + ); + const useHideChrome = () => { React.useEffect(() => { core.chrome.setIsVisible(false); @@ -73,6 +86,8 @@ export class DashboardEmbeddableContainerPublicPlugin const changeViewAction = new ReplacePanelAction( core, + SavedObjectFinder, + notifications, plugins.embeddable.getEmbeddableFactories ); uiActions.registerAction(changeViewAction); @@ -84,10 +99,9 @@ export class DashboardEmbeddableContainerPublicPlugin overlays, embeddable, inspector, + SavedObjectFinder, ExitFullScreenButton, uiActions, - uiSettings, - savedObjects, }); embeddable.registerEmbeddableFactory(factory.type, factory); diff --git a/src/plugins/dashboard_embeddable_container/public/tests/dashboard_container.test.tsx b/src/plugins/dashboard_embeddable_container/public/tests/dashboard_container.test.tsx index fd2b294663642..6a3b69af60d6b 100644 --- a/src/plugins/dashboard_embeddable_container/public/tests/dashboard_container.test.tsx +++ b/src/plugins/dashboard_embeddable_container/public/tests/dashboard_container.test.tsx @@ -64,8 +64,7 @@ test('DashboardContainer in edit mode shows edit mode actions', async () => { notifications: {} as any, overlays: {} as any, inspector: {} as any, - uiSettings: {} as any, - savedObjects: {} as any, + SavedObjectFinder: () => null, ExitFullScreenButton: () => null, uiActions: {} as any, }; @@ -90,8 +89,7 @@ test('DashboardContainer in edit mode shows edit mode actions', async () => { notifications={{} as any} overlays={{} as any} inspector={inspector} - uiSettings={{} as any} - savedObjects={{} as any} + SavedObjectFinder={() => null} /> diff --git a/src/plugins/embeddable/public/lib/containers/embeddable_child_panel.test.tsx b/src/plugins/embeddable/public/lib/containers/embeddable_child_panel.test.tsx index c5eb7f17e9ccb..3c9e6e31220b2 100644 --- a/src/plugins/embeddable/public/lib/containers/embeddable_child_panel.test.tsx +++ b/src/plugins/embeddable/public/lib/containers/embeddable_child_panel.test.tsx @@ -68,9 +68,8 @@ test('EmbeddableChildPanel renders an embeddable when it is done loading', async getEmbeddableFactory={(() => undefined) as any} notifications={{} as any} overlays={{} as any} - uiSettings={{} as any} - savedObjects={{} as any} inspector={inspector} + SavedObjectFinder={() => null} /> ); @@ -107,9 +106,8 @@ test(`EmbeddableChildPanel renders an error message if the factory doesn't exist getEmbeddableFactory={(() => undefined) as any} notifications={{} as any} overlays={{} as any} - uiSettings={{} as any} - savedObjects={{} as any} inspector={inspector} + SavedObjectFinder={() => null} /> ); diff --git a/src/plugins/embeddable/public/lib/containers/embeddable_child_panel.tsx b/src/plugins/embeddable/public/lib/containers/embeddable_child_panel.tsx index 2432b97ddd749..d3f9b07be4754 100644 --- a/src/plugins/embeddable/public/lib/containers/embeddable_child_panel.tsx +++ b/src/plugins/embeddable/public/lib/containers/embeddable_child_panel.tsx @@ -40,9 +40,8 @@ export interface EmbeddableChildPanelProps { getAllEmbeddableFactories: GetEmbeddableFactories; overlays: CoreStart['overlays']; notifications: CoreStart['notifications']; - uiSettings: CoreStart['uiSettings']; - savedObjects: CoreStart['savedObjects']; inspector: InspectorStartContract; + SavedObjectFinder: React.ComponentType; } interface State { @@ -103,9 +102,8 @@ export class EmbeddableChildPanel extends React.Component )} diff --git a/src/plugins/embeddable/public/lib/panel/embeddable_panel.test.tsx b/src/plugins/embeddable/public/lib/panel/embeddable_panel.test.tsx index 1073dcc04d211..196d6f934134b 100644 --- a/src/plugins/embeddable/public/lib/panel/embeddable_panel.test.tsx +++ b/src/plugins/embeddable/public/lib/panel/embeddable_panel.test.tsx @@ -162,9 +162,8 @@ test('HelloWorldContainer in view mode hides edit mode actions', async () => { getEmbeddableFactory={(() => undefined) as any} notifications={{} as any} overlays={{} as any} - uiSettings={{} as any} - savedObjects={{} as any} inspector={inspector} + SavedObjectFinder={() => null} /> ); @@ -201,9 +200,8 @@ const renderInEditModeAndOpenContextMenu = async ( getEmbeddableFactory={(() => undefined) as any} notifications={{} as any} overlays={{} as any} - uiSettings={{} as any} - savedObjects={{} as any} inspector={inspector} + SavedObjectFinder={() => null} /> ); @@ -301,8 +299,7 @@ test('HelloWorldContainer in edit mode shows edit mode actions', async () => { notifications={{} as any} overlays={{} as any} inspector={inspector} - uiSettings={{} as any} - savedObjects={{} as any} + SavedObjectFinder={() => null} /> ); @@ -364,8 +361,7 @@ test('Updates when hidePanelTitles is toggled', async () => { notifications={{} as any} overlays={{} as any} inspector={inspector} - uiSettings={{} as any} - savedObjects={{} as any} + SavedObjectFinder={() => null} /> ); @@ -417,8 +413,7 @@ test('Check when hide header option is false', async () => { notifications={{} as any} overlays={{} as any} inspector={inspector} - uiSettings={{} as any} - savedObjects={{} as any} + SavedObjectFinder={() => null} hideHeader={false} /> @@ -455,8 +450,7 @@ test('Check when hide header option is true', async () => { notifications={{} as any} overlays={{} as any} inspector={inspector} - uiSettings={{} as any} - savedObjects={{} as any} + SavedObjectFinder={() => null} hideHeader={true} /> diff --git a/src/plugins/embeddable/public/lib/panel/embeddable_panel.tsx b/src/plugins/embeddable/public/lib/panel/embeddable_panel.tsx index afd22b5769da9..234d8508bb97a 100644 --- a/src/plugins/embeddable/public/lib/panel/embeddable_panel.tsx +++ b/src/plugins/embeddable/public/lib/panel/embeddable_panel.tsx @@ -48,9 +48,8 @@ interface Props { getAllEmbeddableFactories: GetEmbeddableFactories; overlays: CoreStart['overlays']; notifications: CoreStart['notifications']; - uiSettings: CoreStart['uiSettings']; - savedObjects: CoreStart['savedObjects']; inspector: InspectorStartContract; + SavedObjectFinder: React.ComponentType; hideHeader?: boolean; } @@ -243,8 +242,7 @@ export class EmbeddablePanel extends React.Component { this.props.getAllEmbeddableFactories, this.props.overlays, this.props.notifications, - this.props.uiSettings, - this.props.savedObjects + this.props.SavedObjectFinder ), new InspectPanelAction(this.props.inspector), new RemovePanelAction(), diff --git a/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_action.test.tsx b/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_action.test.tsx index b0c9e16cc4dce..47113ffc59561 100644 --- a/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_action.test.tsx +++ b/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_action.test.tsx @@ -48,8 +48,7 @@ beforeEach(async () => { () => [] as any, start.overlays, start.notifications, - start.uiSettings, - start.savedObjects + () => null ); const derivedFilter: esFilters.Filter = { @@ -84,8 +83,7 @@ test('Is not compatible when container is in view mode', async () => { () => [] as any, start.overlays, start.notifications, - start.uiSettings, - start.savedObjects + () => null ); container.updateInput({ viewMode: ViewMode.VIEW }); expect(await addPanelAction.isCompatible({ embeddable: container })).toBe(false); diff --git a/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_action.ts b/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_action.ts index e4a1929ad815b..9ecc4686c21b6 100644 --- a/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_action.ts +++ b/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_action.ts @@ -18,7 +18,7 @@ */ import { i18n } from '@kbn/i18n'; import { IAction } from 'src/plugins/ui_actions/public'; -import { CoreStart, NotificationsStart, OverlayStart } from 'src/core/public'; +import { NotificationsStart, OverlayStart } from 'src/core/public'; import { ViewMode, GetEmbeddableFactory, GetEmbeddableFactories } from '../../../../types'; import { openAddPanelFlyout } from './open_add_panel_flyout'; import { IContainer } from '../../../../containers'; @@ -38,8 +38,7 @@ export class AddPanelAction implements IAction { private readonly getAllFactories: GetEmbeddableFactories, private readonly overlays: OverlayStart, private readonly notifications: NotificationsStart, - private readonly uiSettings: CoreStart['uiSettings'], - private readonly savedObjects: CoreStart['savedObjects'] + private readonly SavedObjectFinder: React.ComponentType ) {} public getDisplayName() { @@ -67,8 +66,7 @@ export class AddPanelAction implements IAction { getAllFactories: this.getAllFactories, overlays: this.overlays, notifications: this.notifications, - savedObjects: this.savedObjects, - uiSettings: this.uiSettings, + SavedObjectFinder: this.SavedObjectFinder, }); } } diff --git a/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_flyout.test.tsx b/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_flyout.test.tsx index c69c25837f80e..fd8f286a9d8f6 100644 --- a/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_flyout.test.tsx +++ b/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_flyout.test.tsx @@ -63,8 +63,7 @@ test('createNewEmbeddable() add embeddable to container', async () => { getFactory={getEmbeddableFactory} getAllFactories={() => new Set([contactCardEmbeddableFactory]).values()} notifications={core.notifications} - uiSettings={core.uiSettings} - savedObjects={core.savedObjects} + SavedObjectFinder={() => null} /> ) as ReactWrapper; @@ -109,8 +108,7 @@ test('selecting embeddable in "Create new ..." list calls createNewEmbeddable()' getFactory={getEmbeddableFactory} getAllFactories={() => new Set([contactCardEmbeddableFactory]).values()} notifications={core.notifications} - uiSettings={core.uiSettings} - savedObjects={core.savedObjects} + SavedObjectFinder={() => null} /> ) as ReactWrapper; diff --git a/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_flyout.tsx b/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_flyout.tsx index cc49e0d8777ab..4f2ae7ab19bcb 100644 --- a/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_flyout.tsx +++ b/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_flyout.tsx @@ -19,7 +19,7 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import React from 'react'; -import { CoreSetup, CoreStart } from 'src/core/public'; +import { CoreSetup } from 'src/core/public'; import { EuiButton, @@ -36,7 +36,6 @@ import { import { IContainer } from '../../../../containers'; import { EmbeddableFactoryNotFoundError } from '../../../../errors'; import { GetEmbeddableFactories, GetEmbeddableFactory } from '../../../../types'; -import { SavedObjectFinderUi } from '../../../../../../../kibana_react/public'; interface Props { onClose: () => void; @@ -44,8 +43,7 @@ interface Props { getFactory: GetEmbeddableFactory; getAllFactories: GetEmbeddableFactories; notifications: CoreSetup['notifications']; - savedObjects: CoreStart['savedObjects']; - uiSettings: CoreSetup['uiSettings']; + SavedObjectFinder: React.ComponentType; } interface State { @@ -133,8 +131,9 @@ export class AddPanelFlyout extends React.Component { } public render() { + const SavedObjectFinder = this.props.SavedObjectFinder; const savedObjectsFinder = ( - { noItemsMessage={i18n.translate('embeddableApi.addPanel.noMatchingObjectsMessage', { defaultMessage: 'No matching objects found.', })} - savedObjects={this.props.savedObjects} - uiSettings={this.props.uiSettings} /> ); diff --git a/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/open_add_panel_flyout.tsx b/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/open_add_panel_flyout.tsx index 1101f71e1d466..481693501066c 100644 --- a/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/open_add_panel_flyout.tsx +++ b/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/open_add_panel_flyout.tsx @@ -17,7 +17,7 @@ * under the License. */ import React from 'react'; -import { CoreSetup, CoreStart, NotificationsStart, OverlayStart } from 'src/core/public'; +import { NotificationsStart, OverlayStart } from 'src/core/public'; import { toMountPoint } from '../../../../../../../kibana_react/public'; import { IContainer } from '../../../../containers'; import { AddPanelFlyout } from './add_panel_flyout'; @@ -29,8 +29,7 @@ export async function openAddPanelFlyout(options: { getAllFactories: GetEmbeddableFactories; overlays: OverlayStart; notifications: NotificationsStart; - savedObjects: CoreStart['savedObjects']; - uiSettings: CoreSetup['uiSettings']; + SavedObjectFinder: React.ComponentType; }) { const { embeddable, @@ -38,8 +37,7 @@ export async function openAddPanelFlyout(options: { getAllFactories, overlays, notifications, - savedObjects, - uiSettings, + SavedObjectFinder, } = options; const flyoutSession = overlays.openFlyout( toMountPoint( @@ -53,8 +51,7 @@ export async function openAddPanelFlyout(options: { getFactory={getFactory} getAllFactories={getAllFactories} notifications={notifications} - savedObjects={savedObjects} - uiSettings={uiSettings} + SavedObjectFinder={SavedObjectFinder} /> ), { diff --git a/src/plugins/embeddable/public/lib/test_samples/embeddables/hello_world_container.tsx b/src/plugins/embeddable/public/lib/test_samples/embeddables/hello_world_container.tsx index 317df193f629c..de486598470d3 100644 --- a/src/plugins/embeddable/public/lib/test_samples/embeddables/hello_world_container.tsx +++ b/src/plugins/embeddable/public/lib/test_samples/embeddables/hello_world_container.tsx @@ -50,9 +50,8 @@ interface HelloWorldContainerOptions { getAllEmbeddableFactories: GetEmbeddableFactories; overlays: CoreStart['overlays']; notifications: CoreStart['notifications']; - uiSettings: CoreStart['uiSettings']; - savedObjects: CoreStart['savedObjects']; inspector: InspectorStartContract; + SavedObjectFinder: React.ComponentType; } export class HelloWorldContainer extends Container { @@ -84,8 +83,7 @@ export class HelloWorldContainer extends Container , node diff --git a/src/plugins/embeddable/public/lib/test_samples/embeddables/hello_world_container_component.tsx b/src/plugins/embeddable/public/lib/test_samples/embeddables/hello_world_container_component.tsx index 8cd30cde42f94..7c0e09eff1d50 100644 --- a/src/plugins/embeddable/public/lib/test_samples/embeddables/hello_world_container_component.tsx +++ b/src/plugins/embeddable/public/lib/test_samples/embeddables/hello_world_container_component.tsx @@ -34,8 +34,7 @@ interface Props { overlays: CoreStart['overlays']; notifications: CoreStart['notifications']; inspector: InspectorStartContract; - uiSettings: CoreStart['uiSettings']; - savedObjects: CoreStart['savedObjects']; + SavedObjectFinder: React.ComponentType; } interface State { @@ -113,9 +112,8 @@ export class HelloWorldContainerComponent extends Component { getAllEmbeddableFactories={this.props.getAllEmbeddableFactories} overlays={this.props.overlays} notifications={this.props.notifications} - uiSettings={this.props.uiSettings} - savedObjects={this.props.savedObjects} inspector={this.props.inspector} + SavedObjectFinder={this.props.SavedObjectFinder} /> ); diff --git a/src/plugins/embeddable/public/tests/apply_filter_action.test.ts b/src/plugins/embeddable/public/tests/apply_filter_action.test.ts index 2c3299f3bc630..0721acb1a1fba 100644 --- a/src/plugins/embeddable/public/tests/apply_filter_action.test.ts +++ b/src/plugins/embeddable/public/tests/apply_filter_action.test.ts @@ -106,9 +106,8 @@ test('ApplyFilterAction is incompatible if the root container does not accept a getAllEmbeddableFactories: api.getEmbeddableFactories, overlays: coreStart.overlays, notifications: coreStart.notifications, - uiSettings: coreStart.uiSettings, - savedObjects: coreStart.savedObjects, inspector, + SavedObjectFinder: () => null, } ); @@ -147,8 +146,7 @@ test('trying to execute on incompatible context throws an error ', async () => { overlays: coreStart.overlays, notifications: coreStart.notifications, inspector, - uiSettings: coreStart.uiSettings, - savedObjects: coreStart.savedObjects, + SavedObjectFinder: () => null, } ); diff --git a/src/plugins/embeddable/public/tests/container.test.ts b/src/plugins/embeddable/public/tests/container.test.ts index 3385bf9354a91..f97c26a41b901 100644 --- a/src/plugins/embeddable/public/tests/container.test.ts +++ b/src/plugins/embeddable/public/tests/container.test.ts @@ -73,8 +73,7 @@ async function creatHelloWorldContainerAndEmbeddable( overlays: coreStart.overlays, notifications: coreStart.notifications, inspector: {} as any, - uiSettings: coreStart.uiSettings, - savedObjects: coreStart.savedObjects, + SavedObjectFinder: () => null, }); const embeddable = await container.addNewEmbeddable< ContactCardEmbeddableInput, @@ -147,8 +146,7 @@ test('Container.removeEmbeddable removes and cleans up', async done => { overlays: coreStart.overlays, notifications: coreStart.notifications, inspector: {} as any, - uiSettings: coreStart.uiSettings, - savedObjects: coreStart.savedObjects, + SavedObjectFinder: () => null, } ); const embeddable = await container.addNewEmbeddable< @@ -328,8 +326,7 @@ test(`Container updates its state when a child's input is updated`, async done = notifications: coreStart.notifications, overlays: coreStart.overlays, inspector: {} as any, - uiSettings: coreStart.uiSettings, - savedObjects: coreStart.savedObjects, + SavedObjectFinder: () => null, }); const cloneSubscription = Rx.merge( containerClone.getOutput$(), @@ -579,8 +576,7 @@ test('Container changes made directly after adding a new embeddable are propagat overlays: coreStart.overlays, notifications: coreStart.notifications, inspector: {} as any, - uiSettings: coreStart.uiSettings, - savedObjects: coreStart.savedObjects, + SavedObjectFinder: () => null, } ); @@ -712,8 +708,7 @@ test('untilEmbeddableLoaded() throws an error if there is no such child panel in overlays: coreStart.overlays, notifications: coreStart.notifications, inspector: {} as any, - uiSettings: coreStart.uiSettings, - savedObjects: coreStart.savedObjects, + SavedObjectFinder: () => null, } ); @@ -747,8 +742,7 @@ test('untilEmbeddableLoaded() resolves if child is loaded in the container', asy overlays: coreStart.overlays, notifications: coreStart.notifications, inspector: {} as any, - uiSettings: coreStart.uiSettings, - savedObjects: coreStart.savedObjects, + SavedObjectFinder: () => null, } ); @@ -786,8 +780,7 @@ test('untilEmbeddableLoaded resolves with undefined if child is subsequently rem overlays: coreStart.overlays, notifications: coreStart.notifications, inspector: {} as any, - uiSettings: coreStart.uiSettings, - savedObjects: coreStart.savedObjects, + SavedObjectFinder: () => null, } ); @@ -827,8 +820,7 @@ test('adding a panel then subsequently removing it before its loaded removes the overlays: coreStart.overlays, notifications: coreStart.notifications, inspector: {} as any, - uiSettings: coreStart.uiSettings, - savedObjects: coreStart.savedObjects, + SavedObjectFinder: () => null, } ); diff --git a/src/plugins/embeddable/public/tests/customize_panel_modal.test.tsx b/src/plugins/embeddable/public/tests/customize_panel_modal.test.tsx index a1b85384d9b6b..70d7c99d3fb9d 100644 --- a/src/plugins/embeddable/public/tests/customize_panel_modal.test.tsx +++ b/src/plugins/embeddable/public/tests/customize_panel_modal.test.tsx @@ -65,8 +65,7 @@ beforeEach(async () => { overlays: coreStart.overlays, notifications: coreStart.notifications, inspector: {} as any, - uiSettings: coreStart.uiSettings, - savedObjects: coreStart.savedObjects, + SavedObjectFinder: () => null, } ); const contactCardEmbeddable = await container.addNewEmbeddable< diff --git a/src/plugins/embeddable/public/tests/explicit_input.test.ts b/src/plugins/embeddable/public/tests/explicit_input.test.ts index a7fbc4c96b69b..47c4b0944cef2 100644 --- a/src/plugins/embeddable/public/tests/explicit_input.test.ts +++ b/src/plugins/embeddable/public/tests/explicit_input.test.ts @@ -86,8 +86,7 @@ test('Explicit embeddable input mapped to undefined with no inherited value will notifications: coreStart.notifications, overlays: coreStart.overlays, inspector: {} as any, - uiSettings: coreStart.uiSettings, - savedObjects: coreStart.savedObjects, + SavedObjectFinder: () => null, } ); @@ -135,8 +134,7 @@ test('Explicit input tests in async situations', (done: () => void) => { notifications: coreStart.notifications, overlays: coreStart.overlays, inspector: {} as any, - uiSettings: coreStart.uiSettings, - savedObjects: coreStart.savedObjects, + SavedObjectFinder: () => null, } ); diff --git a/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/app/app.tsx b/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/app/app.tsx index 1c8cbde566859..c0ed2b027f0e4 100644 --- a/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/app/app.tsx +++ b/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/app/app.tsx @@ -36,8 +36,7 @@ export interface AppProps { overlays: CoreStart['overlays']; notifications: CoreStart['notifications']; inspector: InspectorStartContract; - uiSettings: CoreStart['uiSettings']; - savedObjects: CoreStart['savedObjects']; + SavedObjectFinder: React.ComponentType; I18nContext: CoreStart['i18n']['Context']; } @@ -106,8 +105,7 @@ export class App extends Component { overlays={this.props.overlays} notifications={this.props.notifications} inspector={this.props.inspector} - uiSettings={this.props.uiSettings} - savedObjects={this.props.savedObjects} + SavedObjectFinder={this.props.SavedObjectFinder} /> ); } @@ -120,8 +118,7 @@ export class App extends Component { overlays={this.props.overlays} notifications={this.props.notifications} inspector={this.props.inspector} - uiSettings={this.props.uiSettings} - savedObjects={this.props.savedObjects} + SavedObjectFinder={this.props.SavedObjectFinder} /> ); } @@ -134,8 +131,7 @@ export class App extends Component { overlays={this.props.overlays} notifications={this.props.notifications} inspector={this.props.inspector} - uiSettings={this.props.uiSettings} - savedObjects={this.props.savedObjects} + SavedObjectFinder={this.props.SavedObjectFinder} /> ); } diff --git a/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/app/dashboard_container_example.tsx b/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/app/dashboard_container_example.tsx index d8a569d367bcc..5cfaa1c22f4e5 100644 --- a/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/app/dashboard_container_example.tsx +++ b/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/app/dashboard_container_example.tsx @@ -43,9 +43,8 @@ interface Props { getAllEmbeddableFactories: GetEmbeddableFactories; overlays: CoreStart['overlays']; notifications: CoreStart['notifications']; - uiSettings: CoreStart['uiSettings']; - savedObjects: CoreStart['savedObjects']; inspector: InspectorStartContract; + SavedObjectFinder: React.ComponentType; } interface State { @@ -115,8 +114,7 @@ export class DashboardContainerExample extends React.Component { overlays={this.props.overlays} notifications={this.props.notifications} inspector={this.props.inspector} - uiSettings={this.props.uiSettings} - savedObjects={this.props.savedObjects} + SavedObjectFinder={this.props.SavedObjectFinder} /> )} diff --git a/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/app/hello_world_container_example.tsx b/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/app/hello_world_container_example.tsx index 45b36d3a27718..efd700552ec32 100644 --- a/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/app/hello_world_container_example.tsx +++ b/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/app/hello_world_container_example.tsx @@ -41,8 +41,7 @@ interface Props { overlays: CoreStart['overlays']; notifications: CoreStart['notifications']; inspector: InspectorStartContract; - uiSettings: CoreStart['uiSettings']; - savedObjects: CoreStart['savedObjects']; + SavedObjectFinder: React.ComponentType; } export class HelloWorldContainerExample extends React.Component { @@ -81,8 +80,7 @@ export class HelloWorldContainerExample extends React.Component ); diff --git a/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/app/hello_world_embeddable_example.tsx b/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/app/hello_world_embeddable_example.tsx index 4f1456f136c0a..78b122cb1baf5 100644 --- a/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/app/hello_world_embeddable_example.tsx +++ b/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/app/hello_world_embeddable_example.tsx @@ -35,8 +35,7 @@ interface Props { overlays: CoreStart['overlays']; notifications: CoreStart['notifications']; inspector: InspectorStartContract; - uiSettings: CoreStart['uiSettings']; - savedObjects: CoreStart['savedObjects']; + SavedObjectFinder: React.ComponentType; } export class ContactCardEmbeddableExample extends React.Component { @@ -65,8 +64,7 @@ export class ContactCardEmbeddableExample extends React.Component { overlays={this.props.overlays} notifications={this.props.notifications} inspector={this.props.inspector} - uiSettings={this.props.uiSettings} - savedObjects={this.props.savedObjects} + SavedObjectFinder={this.props.SavedObjectFinder} /> ); diff --git a/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/plugin.tsx b/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/plugin.tsx index 8cf74dbdf8a5a..adf898d9af2c7 100644 --- a/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/plugin.tsx +++ b/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/plugin.tsx @@ -38,6 +38,10 @@ import { ContactCardEmbeddableFactory, } from './embeddable_api'; import { App } from './app'; +import { + SavedObjectFinderProps, + SavedObjectFinderUi, +} from '../../../../../../../src/plugins/kibana_react/public/saved_objects'; import { IEmbeddableStart, IEmbeddableSetup, @@ -97,6 +101,13 @@ export class EmbeddableExplorerPublicPlugin plugins.__LEGACY.onRenderComplete(() => { const root = document.getElementById(REACT_ROOT_ID); + const SavedObjectFinder = (props: SavedObjectFinderProps) => ( + + ); ReactDOM.render( , root ); diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/embeddable.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/embeddable.tsx index e24b438bb9d4d..5c7ef1a8c1799 100644 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/embeddable.tsx +++ b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/embeddable.tsx @@ -17,6 +17,10 @@ import { import { start } from '../../../../../../src/legacy/core_plugins/embeddable_api/public/np_ready/public/legacy'; import { EmbeddableExpression } from '../expression_types/embeddable'; import { RendererStrings } from '../../i18n'; +import { + SavedObjectFinderProps, + SavedObjectFinderUi, +} from '../../../../../../src/plugins/kibana_react/public'; const { embeddable: strings } = RendererStrings; @@ -33,6 +37,13 @@ interface Handlers { } const renderEmbeddable = (embeddableObject: IEmbeddable, domNode: HTMLElement) => { + const SavedObjectFinder = (props: SavedObjectFinderProps) => ( + + ); return (
diff --git a/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.tsx b/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.tsx index 7f0e98caa9847..1658002408fb0 100644 --- a/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.tsx +++ b/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.tsx @@ -28,6 +28,10 @@ import { MapToolTip } from './map_tool_tip/map_tool_tip'; import * as i18n from './translations'; import { MapEmbeddable, SetQuery } from './types'; import { Query, esFilters } from '../../../../../../../src/plugins/data/public'; +import { + SavedObjectFinderProps, + SavedObjectFinderUi, +} from '../../../../../../../src/plugins/kibana_react/public'; interface EmbeddableMapProps { maintainRatio?: boolean; @@ -175,6 +179,10 @@ export const EmbeddedMapComponent = ({ } }, [startDate, endDate]); + const SavedObjectFinder = (props: SavedObjectFinderProps) => ( + + ); + return isError ? null : ( @@ -201,10 +209,9 @@ export const EmbeddedMapComponent = ({ getEmbeddableFactory={start.getEmbeddableFactory} getAllEmbeddableFactories={start.getEmbeddableFactories} notifications={core.notifications} - uiSettings={core.uiSettings} - savedObjects={core.savedObjects} overlays={core.overlays} inspector={plugins.inspector} + SavedObjectFinder={SavedObjectFinder} /> ) : !isLoading && isIndexError ? ( From 146b3ab789bea2d0b5ebb01d4fca8704b91dad14 Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Tue, 10 Dec 2019 16:00:23 +0100 Subject: [PATCH 7/8] fix uninitialized visualization app for wizard --- .../embeddable/visualize_embeddable_factory.tsx | 3 ++- .../public/visualize/listing/visualize_listing.html | 1 + .../public/visualize/listing/visualize_listing.js | 4 +++- .../kibana/public/visualize/wizard/new_vis_modal.tsx | 10 ++++++++-- .../wizard/search_selection/search_selection.tsx | 11 +++++------ .../kibana/public/visualize/wizard/show_new_vis.tsx | 6 ++++-- 6 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.tsx b/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.tsx index 7c9efa280c9f1..a377dafe9e512 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.tsx +++ b/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.tsx @@ -199,7 +199,8 @@ export class VisualizeEmbeddableFactory extends EmbeddableFactory< editorParams: ['addToDashboard'], }, npStart.core.http.basePath.prepend, - npStart.core.uiSettings + npStart.core.uiSettings, + npStart.core.savedObjects ); } return undefined; diff --git a/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing.html b/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing.html index 4511ac61f7396..4ee8809fab228 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing.html +++ b/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing.html @@ -16,6 +16,7 @@ vis-types-registry="listingController.visTypeRegistry" add-base-path="listingController.addBasePath" ui-settings="listingController.uiSettings" + saved-objects="listingController.savedObjects" > diff --git a/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing.js b/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing.js index 9b02be0581b8d..b1ed5ce81d6ee 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing.js +++ b/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing.js @@ -34,6 +34,7 @@ export function initListingDirective(app) { ['onClose', { watchDepth: 'reference' }], ['addBasePath', { watchDepth: 'reference' }], ['uiSettings', { watchDepth: 'reference' }], + ['savedObjects', { watchDepth: 'reference' }], 'isOpen', ]) ); @@ -54,7 +55,7 @@ export function VisualizeListingController($injector, createNewVis) { toastNotifications, uiSettings, visualizations, - core: { docLinks }, + core: { docLinks, savedObjects }, } = getServices(); const kbnUrl = $injector.get('kbnUrl'); @@ -64,6 +65,7 @@ export function VisualizeListingController($injector, createNewVis) { this.showNewVisModal = false; this.addBasePath = addBasePath; this.uiSettings = uiSettings; + this.savedObjects = savedObjects; this.createNewVis = () => { this.showNewVisModal = true; diff --git a/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.tsx b/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.tsx index 0b46b562f2146..0402265610fb1 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.tsx +++ b/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.tsx @@ -22,7 +22,7 @@ import React from 'react'; import { EuiModal, EuiOverlayMask } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { IUiSettingsClient } from 'kibana/public'; +import { IUiSettingsClient, SavedObjectsStart } from 'kibana/public'; import { VisType } from '../legacy_imports'; import { VisualizeConstants } from '../visualize_constants'; import { createUiStatsReporter, METRIC_TYPE } from '../../../../ui_metric/public'; @@ -37,6 +37,7 @@ interface TypeSelectionProps { editorParams?: string[]; addBasePath: (path: string) => string; uiSettings: IUiSettingsClient; + savedObjects: SavedObjectsStart; } interface TypeSelectionState { @@ -81,7 +82,12 @@ class NewVisModal extends React.Component - + ) : ( void; visType: VisType; + uiSettings: IUiSettingsClient; + savedObjects: SavedObjectsStart; } export class SearchSelection extends React.Component { private fixedPageSize: number = 8; public render() { - const { - core: { uiSettings, savedObjects }, - } = getServices(); return ( @@ -88,8 +87,8 @@ export class SearchSelection extends React.Component { }, ]} fixedPageSize={this.fixedPageSize} - uiSettings={uiSettings} - savedObjects={savedObjects} + uiSettings={this.props.uiSettings} + savedObjects={this.props.savedObjects} />
diff --git a/src/legacy/core_plugins/kibana/public/visualize/wizard/show_new_vis.tsx b/src/legacy/core_plugins/kibana/public/visualize/wizard/show_new_vis.tsx index 92320f7bb443a..88838e16c40e2 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/wizard/show_new_vis.tsx +++ b/src/legacy/core_plugins/kibana/public/visualize/wizard/show_new_vis.tsx @@ -21,7 +21,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; import { I18nProvider } from '@kbn/i18n/react'; -import { IUiSettingsClient } from 'kibana/public'; +import { IUiSettingsClient, SavedObjectsStart } from 'kibana/public'; import { NewVisModal } from './new_vis_modal'; import { TypesStart } from '../../../../visualizations/public/np_ready/public/types'; @@ -33,7 +33,8 @@ export function showNewVisModal( visTypeRegistry: TypesStart, { editorParams = [] }: ShowNewVisModalParams = {}, addBasePath: (path: string) => string, - uiSettings: IUiSettingsClient + uiSettings: IUiSettingsClient, + savedObjects: SavedObjectsStart ) { const container = document.createElement('div'); const onClose = () => { @@ -51,6 +52,7 @@ export function showNewVisModal( editorParams={editorParams} addBasePath={addBasePath} uiSettings={uiSettings} + savedObjects={savedObjects} /> ); From 27ce33a6e05e34b1240594238fad20804f338b79 Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Tue, 10 Dec 2019 16:32:00 +0100 Subject: [PATCH 8/8] fix tests --- .../wizard/__snapshots__/new_vis_modal.test.tsx.snap | 2 ++ .../kibana/public/visualize/wizard/new_vis_modal.test.tsx | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/src/legacy/core_plugins/kibana/public/visualize/wizard/__snapshots__/new_vis_modal.test.tsx.snap b/src/legacy/core_plugins/kibana/public/visualize/wizard/__snapshots__/new_vis_modal.test.tsx.snap index 5be5f58994887..04b7cddc75289 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/wizard/__snapshots__/new_vis_modal.test.tsx.snap +++ b/src/legacy/core_plugins/kibana/public/visualize/wizard/__snapshots__/new_vis_modal.test.tsx.snap @@ -108,6 +108,7 @@ exports[`NewVisModal filter for visualization types should render as expected 1` } isOpen={true} onClose={[Function]} + savedObjects={Object {}} uiSettings={ Object { "get": [MockFunction] { @@ -1413,6 +1414,7 @@ exports[`NewVisModal should render as expected 1`] = ` } isOpen={true} onClose={[Function]} + savedObjects={Object {}} uiSettings={ Object { "get": [MockFunction] { diff --git a/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.test.tsx b/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.test.tsx index 0dd2091bbfee0..4eafd06c7bb20 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.test.tsx +++ b/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.test.tsx @@ -29,6 +29,7 @@ jest.mock('../legacy_imports', () => ({ })); import { NewVisModal } from './new_vis_modal'; +import { SavedObjectsStart } from 'kibana/public'; describe('NewVisModal', () => { const defaultVisTypeParams = { @@ -76,6 +77,7 @@ describe('NewVisModal', () => { visTypesRegistry={visTypes} addBasePath={addBasePath} uiSettings={uiSettings} + savedObjects={{} as SavedObjectsStart} /> ); expect(wrapper).toMatchSnapshot(); @@ -89,6 +91,7 @@ describe('NewVisModal', () => { visTypesRegistry={visTypes} addBasePath={addBasePath} uiSettings={uiSettings} + savedObjects={{} as SavedObjectsStart} /> ); expect(wrapper.find('[data-test-subj="visType-vis"]').exists()).toBe(true); @@ -104,6 +107,7 @@ describe('NewVisModal', () => { visTypesRegistry={visTypes} addBasePath={addBasePath} uiSettings={uiSettings} + savedObjects={{} as SavedObjectsStart} /> ); const visButton = wrapper.find('button[data-test-subj="visType-vis"]'); @@ -121,6 +125,7 @@ describe('NewVisModal', () => { editorParams={['foo=true', 'bar=42']} addBasePath={addBasePath} uiSettings={uiSettings} + savedObjects={{} as SavedObjectsStart} /> ); const visButton = wrapper.find('button[data-test-subj="visType-vis"]'); @@ -138,6 +143,7 @@ describe('NewVisModal', () => { visTypesRegistry={visTypes} addBasePath={addBasePath} uiSettings={uiSettings} + savedObjects={{} as SavedObjectsStart} /> ); const searchBox = wrapper.find('input[data-test-subj="filterVisType"]'); @@ -156,6 +162,7 @@ describe('NewVisModal', () => { visTypesRegistry={visTypes} addBasePath={addBasePath} uiSettings={uiSettings} + savedObjects={{} as SavedObjectsStart} /> ); expect(wrapper.find('[data-test-subj="visType-visExp"]').exists()).toBe(false); @@ -170,6 +177,7 @@ describe('NewVisModal', () => { visTypesRegistry={visTypes} addBasePath={addBasePath} uiSettings={uiSettings} + savedObjects={{} as SavedObjectsStart} /> ); expect(wrapper.find('[data-test-subj="visType-visExp"]').exists()).toBe(true);