Skip to content

Commit

Permalink
move visualizations plugin to new platform (#60403)
Browse files Browse the repository at this point in the history
  • Loading branch information
ppisljar authored Mar 27, 2020
1 parent ba3d639 commit 7b0c66f
Show file tree
Hide file tree
Showing 189 changed files with 5,507 additions and 1,543 deletions.
5 changes: 1 addition & 4 deletions .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@
"visTypeVega": "src/legacy/core_plugins/vis_type_vega",
"visTypeVislib": "src/legacy/core_plugins/vis_type_vislib",
"visTypeXy": "src/legacy/core_plugins/vis_type_xy",
"visualizations": [
"src/plugins/visualizations",
"src/legacy/core_plugins/visualizations"
]
"visualizations": "src/plugins/visualizations"
},
"exclude": [
"src/legacy/ui/ui_render/ui_render_mixin.js"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
search: {
aggs: {
AggConfigs: typeof AggConfigs;
aggGroupNamesMap: () => Record<"buckets" | "metrics", string>;
aggGroupNamesMap: () => Record<"metrics" | "buckets", string>;
aggTypeFilters: import("./search/aggs/filter/agg_type_filters").AggTypeFilters;
CidrMask: typeof CidrMask;
convertDateRangeToString: typeof convertDateRangeToString;
Expand Down
6 changes: 3 additions & 3 deletions src/core/MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -1152,12 +1152,12 @@ _See also: [Public's CoreStart API Docs](/docs/development/core/public/kibana-pl
##### Plugins for shared application services
In client code, we have a series of plugins which house shared application services that are being built in the shape of the new platform, but for the time being, are only available in legacy. So if your plugin depends on any of the APIs below, you'll need build your plugin as a legacy plugin that shims the new platform. Once these API's have been moved to the new platform you can migrate your plugin and declare a dependency on the plugin that owns the API's you require.
In client code, we have a series of plugins which house shared application services which are not technically part of `core`, but are often used in Kibana plugins.
The contracts for these plugins are exposed for you to consume in your own plugin; we have created dedicated exports for the `setup` and `start` contracts in a file called `legacy`. By passing these contracts to your plugin's `setup` and `start` methods, you can mimic the functionality that will eventually be provided in the new platform.
This table maps some of the most commonly used legacy items to their new platform locations.
```ts
import { setup, start } from '../core_plugins/visualizations/public/legacy';
import { npStart: { plugins } } from 'ui/new_platform';
```
| Legacy Platform | New Platform | Notes |
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/input_control_vis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { LegacyPluginApi, LegacyPluginInitializer } from '../../../../src/legacy
const inputControlVisPluginInitializer: LegacyPluginInitializer = ({ Plugin }: LegacyPluginApi) =>
new Plugin({
id: 'input_control_vis',
require: ['kibana', 'elasticsearch', 'visualizations', 'interpreter'],
require: ['kibana', 'elasticsearch', 'interpreter'],
publicDir: resolve(__dirname, 'public'),
uiExports: {
styleSheetPaths: resolve(__dirname, 'public/index.scss'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { shallowWithIntl, mountWithIntl } from 'test_utils/enzyme_helpers';
import { findTestSubject } from '@elastic/eui/lib/test';
import { getDepsMock, getIndexPatternMock } from '../../test_utils';
import { ControlsTab, ControlsTabUiProps } from './controls_tab';
import { Vis } from 'src/legacy/core_plugins/visualizations/public';
import { Vis } from '../../../../../../plugins/visualizations/public';

const indexPatternsMock = {
get: getIndexPatternMock,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import React from 'react';
import { shallow } from 'enzyme';
import { mountWithIntl } from 'test_utils/enzyme_helpers';

import { Vis } from 'src/legacy/core_plugins/visualizations/public';
import { Vis } from '../../../../../../plugins/visualizations/public';
import { OptionsTab, OptionsTabProps } from './options_tab';

describe('OptionsTab', () => {
Expand Down
8 changes: 2 additions & 6 deletions src/legacy/core_plugins/input_control_vis/public/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,17 @@ import {
InputControlVisPluginSetupDependencies,
InputControlVisPluginStartDependencies,
} from './plugin';
import {
setup as visualizationsSetup,
start as visualizationsStart,
} from '../../visualizations/public/np_ready/public/legacy';

const setupPlugins: Readonly<InputControlVisPluginSetupDependencies> = {
expressions: npSetup.plugins.expressions,
data: npSetup.plugins.data,
visualizations: visualizationsSetup,
visualizations: npSetup.plugins.visualizations,
};

const startPlugins: Readonly<InputControlVisPluginStartDependencies> = {
expressions: npStart.plugins.expressions,
data: npStart.plugins.data,
visualizations: visualizationsStart,
visualizations: npStart.plugins.visualizations,
};

const pluginInstance = plugin({} as PluginInitializerContext);
Expand Down
5 changes: 4 additions & 1 deletion src/legacy/core_plugins/input_control_vis/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from 'kibana/p

import { DataPublicPluginSetup, DataPublicPluginStart } from 'src/plugins/data/public';
import { Plugin as ExpressionsPublicPlugin } from '../../../../plugins/expressions/public';
import { VisualizationsSetup, VisualizationsStart } from '../../visualizations/public';
import {
VisualizationsSetup,
VisualizationsStart,
} from '../../../../plugins/visualizations/public';
import { createInputControlVisFn } from './input_control_fn';
import { createInputControlVisTypeDefinition } from './input_control_vis_type';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { RangeControl } from './control/range_control_factory';
import { ListControl } from './control/list_control_factory';
import { InputControlVisDependencies } from './plugin';
import { FilterManager, Filter } from '../../../../plugins/data/public';
import { VisParams, Vis } from '../../visualizations/public';
import { VisParams, Vis } from '../../../../plugins/visualizations/public';

export const createInputControlVisController = (deps: InputControlVisDependencies) => {
return class InputControlVisController {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
import { DiscoverStartPlugins } from './plugin';
import { SharePluginStart } from '../../../../../plugins/share/public';
import { ChartsPluginStart } from '../../../../../plugins/charts/public';
import { VisualizationsStart } from '../../../visualizations/public';
import { VisualizationsStart } from '../../../../../plugins/visualizations/public';
import {
createSavedSearchesLoader,
DocViewerComponent,
Expand Down
14 changes: 2 additions & 12 deletions src/legacy/core_plugins/kibana/public/discover/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,8 @@
import { PluginInitializerContext } from 'kibana/public';
import { npSetup, npStart } from 'ui/new_platform';
import { plugin } from './index';
import {
setup as visualizationsSetup,
start as visualizationsStart,
} from '../../../../core_plugins/visualizations/public/np_ready/public/legacy';

// Legacy compatibility part - to be removed at cutover, replaced by a kibana.json file
export const pluginInstance = plugin({} as PluginInitializerContext);
export const setup = pluginInstance.setup(npSetup.core, {
...npSetup.plugins,
visualizations: visualizationsSetup,
});
export const start = pluginInstance.start(npStart.core, {
...npStart.plugins,
visualizations: visualizationsStart,
});
export const setup = pluginInstance.setup(npSetup.core, npSetup.plugins);
export const start = pluginInstance.start(npStart.core, npStart.plugins);
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/kibana/public/discover/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import { HomePublicPluginSetup } from '../../../../../plugins/home/public';
import {
VisualizationsStart,
VisualizationsSetup,
} from '../../../visualizations/public/np_ready/public';
} from '../../../../../plugins/visualizations/public';
import { createKbnUrlTracker } from '../../../../../plugins/kibana_utils/public';

export interface DiscoverSetupPlugins {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import _ from 'lodash';
import { i18n } from '@kbn/i18n';
import { npStart } from 'ui/new_platform';
import { SavedObjectLoader } from '../../../../../plugins/saved_objects/public';
import { start as visualizations } from '../../../visualizations/public/np_ready/public/legacy';
import { createSavedSearchesLoader } from '../../../../../plugins/discover/public';

/**
Expand Down Expand Up @@ -63,7 +62,7 @@ const services = {

savedObjectManagementRegistry.register({
id: 'savedVisualizations',
service: visualizations.savedVisualizationsLoader,
service: npStart.plugins.visualizations.savedVisualizationsLoader,
title: 'visualizations',
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { Storage } from '../../../../../plugins/kibana_utils/public';
import { EmbeddableStart } from '../../../../../plugins/embeddable/public';
import { SharePluginStart } from '../../../../../plugins/share/public';
import { DataPublicPluginStart, IndexPatternsContract } from '../../../../../plugins/data/public';
import { VisualizationsStart } from '../../../visualizations/public';
import { VisualizationsStart } from '../../../../../plugins/visualizations/public';
import { SavedVisualizations } from './np_ready/types';
import { UsageCollectionSetup } from '../../../../../plugins/usage_collection/public';
import { KibanaLegacyStart } from '../../../../../plugins/kibana_legacy/public';
Expand Down
6 changes: 1 addition & 5 deletions src/legacy/core_plugins/kibana/public/visualize/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@

import { PluginInitializerContext } from 'kibana/public';
import { npSetup, npStart } from 'ui/new_platform';
import { start as visualizations } from '../../../visualizations/public/np_ready/public/legacy';
import { plugin } from './index';

const instance = plugin({
env: npSetup.plugins.kibanaLegacy.env,
} as PluginInitializerContext);
instance.setup(npSetup.core, npSetup.plugins);
instance.start(npStart.core, {
...npStart.plugins,
visualizations,
});
instance.start(npStart.core, npStart.plugins);
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ export { absoluteToParsedUrl } from 'ui/url/absolute_to_parsed_url';
export { KibanaParsedUrl } from 'ui/url/kibana_parsed_url';
export { wrapInI18nContext } from 'ui/i18n';
export { DashboardConstants } from '../dashboard/np_ready/dashboard_constants';
export { VisSavedObject, VISUALIZE_EMBEDDABLE_TYPE } from '../../../visualizations/public/';
export {
VisSavedObject,
VISUALIZE_EMBEDDABLE_TYPE,
} from '../../../../../plugins/visualizations/public/';
export {
configureAppAngularModule,
migrateLegacyQuery,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ import {
import { EmbeddableStart } from 'src/plugins/embeddable/public';
import { PersistedState } from 'src/plugins/visualizations/public';
import { LegacyCoreStart } from 'kibana/public';
import { Vis } from 'src/legacy/core_plugins/visualizations/public';
import { VisSavedObject } from '../legacy_imports';
import { SavedVisState } from '../../../../visualizations/public/np_ready/public/types';
import { SavedVisState } from '../../../../../../plugins/visualizations/public';
import { SavedSearch } from '../../../../../../plugins/discover/public';

export type PureVisState = SavedVisState;
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/kibana/public/visualize/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import {
KibanaLegacySetup,
AngularRenderedAppUpdater,
} from '../../../../../plugins/kibana_legacy/public';
import { VisualizationsStart } from '../../../visualizations/public';
import { VisualizationsStart } from '../../../../../plugins/visualizations/public';
import { VisualizeConstants } from './np_ready/visualize_constants';
import { setServices, VisualizeKibanaServices } from './kibana_services';
import {
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/management/public/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* simply delete this shim file.
*
* We are also calling `setup/start` here and exporting our public contract so that
* other legacy plugins are able to import from '../core_plugins/visualizations/legacy'
* other legacy plugins are able to import from '../core_plugins/management/legacy'
* and receive the response value of the `setup/start` contract, mimicking the
* data that will eventually be injected by the new platform.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ import afterdatachangePng from './afterdatachange.png';
import afterdatachangeandresizePng from './afterdatachangeandresize.png';
import aftercolorchangePng from './aftercolorchange.png';
import changestartupPng from './changestartup.png';
import { setup as visualizationsSetup } from '../../../visualizations/public/np_ready/public/legacy';

import { createRegionMapVisualization } from '../region_map_visualization';
import { createRegionMapTypeDefinition } from '../region_map_type';
import { ExprVis } from '../../../visualizations/public/np_ready/public/expressions/vis';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { ExprVis } from '../../../../../plugins/visualizations/public/expressions/vis';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { BaseVisType } from '../../../../../plugins/visualizations/public/vis_types/base_vis_type';

const THRESHOLD = 0.45;
const PIXEL_DIFF = 96;
Expand All @@ -50,6 +52,7 @@ describe('RegionMapsVisualizationTests', function() {
let domNode;
let RegionMapsVisualization;
let vis;
let regionMapVisType;
let dependencies;

let imageComparator;
Expand Down Expand Up @@ -84,8 +87,6 @@ describe('RegionMapsVisualizationTests', function() {
],
};

let visRegComplete = false;

beforeEach(ngMock.module('kibana'));

let getManifestStub;
Expand All @@ -105,11 +106,7 @@ describe('RegionMapsVisualizationTests', function() {
uiSettings,
};

if (!visRegComplete) {
visRegComplete = true;
visualizationsSetup.createBaseVisualization(createRegionMapTypeDefinition(dependencies));
}

regionMapVisType = new BaseVisType(createRegionMapTypeDefinition(dependencies));
RegionMapsVisualization = createRegionMapVisualization(dependencies);

ChoroplethLayer.prototype._makeJsonAjaxCall = async function() {
Expand Down Expand Up @@ -154,7 +151,7 @@ describe('RegionMapsVisualizationTests', function() {
imageComparator = new ImageComparator();

vis = new ExprVis({
type: 'region_map',
type: regionMapVisType,
});

vis.params.bucket = {
Expand Down
3 changes: 1 addition & 2 deletions src/legacy/core_plugins/region_map/public/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import { PluginInitializerContext } from 'kibana/public';
import { npSetup, npStart } from 'ui/new_platform';

import { setup as visualizationsSetup } from '../../visualizations/public/np_ready/public/legacy';
import { RegionMapPluginSetupDependencies, RegionMapsConfig } from './plugin';
import { LegacyDependenciesPlugin } from './shim';
import { plugin } from '.';
Expand All @@ -31,7 +30,7 @@ const regionmapsConfig = npSetup.core.injectedMetadata.getInjectedVar(

const plugins: Readonly<RegionMapPluginSetupDependencies> = {
expressions: npSetup.plugins.expressions,
visualizations: visualizationsSetup,
visualizations: npSetup.plugins.visualizations,

// Temporary solution
// It will be removed when all dependent services are migrated to the new platform.
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/region_map/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
IUiSettingsClient,
} from '../../../../core/public';
import { Plugin as ExpressionsPublicPlugin } from '../../../../plugins/expressions/public';
import { VisualizationsSetup } from '../../visualizations/public';
import { VisualizationsSetup } from '../../../../plugins/visualizations/public';

import { LegacyDependenciesPlugin, LegacyDependenciesPluginSetup } from './shim';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ import EMS_TILES from '../../../../ui/public/vis/__tests__/map/ems_mocks/sample_
import EMS_STYLE_ROAD_MAP_BRIGHT from '../../../../ui/public/vis/__tests__/map/ems_mocks/sample_style_bright';
import EMS_STYLE_ROAD_MAP_DESATURATED from '../../../../ui/public/vis/__tests__/map/ems_mocks/sample_style_desaturated';
import EMS_STYLE_DARK_MAP from '../../../../ui/public/vis/__tests__/map/ems_mocks/sample_style_dark';
import { setup as visualizationsSetup } from '../../../visualizations/public/np_ready/public/legacy';

import { createTileMapVisualization } from '../tile_map_visualization';
import { createTileMapTypeDefinition } from '../tile_map_type';
import { ExprVis } from '../../../visualizations/public/np_ready/public/expressions/vis';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { ExprVis } from '../../../../../plugins/visualizations/public/expressions/vis';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { BaseVisType } from '../../../../../plugins/visualizations/public/vis_types/base_vis_type';

function mockRawData() {
const stack = [dummyESResponse];
Expand All @@ -59,13 +61,13 @@ mockRawData();

const THRESHOLD = 0.45;
const PIXEL_DIFF = 64;
let visRegComplete = false;

describe('CoordinateMapsVisualizationTest', function() {
let domNode;
let CoordinateMapsVisualization;
let vis;
let dependencies;
let visType;

let imageComparator;

Expand All @@ -82,10 +84,7 @@ describe('CoordinateMapsVisualizationTest', function() {
$injector,
};

if (!visRegComplete) {
visRegComplete = true;
visualizationsSetup.createBaseVisualization(createTileMapTypeDefinition(dependencies));
}
visType = new BaseVisType(createTileMapTypeDefinition(dependencies));

CoordinateMapsVisualization = createTileMapVisualization(dependencies);

Expand Down Expand Up @@ -120,7 +119,7 @@ describe('CoordinateMapsVisualizationTest', function() {

imageComparator = new ImageComparator();
vis = new ExprVis({
type: 'tile_map',
type: visType,
});
vis.params = {
mapType: 'Scaled Circle Markers',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';

import { TmsLayer } from 'ui/vis/map/service_settings';
import { Vis } from '../../../visualizations/public';
import { Vis } from '../../../../../plugins/visualizations/public';
import { RegionMapVisParams } from '../../../region_map/public/types';
import { SelectOption, SwitchOption } from '../../../vis_type_vislib/public';
import { WmsInternalOptions } from './wms_internal_options';
Expand Down
3 changes: 1 addition & 2 deletions src/legacy/core_plugins/tile_map/public/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@
import { PluginInitializerContext } from 'kibana/public';
import { npSetup, npStart } from 'ui/new_platform';

import { setup as visualizationsSetup } from '../../visualizations/public/np_ready/public/legacy';
import { TileMapPluginSetupDependencies } from './plugin';
import { LegacyDependenciesPlugin } from './shim';
import { plugin } from '.';

const plugins: Readonly<TileMapPluginSetupDependencies> = {
expressions: npSetup.plugins.expressions,
visualizations: visualizationsSetup,
visualizations: npSetup.plugins.visualizations,

// Temporary solution
// It will be removed when all dependent services are migrated to the new platform.
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/tile_map/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
IUiSettingsClient,
} from '../../../../core/public';
import { Plugin as ExpressionsPublicPlugin } from '../../../../plugins/expressions/public';
import { VisualizationsSetup } from '../../visualizations/public';
import { VisualizationsSetup } from '../../../../plugins/visualizations/public';

import { LegacyDependenciesPlugin, LegacyDependenciesPluginSetup } from './shim';

Expand Down
Loading

0 comments on commit 7b0c66f

Please sign in to comment.