From daac96cce7a3844e03c93a4e1e0ad01b06ce69f6 Mon Sep 17 00:00:00 2001 From: Liza Katz Date: Mon, 16 Dec 2019 13:56:51 +0000 Subject: [PATCH] Move top nav to NP (#52877) * Move top nav to NP * TopNavMenu karma mock * Fixed lens test mocking Removed old plugin code * readme * Code review fixes * lint * ts --- .i18nrc.json | 18 +++++-- .../kibana/public/dashboard/application.ts | 2 +- .../kibana/public/dashboard/index.ts | 3 +- .../kibana/public/dashboard/plugin.ts | 2 +- .../public/discover/get_inner_angular.ts | 2 +- .../kibana/public/discover/index.ts | 3 +- .../kibana/public/discover/plugin.ts | 2 +- .../kibana/public/visualize/application.ts | 2 +- .../kibana/public/visualize/index.ts | 2 - .../public/visualize/kibana_services.ts | 2 +- .../kibana/public/visualize/plugin.ts | 2 +- .../core_plugins/navigation/public/index.scss | 2 +- .../core_plugins/navigation/public/index.ts | 9 ---- .../ui/public/kbn_top_nav/kbn_top_nav.js | 4 +- .../public/new_platform/__mocks__/helpers.ts | 3 ++ .../new_platform/new_platform.karma_mock.js | 5 ++ .../ui/public/new_platform/new_platform.ts | 6 +++ src/plugins/navigation/README.md | 5 ++ src/plugins/navigation/kibana.json | 7 +++ src/plugins/navigation/public/index.ts | 31 +++++++++++ src/plugins/navigation/public/mocks.ts | 44 +++++++++++++++ .../navigation/public/plugin.ts | 54 +++++++------------ .../public/top_nav_menu/_index.scss | 0 .../top_nav_menu/create_top_nav_menu.tsx | 0 .../navigation/public/top_nav_menu/index.ts | 8 ++- .../public/top_nav_menu/top_nav_menu.test.tsx | 0 .../public/top_nav_menu/top_nav_menu.tsx | 2 +- .../public/top_nav_menu/top_nav_menu_data.tsx | 0 .../top_nav_menu_extensions_registry.ts | 0 .../top_nav_menu/top_nav_menu_item.test.tsx | 0 .../public/top_nav_menu/top_nav_menu_item.tsx | 0 .../navigation/public/types.ts} | 20 ++++--- .../plugins/kbn_tp_top_nav/public/top_nav.tsx | 9 ++-- x-pack/legacy/plugins/graph/public/index.ts | 3 +- x-pack/legacy/plugins/graph/public/plugin.ts | 2 +- .../legacy/plugins/graph/public/render_app.ts | 2 +- .../lens/public/app_plugin/app.test.tsx | 23 ++++---- .../plugins/lens/public/app_plugin/app.tsx | 6 +-- 38 files changed, 183 insertions(+), 102 deletions(-) create mode 100644 src/plugins/navigation/README.md create mode 100644 src/plugins/navigation/kibana.json create mode 100644 src/plugins/navigation/public/index.ts create mode 100644 src/plugins/navigation/public/mocks.ts rename src/{legacy/core_plugins => plugins}/navigation/public/plugin.ts (52%) rename src/{legacy/core_plugins => plugins}/navigation/public/top_nav_menu/_index.scss (100%) rename src/{legacy/core_plugins => plugins}/navigation/public/top_nav_menu/create_top_nav_menu.tsx (100%) rename src/{legacy/core_plugins => plugins}/navigation/public/top_nav_menu/index.ts (78%) rename src/{legacy/core_plugins => plugins}/navigation/public/top_nav_menu/top_nav_menu.test.tsx (100%) rename src/{legacy/core_plugins => plugins}/navigation/public/top_nav_menu/top_nav_menu.tsx (99%) rename src/{legacy/core_plugins => plugins}/navigation/public/top_nav_menu/top_nav_menu_data.tsx (100%) rename src/{legacy/core_plugins => plugins}/navigation/public/top_nav_menu/top_nav_menu_extensions_registry.ts (100%) rename src/{legacy/core_plugins => plugins}/navigation/public/top_nav_menu/top_nav_menu_item.test.tsx (100%) rename src/{legacy/core_plugins => plugins}/navigation/public/top_nav_menu/top_nav_menu_item.tsx (100%) rename src/{legacy/core_plugins/navigation/public/legacy.ts => plugins/navigation/public/types.ts} (63%) diff --git a/.i18nrc.json b/.i18nrc.json index a1c49ae03f359..9a37ce1310a32 100644 --- a/.i18nrc.json +++ b/.i18nrc.json @@ -4,7 +4,10 @@ "console": "src/legacy/core_plugins/console", "core": "src/core", "dashboardEmbeddableContainer": "src/plugins/dashboard_embeddable_container", - "data": ["src/legacy/core_plugins/data", "src/plugins/data"], + "data": [ + "src/legacy/core_plugins/data", + "src/plugins/data" + ], "embeddableApi": "src/plugins/embeddable", "share": "src/plugins/share", "esUi": "src/plugins/es_ui_shared", @@ -21,7 +24,7 @@ "kibana_react": "src/legacy/core_plugins/kibana_react", "kibana-react": "src/plugins/kibana_react", "kibana_utils": "src/plugins/kibana_utils", - "navigation": "src/legacy/core_plugins/navigation", + "navigation": "src/plugins/navigation", "newsfeed": "src/plugins/newsfeed", "regionMap": "src/legacy/core_plugins/region_map", "server": "src/legacy/server", @@ -36,8 +39,13 @@ "visTypeTagCloud": "src/legacy/core_plugins/vis_type_tagcloud", "visTypeTimeseries": "src/legacy/core_plugins/vis_type_timeseries", "visTypeVega": "src/legacy/core_plugins/vis_type_vega", - "visualizations": ["src/plugins/visualizations", "src/legacy/core_plugins/visualizations"] + "visualizations": [ + "src/plugins/visualizations", + "src/legacy/core_plugins/visualizations" + ] }, - "exclude": ["src/legacy/ui/ui_render/ui_render_mixin.js"], + "exclude": [ + "src/legacy/ui/ui_render/ui_render_mixin.js" + ], "translations": [] -} +} \ No newline at end of file diff --git a/src/legacy/core_plugins/kibana/public/dashboard/application.ts b/src/legacy/core_plugins/kibana/public/dashboard/application.ts index ef1bcab589c4a..3482197e381e6 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/application.ts +++ b/src/legacy/core_plugins/kibana/public/dashboard/application.ts @@ -48,7 +48,7 @@ import { // @ts-ignore import { initDashboardApp } from './legacy_app'; import { IEmbeddableStart } from '../../../../../plugins/embeddable/public'; -import { NavigationStart } from '../../../navigation/public'; +import { NavigationPublicPluginStart as NavigationStart } from '../../../../../plugins/navigation/public'; import { DataPublicPluginStart as NpDataStart } from '../../../../../plugins/data/public'; import { SharePluginStart } from '../../../../../plugins/share/public'; diff --git a/src/legacy/core_plugins/kibana/public/dashboard/index.ts b/src/legacy/core_plugins/kibana/public/dashboard/index.ts index d37cf5d7139ec..dccc4c11e334f 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/index.ts +++ b/src/legacy/core_plugins/kibana/public/dashboard/index.ts @@ -27,7 +27,6 @@ import { import { DashboardPlugin, LegacyAngularInjectedDependencies } from './plugin'; import { start as data } from '../../../data/public/legacy'; import { start as embeddables } from '../../../embeddable_api/public/np_ready/public/legacy'; -import { start as navigation } from '../../../navigation/public/legacy'; import './saved_dashboard/saved_dashboards'; import './dashboard_config'; @@ -62,6 +61,6 @@ async function getAngularDependencies(): Promise = () => { @@ -31,7 +30,7 @@ export const plugin: PluginInitializer = () => { export const pluginInstance = plugin({} as PluginInitializerContext); (async () => { pluginInstance.setup(npSetup.core, npSetup.plugins); - pluginInstance.start(npStart.core, { ...npStart.plugins, navigation }); + pluginInstance.start(npStart.core, npStart.plugins); })(); SavedObjectRegistryProvider.register((savedSearches: any) => { diff --git a/src/legacy/core_plugins/kibana/public/discover/plugin.ts b/src/legacy/core_plugins/kibana/public/discover/plugin.ts index cb84463c18438..b5a8e25dc11ea 100644 --- a/src/legacy/core_plugins/kibana/public/discover/plugin.ts +++ b/src/legacy/core_plugins/kibana/public/discover/plugin.ts @@ -25,7 +25,7 @@ import './kibana_services'; import { IEmbeddableStart, IEmbeddableSetup } from '../../../../../plugins/embeddable/public'; import { getInnerAngularModule, getInnerAngularModuleEmbeddable } from './get_inner_angular'; import { setAngularModule, setServices } from './kibana_services'; -import { NavigationStart } from '../../../navigation/public'; +import { NavigationPublicPluginStart as NavigationStart } from '../../../../../plugins/navigation/public'; import { EuiUtilsStart } from '../../../../../plugins/eui_utils/public'; import { buildServices } from './helpers/build_services'; import { SharePluginStart } from '../../../../../plugins/share/public'; diff --git a/src/legacy/core_plugins/kibana/public/visualize/application.ts b/src/legacy/core_plugins/kibana/public/visualize/application.ts index 7684f982de7e0..3161576eacf71 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/application.ts +++ b/src/legacy/core_plugins/kibana/public/visualize/application.ts @@ -39,7 +39,7 @@ import { PromiseServiceCreator, StateManagementConfigProvider, } from './legacy_imports'; -import { NavigationStart } from '../../../navigation/public'; +import { NavigationPublicPluginStart as NavigationStart } from '../../../../../plugins/navigation/public'; // @ts-ignore import { initVisualizeApp } from './legacy_app'; diff --git a/src/legacy/core_plugins/kibana/public/visualize/index.ts b/src/legacy/core_plugins/kibana/public/visualize/index.ts index 5e9f2fdeb8999..7c22bb3d0eaeb 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/index.ts +++ b/src/legacy/core_plugins/kibana/public/visualize/index.ts @@ -30,7 +30,6 @@ import { } from './legacy_imports'; import { VisualizePlugin, LegacyAngularInjectedDependencies } from './plugin'; import { start as embeddables } from '../../../embeddable_api/public/np_ready/public/legacy'; -import { start as navigation } from '../../../navigation/public/legacy'; import { start as visualizations } from '../../../visualizations/public/np_ready/public/legacy'; /** @@ -64,7 +63,6 @@ async function getAngularDependencies(): Promise reactDirective => { ]); }; -module.directive('kbnTopNavHelper', createTopNavHelper(navigation.ui)); +module.directive('kbnTopNavHelper', createTopNavHelper(npStart.plugins.navigation.ui)); diff --git a/src/legacy/ui/public/new_platform/__mocks__/helpers.ts b/src/legacy/ui/public/new_platform/__mocks__/helpers.ts index 006497435aec8..a0a917bc48049 100644 --- a/src/legacy/ui/public/new_platform/__mocks__/helpers.ts +++ b/src/legacy/ui/public/new_platform/__mocks__/helpers.ts @@ -21,6 +21,7 @@ import { coreMock } from '../../../../../core/public/mocks'; import { dataPluginMock } from '../../../../../plugins/data/public/mocks'; import { embeddablePluginMock } from '../../../../../plugins/embeddable/public/mocks'; +import { navigationPluginMock } from '../../../../../plugins/navigation/public/mocks'; import { expressionsPluginMock } from '../../../../../plugins/expressions/public/mocks'; import { inspectorPluginMock } from '../../../../../plugins/inspector/public/mocks'; import { uiActionsPluginMock } from '../../../../../plugins/ui_actions/public/mocks'; @@ -30,6 +31,7 @@ import { usageCollectionPluginMock } from '../../../../../plugins/usage_collecti export const pluginsMock = { createSetup: () => ({ data: dataPluginMock.createSetupContract(), + navigation: navigationPluginMock.createSetupContract(), embeddable: embeddablePluginMock.createSetupContract(), inspector: inspectorPluginMock.createSetupContract(), expressions: expressionsPluginMock.createSetupContract(), @@ -38,6 +40,7 @@ export const pluginsMock = { }), createStart: () => ({ data: dataPluginMock.createStartContract(), + navigation: navigationPluginMock.createStartContract(), embeddable: embeddablePluginMock.createStartContract(), inspector: inspectorPluginMock.createStartContract(), expressions: expressionsPluginMock.createStartContract(), diff --git a/src/legacy/ui/public/new_platform/new_platform.karma_mock.js b/src/legacy/ui/public/new_platform/new_platform.karma_mock.js index eacaac95a9879..20a7e0d5dde8d 100644 --- a/src/legacy/ui/public/new_platform/new_platform.karma_mock.js +++ b/src/legacy/ui/public/new_platform/new_platform.karma_mock.js @@ -244,6 +244,11 @@ export const npStart = { register: sinon.fake(), }, }, + navigation: { + ui: { + TopNavMenu: mockComponent, + }, + }, }, }; diff --git a/src/legacy/ui/public/new_platform/new_platform.ts b/src/legacy/ui/public/new_platform/new_platform.ts index 0a27bffd32b05..138bb4135c507 100644 --- a/src/legacy/ui/public/new_platform/new_platform.ts +++ b/src/legacy/ui/public/new_platform/new_platform.ts @@ -34,6 +34,10 @@ import { HomePublicPluginSetup, HomePublicPluginStart } from '../../../../plugin import { SharePluginSetup, SharePluginStart } from '../../../../plugins/share/public'; import { BfetchPublicSetup, BfetchPublicStart } from '../../../../plugins/bfetch/public'; import { UsageCollectionSetup } from '../../../../plugins/usage_collection/public'; +import { + NavigationPublicPluginSetup, + NavigationPublicPluginStart, +} from '../../../../plugins/navigation/public'; export interface PluginsSetup { bfetch: BfetchPublicSetup; @@ -43,6 +47,7 @@ export interface PluginsSetup { home: HomePublicPluginSetup; inspector: InspectorSetup; uiActions: IUiActionsSetup; + navigation: NavigationPublicPluginSetup; dev_tools: DevToolsSetup; kibana_legacy: KibanaLegacySetup; share: SharePluginSetup; @@ -58,6 +63,7 @@ export interface PluginsStart { home: HomePublicPluginStart; inspector: InspectorStart; uiActions: IUiActionsStart; + navigation: NavigationPublicPluginStart; dev_tools: DevToolsStart; kibana_legacy: KibanaLegacyStart; share: SharePluginStart; diff --git a/src/plugins/navigation/README.md b/src/plugins/navigation/README.md new file mode 100644 index 0000000000000..2b32cb50f0b11 --- /dev/null +++ b/src/plugins/navigation/README.md @@ -0,0 +1,5 @@ +# navigation + +The navigation plugins exports the `TopNavMenu` component. +It also provides a stateful version of it on the `start` contract. + diff --git a/src/plugins/navigation/kibana.json b/src/plugins/navigation/kibana.json new file mode 100644 index 0000000000000..000d5acf2635f --- /dev/null +++ b/src/plugins/navigation/kibana.json @@ -0,0 +1,7 @@ +{ + "id": "navigation", + "version": "kibana", + "server": false, + "ui": true, + "requiredPlugins": ["data"] +} \ No newline at end of file diff --git a/src/plugins/navigation/public/index.ts b/src/plugins/navigation/public/index.ts new file mode 100644 index 0000000000000..1c0a36c597ce7 --- /dev/null +++ b/src/plugins/navigation/public/index.ts @@ -0,0 +1,31 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { PluginInitializerContext } from '../../../core/public'; +export function plugin(initializerContext: PluginInitializerContext) { + return new NavigationPublicPlugin(initializerContext); +} + +export { TopNavMenuData, TopNavMenu } from './top_nav_menu'; + +export { NavigationPublicPluginSetup, NavigationPublicPluginStart } from './types'; + +// Export plugin after all other imports +import { NavigationPublicPlugin } from './plugin'; +export { NavigationPublicPlugin as Plugin }; diff --git a/src/plugins/navigation/public/mocks.ts b/src/plugins/navigation/public/mocks.ts new file mode 100644 index 0000000000000..3e30217f6b6fb --- /dev/null +++ b/src/plugins/navigation/public/mocks.ts @@ -0,0 +1,44 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import { Plugin } from '.'; + +export type Setup = jest.Mocked>; +export type Start = jest.Mocked>; + +const createSetupContract = (): jest.Mocked => { + const setupContract = { + registerMenuItem: jest.fn(), + }; + + return setupContract; +}; + +const createStartContract = (): jest.Mocked => { + const startContract = { + ui: { + TopNavMenu: jest.fn(), + }, + }; + return startContract; +}; + +export const navigationPluginMock = { + createSetupContract, + createStartContract, +}; diff --git a/src/legacy/core_plugins/navigation/public/plugin.ts b/src/plugins/navigation/public/plugin.ts similarity index 52% rename from src/legacy/core_plugins/navigation/public/plugin.ts rename to src/plugins/navigation/public/plugin.ts index 27533e6c8fcf6..e8df5bcd616d9 100644 --- a/src/legacy/core_plugins/navigation/public/plugin.ts +++ b/src/plugins/navigation/public/plugin.ts @@ -17,40 +17,21 @@ * under the License. */ -import { CoreSetup, CoreStart, Plugin } from 'kibana/public'; -import { DataPublicPluginStart } from 'src/plugins/data/public'; -import { TopNavMenuExtensionsRegistry, TopNavMenuExtensionsRegistrySetup } from './top_nav_menu'; -import { createTopNav } from './top_nav_menu/create_top_nav_menu'; -import { TopNavMenuProps } from './top_nav_menu/top_nav_menu'; - -/** - * Interface for this plugin's returned `setup` contract. - * - * @public - */ -export interface NavigationSetup { - registerMenuItem: TopNavMenuExtensionsRegistrySetup['register']; -} - -/** - * Interface for this plugin's returned `start` contract. - * - * @public - */ -export interface NavigationStart { - ui: { - TopNavMenu: React.ComponentType; - }; -} - -export interface NavigationPluginStartDependencies { - data: DataPublicPluginStart; -} - -export class NavigationPlugin implements Plugin { +import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from 'src/core/public'; +import { + NavigationPublicPluginSetup, + NavigationPublicPluginStart, + NavigationPluginStartDependencies, +} from './types'; +import { TopNavMenuExtensionsRegistry, createTopNav } from './top_nav_menu'; + +export class NavigationPublicPlugin + implements Plugin { private readonly topNavMenuExtensionsRegistry: TopNavMenuExtensionsRegistry = new TopNavMenuExtensionsRegistry(); - public setup(core: CoreSetup): NavigationSetup { + constructor(initializerContext: PluginInitializerContext) {} + + public setup(core: CoreSetup): NavigationPublicPluginSetup { return { registerMenuItem: this.topNavMenuExtensionsRegistry.register.bind( this.topNavMenuExtensionsRegistry @@ -58,7 +39,10 @@ export class NavigationPlugin implements Plugin & { appName: string; diff --git a/src/legacy/core_plugins/navigation/public/top_nav_menu/top_nav_menu_data.tsx b/src/plugins/navigation/public/top_nav_menu/top_nav_menu_data.tsx similarity index 100% rename from src/legacy/core_plugins/navigation/public/top_nav_menu/top_nav_menu_data.tsx rename to src/plugins/navigation/public/top_nav_menu/top_nav_menu_data.tsx diff --git a/src/legacy/core_plugins/navigation/public/top_nav_menu/top_nav_menu_extensions_registry.ts b/src/plugins/navigation/public/top_nav_menu/top_nav_menu_extensions_registry.ts similarity index 100% rename from src/legacy/core_plugins/navigation/public/top_nav_menu/top_nav_menu_extensions_registry.ts rename to src/plugins/navigation/public/top_nav_menu/top_nav_menu_extensions_registry.ts diff --git a/src/legacy/core_plugins/navigation/public/top_nav_menu/top_nav_menu_item.test.tsx b/src/plugins/navigation/public/top_nav_menu/top_nav_menu_item.test.tsx similarity index 100% rename from src/legacy/core_plugins/navigation/public/top_nav_menu/top_nav_menu_item.test.tsx rename to src/plugins/navigation/public/top_nav_menu/top_nav_menu_item.test.tsx diff --git a/src/legacy/core_plugins/navigation/public/top_nav_menu/top_nav_menu_item.tsx b/src/plugins/navigation/public/top_nav_menu/top_nav_menu_item.tsx similarity index 100% rename from src/legacy/core_plugins/navigation/public/top_nav_menu/top_nav_menu_item.tsx rename to src/plugins/navigation/public/top_nav_menu/top_nav_menu_item.tsx diff --git a/src/legacy/core_plugins/navigation/public/legacy.ts b/src/plugins/navigation/public/types.ts similarity index 63% rename from src/legacy/core_plugins/navigation/public/legacy.ts rename to src/plugins/navigation/public/types.ts index 8a2fdb5ea4964..d07c636b27428 100644 --- a/src/legacy/core_plugins/navigation/public/legacy.ts +++ b/src/plugins/navigation/public/types.ts @@ -17,13 +17,19 @@ * under the License. */ -import { npSetup, npStart } from 'ui/new_platform'; -import { plugin } from '.'; +import { TopNavMenuProps, TopNavMenuExtensionsRegistrySetup } from './top_nav_menu'; +import { DataPublicPluginStart } from '../../data/public'; -const navPlugin = plugin(); +export interface NavigationPublicPluginSetup { + registerMenuItem: TopNavMenuExtensionsRegistrySetup['register']; +} -export const setup = navPlugin.setup(npSetup.core); +export interface NavigationPublicPluginStart { + ui: { + TopNavMenu: React.ComponentType; + }; +} -export const start = navPlugin.start(npStart.core, { - data: npStart.plugins.data, -}); +export interface NavigationPluginStartDependencies { + data: DataPublicPluginStart; +} diff --git a/test/plugin_functional/plugins/kbn_tp_top_nav/public/top_nav.tsx b/test/plugin_functional/plugins/kbn_tp_top_nav/public/top_nav.tsx index 8678ab705df9c..6a6bf9e82d5c0 100644 --- a/test/plugin_functional/plugins/kbn_tp_top_nav/public/top_nav.tsx +++ b/test/plugin_functional/plugins/kbn_tp_top_nav/public/top_nav.tsx @@ -18,10 +18,7 @@ */ import React from 'react'; -import { - setup as navSetup, - start as navStart, -} from '../../../../../src/legacy/core_plugins/navigation/public/legacy'; +import { npSetup, npStart } from 'ui/new_platform'; const customExtension = { id: 'registered-prop', @@ -31,10 +28,10 @@ const customExtension = { testId: 'demoRegisteredNewButton', }; -navSetup.registerMenuItem(customExtension); +npSetup.plugins.navigation.registerMenuItem(customExtension); export const AppWithTopNav = () => { - const { TopNavMenu } = navStart.ui; + const { TopNavMenu } = npStart.plugins.navigation.ui; const config = [ { id: 'new', diff --git a/x-pack/legacy/plugins/graph/public/index.ts b/x-pack/legacy/plugins/graph/public/index.ts index 600df6d309784..995e261a5c7a7 100644 --- a/x-pack/legacy/plugins/graph/public/index.ts +++ b/x-pack/legacy/plugins/graph/public/index.ts @@ -16,7 +16,6 @@ import { SavedObjectRegistryProvider } from 'ui/saved_objects/saved_object_regis import { npSetup, npStart } from 'ui/new_platform'; import { Storage } from '../../../../../src/plugins/kibana_utils/public'; -import { start as navigation } from '../../../../../src/legacy/core_plugins/navigation/public/legacy'; import { LicensingPluginSetup } from '../../../../plugins/licensing/public'; import { GraphPlugin } from './plugin'; @@ -54,7 +53,7 @@ type XpackNpSetupDeps = typeof npSetup.plugins & { }); instance.start(npStart.core, { npData: npStart.plugins.data, - navigation, + navigation: npStart.plugins.navigation, __LEGACY: { angularDependencies: await getAngularInjectedDependencies(), }, diff --git a/x-pack/legacy/plugins/graph/public/plugin.ts b/x-pack/legacy/plugins/graph/public/plugin.ts index 1646cf200e374..f30742f2c00d2 100644 --- a/x-pack/legacy/plugins/graph/public/plugin.ts +++ b/x-pack/legacy/plugins/graph/public/plugin.ts @@ -8,8 +8,8 @@ import { CoreSetup, CoreStart, Plugin, SavedObjectsClientContract } from 'src/core/public'; import { Plugin as DataPlugin } from 'src/plugins/data/public'; import { LegacyAngularInjectedDependencies } from './render_app'; -import { NavigationStart } from '../../../../../src/legacy/core_plugins/navigation/public'; import { LicensingPluginSetup } from '../../../../plugins/licensing/public'; +import { NavigationPublicPluginStart as NavigationStart } from '../../../../../src/plugins/navigation/public'; export interface GraphPluginStartDependencies { npData: ReturnType; diff --git a/x-pack/legacy/plugins/graph/public/render_app.ts b/x-pack/legacy/plugins/graph/public/render_app.ts index b07a91e6d6328..e892643cf8031 100644 --- a/x-pack/legacy/plugins/graph/public/render_app.ts +++ b/x-pack/legacy/plugins/graph/public/render_app.ts @@ -37,9 +37,9 @@ import { Plugin as DataPlugin, IndexPatternsContract, } from '../../../../../src/plugins/data/public'; -import { NavigationStart } from '../../../../../src/legacy/core_plugins/navigation/public'; import { LicensingPluginSetup } from '../../../../plugins/licensing/public'; import { checkLicense } from '../../../../plugins/graph/common/check_license'; +import { NavigationPublicPluginStart as NavigationStart } from '../../../../../src/plugins/navigation/public'; /** * These are dependencies of the Graph app besides the base dependencies diff --git a/x-pack/legacy/plugins/lens/public/app_plugin/app.test.tsx b/x-pack/legacy/plugins/lens/public/app_plugin/app.test.tsx index 3ffc7bcf275d7..b8176cdb14c12 100644 --- a/x-pack/legacy/plugins/lens/public/app_plugin/app.test.tsx +++ b/x-pack/legacy/plugins/lens/public/app_plugin/app.test.tsx @@ -16,26 +16,23 @@ import { esFilters, IFieldType, IIndexPattern } from '../../../../../../src/plug import { dataPluginMock } from '../../../../../../src/plugins/data/public/mocks'; const dataStartMock = dataPluginMock.createStartContract(); -import { TopNavMenuData } from '../../../../../../src/legacy/core_plugins/navigation/public'; +import { TopNavMenuData } from '../../../../../../src/plugins/navigation/public'; import { DataStart } from '../../../../../../src/legacy/core_plugins/data/public'; import { coreMock } from 'src/core/public/mocks'; -jest.mock('../../../../../../src/legacy/core_plugins/navigation/public/legacy', () => ({ - start: { - ui: { - TopNavMenu: jest.fn(() => null), - }, - }, -})); - -import { start as navigation } from '../../../../../../src/legacy/core_plugins/navigation/public/legacy'; - -const { TopNavMenu } = navigation.ui; - jest.mock('ui/new_platform'); jest.mock('../persistence'); jest.mock('src/core/public'); +import { npStart } from 'ui/new_platform'; +jest + .spyOn(npStart.plugins.navigation.ui.TopNavMenu.prototype, 'constructor') + .mockImplementation(() => { + return
; + }); + +const { TopNavMenu } = npStart.plugins.navigation.ui; + const waitForPromises = () => new Promise(resolve => setTimeout(resolve)); function createMockFrame(): jest.Mocked { diff --git a/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx b/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx index fda07c9b6bb77..d3f2ac624a692 100644 --- a/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx +++ b/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx @@ -11,9 +11,8 @@ import { i18n } from '@kbn/i18n'; import { Query, DataPublicPluginStart } from 'src/plugins/data/public'; import { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal'; import { AppMountContext, NotificationsStart } from 'src/core/public'; -import { SavedQuery } from 'src/legacy/core_plugins/data/public'; import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; -import { start as navigation } from '../../../../../../src/legacy/core_plugins/navigation/public/legacy'; +import { npStart } from 'ui/new_platform'; import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public'; import { Document, SavedObjectStore } from '../persistence'; import { EditorFrameInstance } from '../types'; @@ -23,6 +22,7 @@ import { esFilters, IndexPattern as IndexPatternInstance, IndexPatternsContract, + SavedQuery, } from '../../../../../../src/plugins/data/public'; interface State { @@ -160,7 +160,7 @@ export function App({ [] ); - const { TopNavMenu } = navigation.ui; + const { TopNavMenu } = npStart.plugins.navigation.ui; return (