Skip to content

Commit

Permalink
[Maps] Get basic structure of NP client shim in place (elastic#52551) (
Browse files Browse the repository at this point in the history
…elastic#52837)

* Move ui routes init to separate file

* Add index and general maps plugin template

* Add legacy shim. Pass uimodules in as legacy service

* Move ts-ignore

* Fix N/A ts error on uiModules

* Point index file toward legacy file. Minor NP additions
  • Loading branch information
Aaron Caldwell authored Dec 12, 2019
1 parent 2249908 commit e740133
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 28 deletions.
2 changes: 0 additions & 2 deletions x-pack/legacy/plugins/file_upload/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

import { Plugin, CoreStart } from 'src/core/public';
// @ts-ignore
import { initResources } from './util/indexing_service';
// @ts-ignore
import { JsonUploadAndParse } from './components/json_upload_and_parse';
// @ts-ignore
import { initServicesAndConstants } from './kibana_services';
Expand Down
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/maps/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function maps(kibana) {
description: i18n.translate('xpack.maps.appDescription', {
defaultMessage: 'Map application'
}),
main: 'plugins/maps/index',
main: 'plugins/maps/legacy',
icon: 'plugins/maps/icon.svg',
euiIconType: APP_ICON,
},
Expand Down
29 changes: 29 additions & 0 deletions x-pack/legacy/plugins/maps/public/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import './kibana_services';

// import the uiExports that we want to "use"
import 'uiExports/inspectorViews';
import 'uiExports/search';
import 'uiExports/embeddableFactories';
import 'uiExports/embeddableActions';
import 'ui/agg_types';

import 'ui/kbn_top_nav';
import 'ui/autoload/all';
import 'react-vis/dist/style.css';

import './angular/services/gis_map_saved_object_loader';
import './angular/map_controller';
import './routes';
// @ts-ignore
import { PluginInitializerContext } from 'kibana/public';
import { MapsPlugin } from './plugin';

export const plugin = (initializerContext: PluginInitializerContext) => {
return new MapsPlugin();
};
27 changes: 27 additions & 0 deletions x-pack/legacy/plugins/maps/public/legacy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { npSetup, npStart } from 'ui/new_platform';
// @ts-ignore Untyped Module
import { uiModules } from 'ui/modules';
import { PluginInitializerContext } from 'kibana/public'; // eslint-disable-line import/order
import { plugin } from '.';

const pluginInstance = plugin({} as PluginInitializerContext);

const setupPlugins = {
__LEGACY: {
uiModules,
},
plugins: npSetup.plugins,
};

const startPlugins = {
plugins: npStart.plugins,
};

export const setup = pluginInstance.setup(npSetup.core, setupPlugins);
export const start = pluginInstance.start(npStart.core, startPlugins);
31 changes: 31 additions & 0 deletions x-pack/legacy/plugins/maps/public/plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { Plugin, CoreStart } from 'src/core/public';
// @ts-ignore
import { wrapInI18nContext } from 'ui/i18n';
// @ts-ignore
import { MapListing } from './components/map_listing';

/**
* These are the interfaces with your public contracts. You should export these
* for other plugins to use in _their_ `SetupDeps`/`StartDeps` interfaces.
* @public
*/
export type MapsPluginSetup = ReturnType<MapsPlugin['setup']>;
export type MapsPluginStart = ReturnType<MapsPlugin['start']>;

/** @internal */
export class MapsPlugin implements Plugin<MapsPluginSetup, MapsPluginStart> {
public setup(core: any, plugins: any) {
const app = plugins.__LEGACY.uiModules.get('app/maps', ['ngRoute', 'react']);
app.directive('mapListing', function(reactDirective: any) {
return reactDirective(wrapInI18nContext(MapListing));
});
}

public start(core: CoreStart, plugins: any) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,15 @@
* you may not use this file except in compliance with the Elastic License.
*/

import './kibana_services';

import { wrapInI18nContext } from 'ui/i18n';
import { i18n } from '@kbn/i18n';

// import the uiExports that we want to "use"
import 'uiExports/inspectorViews';
import 'uiExports/search';
import 'uiExports/embeddableFactories';
import 'uiExports/embeddableActions';
import 'ui/agg_types';

import { capabilities } from 'ui/capabilities';
import chrome from 'ui/chrome';
import routes from 'ui/routes';
import 'ui/kbn_top_nav';
import { uiModules } from 'ui/modules';
import { docTitle } from 'ui/doc_title';
import 'ui/autoload/all';
import 'react-vis/dist/style.css';

import './angular/services/gis_map_saved_object_loader';
import './angular/map_controller';
import listingTemplate from './angular/listing_ng_wrapper.html';
import mapTemplate from './angular/map.html';
import { MapListing } from './components/map_listing';
import { npStart } from 'ui/new_platform';

const app = uiModules.get('app/maps', ['ngRoute', 'react']);

app.directive('mapListing', function (reactDirective) {
return reactDirective(wrapInI18nContext(MapListing));
});

routes.enable();

routes
Expand Down

0 comments on commit e740133

Please sign in to comment.