Skip to content

Commit

Permalink
Trying to mount Discover - >Failed to execute 'appendChild' on 'Node'
Browse files Browse the repository at this point in the history
  • Loading branch information
kertal committed Oct 16, 2019
1 parent 32cbbf6 commit 7ba0352
Show file tree
Hide file tree
Showing 10 changed files with 293 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,23 @@
* specific language governing permissions and limitations
* under the License.
*/
// LP type imports
import 'ui/collapsible_sidebar';
import 'ui/directives/listen';
import 'ui/visualize';
import 'ui/fixed_scroll';
import 'ui/index_patterns';
import 'ui/state_management/app_state';
import 'ui/capabilities/route_setup';
import '../saved_searches/saved_searches';
import '../components/field_chooser/field_chooser';
// import { SavedObjectRegistryProvider } from 'ui/saved_objects/saved_object_registry';
// import { SavedObjectsClientProvider } from 'ui/saved_objects';

import angular from 'angular';
import { npStart } from 'ui/new_platform';
const { chrome } = npStart.core;

// exports
export { angular };
export { npStart };
export { chrome };
Expand Down Expand Up @@ -80,6 +85,3 @@ export { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_s
export { getRootBreadcrumbs, getSavedSearchBreadcrumbs } from '../breadcrumbs';
export { buildVislibDimensions } from 'ui/visualize/loader/pipeline_helpers/build_pipeline';
export { IPrivate } from 'ui/private';

// import { SavedObjectRegistryProvider } from 'ui/saved_objects/saved_object_registry';
// import { SavedObjectsClientProvider } from 'ui/saved_objects';
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import * as filterActions from './doc_table/actions/filter';
import indexTemplate from './discover.html';
import { showOpenSearchPanel } from '../top_nav/show_open_search_panel';
import { addHelpMenuToAppChrome } from '../components/help_menu/help_menu_util';
import '../components/fetch_error';
import { getPainlessError } from './get_painless_error';

import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@
* under the License.
*/
// @ts-ignore
import { uiModules } from 'ui/modules';
// import { uiModules } from 'ui/modules';
import { npSetup } from 'ui/new_platform';
import { configureAppAngularModule } from 'ui/legacy_compat';
import { createLocalAngularModule } from '../render_app';

let discoverUiModule: any;

/**
export function getDiscoverModule() {
if (!discoverUiModule) {
discoverUiModule = uiModules.get('apps/discover', [
Expand All @@ -30,3 +35,12 @@ export function getDiscoverModule() {
}
return discoverUiModule;
}
**/

export function getDiscoverModule() {
if (!discoverUiModule) {
discoverUiModule = createLocalAngularModule(npSetup as any);
configureAppAngularModule(discoverUiModule);
}
return discoverUiModule;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,26 @@
* specific language governing permissions and limitations
* under the License.
*/
import uiRoutes from 'ui/routes';
// import uiRoutes from 'ui/routes';
import { getDiscoverModule } from './get_discover_module';

export function getRoutes() {
const module = getDiscoverModule();
const uiRoutes = {
defaults: (a: unknown, b: unknown) => {
module.config(function($routeProvider: any) {
// this need to be done in a different way
// $routeProvider.defaults(a, b);
});
return uiRoutes;
},
when: (a: unknown, b: unknown) => {
module.config(function($routeProvider: any) {
$routeProvider.when(a, b);
});
return uiRoutes;
},
};

return uiRoutes;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/

import './discover';
import { initDiscoverDocApp } from './doc';
import './context';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ import $ from 'jquery';
import rison from 'rison-node';
import { fieldCalculator } from './lib/field_calculator';
import { FieldList } from 'ui/index_patterns';
import { uiModules } from 'ui/modules';
import fieldChooserTemplate from './field_chooser.html';
const app = uiModules.get('apps/discover');
import { getDiscoverModule } from '../../angular/get_discover_module';
const app = getDiscoverModule();

app.directive('discFieldChooser', function ($location, config, $route) {
return {
Expand Down
6 changes: 3 additions & 3 deletions src/legacy/core_plugins/kibana/public/discover/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import { PluginInitializer, PluginInitializerContext } from 'kibana/public';
import { npSetup, npStart } from 'ui/new_platform';
import { DiscoverPlugin, DiscoverSetup, DiscoverStart } from './plugin';

import { start as data } from '../../../../../../src/legacy/core_plugins/data/public/legacy';
// Core will be looking for this when loading our plugin in the new platform
export const plugin: PluginInitializer<DiscoverSetup, DiscoverStart> = (
initializerContext: PluginInitializerContext
Expand All @@ -28,5 +28,5 @@ export const plugin: PluginInitializer<DiscoverSetup, DiscoverStart> = (
};

const pluginInstance = plugin({} as PluginInitializerContext);
export const setup = pluginInstance.setup(npSetup.core, npSetup.plugins);
export const start = pluginInstance.start(npStart.core, npStart.plugins);
export const setup = pluginInstance.setup(npSetup.core, { data, npData: npStart.plugins.data });
export const start = pluginInstance.start(npStart.core, { data, npData: npStart.plugins.data });
25 changes: 0 additions & 25 deletions src/legacy/core_plugins/kibana/public/discover/legacy.ts

This file was deleted.

24 changes: 21 additions & 3 deletions src/legacy/core_plugins/kibana/public/discover/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@

import { CoreSetup, CoreStart, Plugin, PluginInitializerContext } from 'kibana/public';
import { i18n } from '@kbn/i18n';
import './saved_searches/saved_searches';
import './components/field_chooser/field_chooser';
import './angular';

import {
FeatureCatalogueRegistryProvider,
Expand Down Expand Up @@ -64,6 +61,27 @@ export class DiscoverPlugin implements Plugin<DiscoverSetup, DiscoverStart> {
constructor(initializerContext: PluginInitializerContext) {}
setup(core: CoreSetup, plugins: DiscoverSetupDeps): DiscoverSetup {
registerFeature();
core.application.register({
id: 'discover',
title: 'Discover',
order: -1004,
icon: 'plugins/kibana/assets/discover.svg',
euiIconType: 'discoverApp',
mount: async (context, params) => {
const { renderApp } = await import('./render_app');
return renderApp(
context,
{
...params,
...plugins,
addBasePath: core.http.basePath.prepend,
getBasePath: core.http.basePath.get,
},
{}
);
},
});

return {};
}

Expand Down
Loading

0 comments on commit 7ba0352

Please sign in to comment.