From 2d879d9154163f017c0d9f99e51a2d758dd7632d Mon Sep 17 00:00:00 2001 From: sainthkh Date: Wed, 4 Sep 2019 09:47:12 +0900 Subject: [PATCH] Removed visualizations from index.ts and call setup directly from legacy.ts --- .../kibana/public/visualize/listing/visualize_listing.js | 4 ++-- .../saved_visualizations/saved_visualizations.js | 4 ++-- src/legacy/core_plugins/metrics/public/legacy.ts | 4 ++-- .../public/__tests__/region_map_visualization.js | 4 ++-- src/legacy/core_plugins/region_map/public/legacy.ts | 4 ++-- .../public/__tests__/coordinate_maps_visualization.js | 4 ++-- src/legacy/core_plugins/tile_map/public/legacy.ts | 4 ++-- .../core_plugins/vis_type_markdown/public/legacy.ts | 4 ++-- .../vis_type_metric/public/__tests__/metric_vis.js | 4 ++-- src/legacy/core_plugins/vis_type_metric/public/legacy.ts | 4 ++-- .../public/__tests__/table_vis_controller.js | 4 ++-- .../public/agg_table/__tests__/agg_table.js | 6 ++---- .../public/agg_table/__tests__/agg_table_group.js | 6 ++---- src/legacy/core_plugins/vis_type_table/public/legacy.ts | 4 ++-- .../core_plugins/vis_type_tagcloud/public/legacy.ts | 4 ++-- .../vis_type_vega/public/__tests__/vega_visualization.js | 4 ++-- src/legacy/core_plugins/vis_type_vega/public/legacy.ts | 4 ++-- .../visualizations/public/np_ready/public/index.ts | 8 -------- .../legacy/plugins/maps/public/register_vis_type_alias.js | 4 ++-- 19 files changed, 36 insertions(+), 48 deletions(-) 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 94bcc15c83431..4da6ed16a144c 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 @@ -30,7 +30,7 @@ import { SavedObjectsClientProvider } from 'ui/saved_objects'; import { VisualizeListingTable } from './visualize_listing_table'; import { NewVisModal } from '../wizard/new_vis_modal'; import { VisualizeConstants } from '../visualize_constants'; -import { visualizations } from '../../../../visualizations/public/np_ready/public'; +import { setup } from '../../../../visualizations/public/np_ready/public/legacy'; import { i18n } from '@kbn/i18n'; const app = uiModules.get('app/visualize', ['ngRoute', 'react']); @@ -46,7 +46,7 @@ export function VisualizeListingController($injector, createNewVis) { const savedObjectClient = Private(SavedObjectsClientProvider); this.visTypeRegistry = Private(VisTypesRegistryProvider); - this.visTypeAliases = visualizations.types.visTypeAliasRegistry.get(); + this.visTypeAliases = setup.types.visTypeAliasRegistry.get(); timefilter.disableAutoRefreshSelector(); timefilter.disableTimeRangeSelector(); diff --git a/src/legacy/core_plugins/kibana/public/visualize/saved_visualizations/saved_visualizations.js b/src/legacy/core_plugins/kibana/public/visualize/saved_visualizations/saved_visualizations.js index 84a6e4ab44740..5f0a2be54e095 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/saved_visualizations/saved_visualizations.js +++ b/src/legacy/core_plugins/kibana/public/visualize/saved_visualizations/saved_visualizations.js @@ -22,7 +22,7 @@ import { VisTypesRegistryProvider } from 'ui/registry/vis_types'; import { uiModules } from 'ui/modules'; import { SavedObjectLoader, SavedObjectsClientProvider } from 'ui/saved_objects'; import { savedObjectManagementRegistry } from '../../management/saved_object_registry'; -import { visualizations } from '../../../../visualizations/public/np_ready/public'; +import { setup } from '../../../../visualizations/public/np_ready/public/legacy'; import { createVisualizeEditUrl } from '../visualize_constants'; import { findListItems } from './find_list_items'; @@ -86,7 +86,7 @@ app.service('savedVisualizations', function (SavedVis, Private, kbnUrl, chrome) size, mapSavedObjectApiHits: this.mapSavedObjectApiHits.bind(this), savedObjectsClient: this.savedObjectsClient, - visTypes: visualizations.types.visTypeAliasRegistry.get(), + visTypes: setup.types.visTypeAliasRegistry.get(), }); }; diff --git a/src/legacy/core_plugins/metrics/public/legacy.ts b/src/legacy/core_plugins/metrics/public/legacy.ts index 5e6237459432b..8dc24503772db 100644 --- a/src/legacy/core_plugins/metrics/public/legacy.ts +++ b/src/legacy/core_plugins/metrics/public/legacy.ts @@ -20,12 +20,12 @@ import { PluginInitializerContext } from 'kibana/public'; import { npSetup, npStart } from 'ui/new_platform'; -import { visualizations } from '../../visualizations/public/np_ready/public'; +import { setup as setupVisualizations } from '../../visualizations/public/np_ready/public/legacy'; import { MetricsPluginSetupDependencies } from './plugin'; import { plugin } from '.'; const plugins: Readonly = { - visualizations, + visualizations: setupVisualizations, data: npSetup.plugins.data, }; diff --git a/src/legacy/core_plugins/region_map/public/__tests__/region_map_visualization.js b/src/legacy/core_plugins/region_map/public/__tests__/region_map_visualization.js index 3fd7fc8759230..b0b40f8ff704e 100644 --- a/src/legacy/core_plugins/region_map/public/__tests__/region_map_visualization.js +++ b/src/legacy/core_plugins/region_map/public/__tests__/region_map_visualization.js @@ -39,7 +39,7 @@ import afterdatachangePng from './afterdatachange.png'; import afterdatachangeandresizePng from './afterdatachangeandresize.png'; import aftercolorchangePng from './aftercolorchange.png'; import changestartupPng from './changestartup.png'; -import { visualizations } from '../../../visualizations/public/np_ready/public'; +import { setup } from '../../../visualizations/public/np_ready/public/legacy'; import { createRegionMapVisualization } from '../region_map_visualization'; import { createRegionMapTypeDefinition } from '../region_map_type'; @@ -106,7 +106,7 @@ describe('RegionMapsVisualizationTests', function () { uiSettings, }; - visualizations.types.registerVisualization(() => createRegionMapTypeDefinition(dependencies)); + setup.types.registerVisualization(() => createRegionMapTypeDefinition(dependencies)); Vis = Private(visModule.VisProvider); RegionMapsVisualization = createRegionMapVisualization(dependencies); diff --git a/src/legacy/core_plugins/region_map/public/legacy.ts b/src/legacy/core_plugins/region_map/public/legacy.ts index 6ddf3085a03ae..7adbc2117d7ee 100644 --- a/src/legacy/core_plugins/region_map/public/legacy.ts +++ b/src/legacy/core_plugins/region_map/public/legacy.ts @@ -20,7 +20,7 @@ import { PluginInitializerContext } from 'kibana/public'; import { npSetup, npStart } from 'ui/new_platform'; -import { visualizations } from '../../visualizations/public/np_ready/public'; +import { setup as setupVisualizations } from '../../visualizations/public/np_ready/public/legacy'; import { RegionMapPluginSetupDependencies, RegionMapsConfig } from './plugin'; import { LegacyDependenciesPlugin } from './shim'; import { plugin } from '.'; @@ -30,7 +30,7 @@ const regionmapsConfig = npSetup.core.injectedMetadata.getInjectedVar( ) as RegionMapsConfig; const plugins: Readonly = { - visualizations, + visualizations: setupVisualizations, data: npSetup.plugins.data, // Temporary solution diff --git a/src/legacy/core_plugins/tile_map/public/__tests__/coordinate_maps_visualization.js b/src/legacy/core_plugins/tile_map/public/__tests__/coordinate_maps_visualization.js index c02b742fef58f..e32df04a583c2 100644 --- a/src/legacy/core_plugins/tile_map/public/__tests__/coordinate_maps_visualization.js +++ b/src/legacy/core_plugins/tile_map/public/__tests__/coordinate_maps_visualization.js @@ -33,7 +33,7 @@ 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 { visualizations } from '../../../visualizations/public/np_ready/public'; +import { setup } from '../../../visualizations/public/np_ready/public/legacy'; import { createTileMapVisualization } from '../tile_map_visualization'; import { createTileMapTypeDefinition } from '../tile_map_type'; @@ -84,7 +84,7 @@ describe('CoordinateMapsVisualizationTest', function () { $injector, }; - visualizations.types.registerVisualization(() => createTileMapTypeDefinition(dependencies)); + setup.types.registerVisualization(() => createTileMapTypeDefinition(dependencies)); Vis = Private(visModule.VisProvider); CoordinateMapsVisualization = createTileMapVisualization(dependencies); diff --git a/src/legacy/core_plugins/tile_map/public/legacy.ts b/src/legacy/core_plugins/tile_map/public/legacy.ts index 90ee35547ca1a..cf2e702cd09b6 100644 --- a/src/legacy/core_plugins/tile_map/public/legacy.ts +++ b/src/legacy/core_plugins/tile_map/public/legacy.ts @@ -20,13 +20,13 @@ import { PluginInitializerContext } from 'kibana/public'; import { npSetup, npStart } from 'ui/new_platform'; -import { visualizations } from '../../visualizations/public/np_ready/public'; +import { setup as setupVisualizations } from '../../visualizations/public/np_ready/public/legacy'; import { TileMapPluginSetupDependencies } from './plugin'; import { LegacyDependenciesPlugin } from './shim'; import { plugin } from '.'; const plugins: Readonly = { - visualizations, + visualizations: setupVisualizations, data: npSetup.plugins.data, // Temporary solution diff --git a/src/legacy/core_plugins/vis_type_markdown/public/legacy.ts b/src/legacy/core_plugins/vis_type_markdown/public/legacy.ts index 92239fa253d9d..539b4e1bdfb45 100644 --- a/src/legacy/core_plugins/vis_type_markdown/public/legacy.ts +++ b/src/legacy/core_plugins/vis_type_markdown/public/legacy.ts @@ -20,12 +20,12 @@ import { PluginInitializerContext } from 'kibana/public'; import { npSetup, npStart } from 'ui/new_platform'; -import { visualizations } from '../../visualizations/public/np_ready/public'; +import { setup as setupVisualizations } from '../../visualizations/public/np_ready/public/legacy'; import { MarkdownPluginSetupDependencies } from './plugin'; import { plugin } from '.'; const plugins: Readonly = { - visualizations, + visualizations: setupVisualizations, data: npSetup.plugins.data, }; diff --git a/src/legacy/core_plugins/vis_type_metric/public/__tests__/metric_vis.js b/src/legacy/core_plugins/vis_type_metric/public/__tests__/metric_vis.js index 6c0419b05e2c9..ce77c64d77651 100644 --- a/src/legacy/core_plugins/vis_type_metric/public/__tests__/metric_vis.js +++ b/src/legacy/core_plugins/vis_type_metric/public/__tests__/metric_vis.js @@ -24,7 +24,7 @@ import expect from '@kbn/expect'; import { VisProvider } from 'ui/vis'; import LogstashIndexPatternStubProvider from 'fixtures/stubbed_logstash_index_pattern'; -import { visualizations } from '../../../visualizations/public/np_ready/public'; +import { setup as setupVisualizations } from '../../../visualizations/public/np_ready/public/legacy'; import { createMetricVisTypeDefinition } from '../metric_vis_type'; describe('metric_vis - createMetricVisTypeDefinition', () => { @@ -38,7 +38,7 @@ describe('metric_vis - createMetricVisTypeDefinition', () => { const Vis = Private(VisProvider); const metricVisType = createMetricVisTypeDefinition(); - visualizations.types.registerVisualization(() => metricVisType); + setupVisualizations.types.registerVisualization(() => metricVisType); const indexPattern = Private(LogstashIndexPatternStubProvider); diff --git a/src/legacy/core_plugins/vis_type_metric/public/legacy.ts b/src/legacy/core_plugins/vis_type_metric/public/legacy.ts index 190ca95c0ac1e..2eea4c70309de 100644 --- a/src/legacy/core_plugins/vis_type_metric/public/legacy.ts +++ b/src/legacy/core_plugins/vis_type_metric/public/legacy.ts @@ -20,13 +20,13 @@ import { PluginInitializerContext } from 'kibana/public'; import { npSetup, npStart } from 'ui/new_platform'; -import { visualizations } from '../../visualizations/public/np_ready/public'; +import { setup as setupVisualizations } from '../../visualizations/public/np_ready/public/legacy'; import { MetricVisPluginSetupDependencies } from './plugin'; import { LegacyDependenciesPlugin } from './shim'; import { plugin } from '.'; const plugins: Readonly = { - visualizations, + visualizations: setupVisualizations, data: npSetup.plugins.data, // Temporary solution diff --git a/src/legacy/core_plugins/vis_type_table/public/__tests__/table_vis_controller.js b/src/legacy/core_plugins/vis_type_table/public/__tests__/table_vis_controller.js index 802d232e7030e..9110c8dcb8486 100644 --- a/src/legacy/core_plugins/vis_type_table/public/__tests__/table_vis_controller.js +++ b/src/legacy/core_plugins/vis_type_table/public/__tests__/table_vis_controller.js @@ -28,7 +28,7 @@ import { AppStateProvider } from 'ui/state_management/app_state'; import { tabifyAggResponse } from 'ui/agg_response/tabify'; import { createTableVisTypeDefinition } from '../table_vis_type'; -import { visualizations } from '../../../visualizations/public/np_ready/public'; +import { setup as setupVisualizations } from '../../../visualizations/public/np_ready/public/legacy'; describe('Table Vis - Controller', async function () { let $rootScope; @@ -52,7 +52,7 @@ describe('Table Vis - Controller', async function () { createAngularVisualization: VisFactoryProvider(Private).createAngularVisualization, }; - visualizations.types.registerVisualization(() => + setupVisualizations.types.registerVisualization(() => createTableVisTypeDefinition(legacyDependencies) ); diff --git a/src/legacy/core_plugins/vis_type_table/public/agg_table/__tests__/agg_table.js b/src/legacy/core_plugins/vis_type_table/public/agg_table/__tests__/agg_table.js index 78954fb24693b..8521ee729f313 100644 --- a/src/legacy/core_plugins/vis_type_table/public/agg_table/__tests__/agg_table.js +++ b/src/legacy/core_plugins/vis_type_table/public/agg_table/__tests__/agg_table.js @@ -31,7 +31,7 @@ import { round } from 'lodash'; import { VisFactoryProvider } from 'ui/vis/vis_factory'; import { createTableVisTypeDefinition } from '../../table_vis_type'; -import { visualizations } from '../../../../visualizations/public/np_ready/public'; +import { setup } from '../../../../visualizations/public/np_ready/public/legacy'; describe('Table Vis - AggTable Directive', function () { let $rootScope; @@ -107,9 +107,7 @@ describe('Table Vis - AggTable Directive', function () { createAngularVisualization: VisFactoryProvider(Private).createAngularVisualization, }; - visualizations.types.registerVisualization(() => - createTableVisTypeDefinition(legacyDependencies) - ); + setup.types.registerVisualization(() => createTableVisTypeDefinition(legacyDependencies)); tableAggResponse = legacyResponseHandlerProvider().handler; indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider); diff --git a/src/legacy/core_plugins/vis_type_table/public/agg_table/__tests__/agg_table_group.js b/src/legacy/core_plugins/vis_type_table/public/agg_table/__tests__/agg_table_group.js index 6478add0ee2c9..7998a92a4759f 100644 --- a/src/legacy/core_plugins/vis_type_table/public/agg_table/__tests__/agg_table_group.js +++ b/src/legacy/core_plugins/vis_type_table/public/agg_table/__tests__/agg_table_group.js @@ -28,7 +28,7 @@ import { tabifyAggResponse } from 'ui/agg_response/tabify'; import { VisFactoryProvider } from 'ui/vis/vis_factory'; import { createTableVisTypeDefinition } from '../../table_vis_type'; -import { visualizations } from '../../../../visualizations/public/np_ready/public'; +import { setup } from '../../../../visualizations/public/np_ready/public/legacy'; describe('Table Vis - AggTableGroup Directive', function () { let $rootScope; @@ -66,9 +66,7 @@ describe('Table Vis - AggTableGroup Directive', function () { createAngularVisualization: VisFactoryProvider(Private).createAngularVisualization, }; - visualizations.types.registerVisualization(() => - createTableVisTypeDefinition(legacyDependencies) - ); + setup.types.registerVisualization(() => createTableVisTypeDefinition(legacyDependencies)); tableAggResponse = legacyResponseHandlerProvider().handler; indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider); diff --git a/src/legacy/core_plugins/vis_type_table/public/legacy.ts b/src/legacy/core_plugins/vis_type_table/public/legacy.ts index d6e68e7a906c4..8139a70552c48 100644 --- a/src/legacy/core_plugins/vis_type_table/public/legacy.ts +++ b/src/legacy/core_plugins/vis_type_table/public/legacy.ts @@ -22,11 +22,11 @@ import { npSetup, npStart } from 'ui/new_platform'; import { plugin } from '.'; import { TablePluginSetupDependencies } from './plugin'; -import { visualizations } from '../../visualizations/public/np_ready/public'; +import { setup as setupVisualizations } from '../../visualizations/public/np_ready/public/legacy'; import { LegacyDependenciesPlugin } from './shim'; const plugins: Readonly = { - visualizations, + visualizations: setupVisualizations, data: npSetup.plugins.data, // Temporary solution diff --git a/src/legacy/core_plugins/vis_type_tagcloud/public/legacy.ts b/src/legacy/core_plugins/vis_type_tagcloud/public/legacy.ts index 19f6eb915f207..6a5e06b6e6978 100644 --- a/src/legacy/core_plugins/vis_type_tagcloud/public/legacy.ts +++ b/src/legacy/core_plugins/vis_type_tagcloud/public/legacy.ts @@ -20,12 +20,12 @@ import { PluginInitializerContext } from 'kibana/public'; import { npSetup, npStart } from 'ui/new_platform'; -import { visualizations } from '../../visualizations/public/np_ready/public'; +import { setup as setupVisualizations } from '../../visualizations/public/np_ready/public/legacy'; import { TagCloudPluginSetupDependencies } from './plugin'; import { plugin } from '.'; const plugins: Readonly = { - visualizations, + visualizations: setupVisualizations, data: npSetup.plugins.data, }; diff --git a/src/legacy/core_plugins/vis_type_vega/public/__tests__/vega_visualization.js b/src/legacy/core_plugins/vis_type_vega/public/__tests__/vega_visualization.js index e3a69eaa6bd84..012f144983e98 100644 --- a/src/legacy/core_plugins/vis_type_vega/public/__tests__/vega_visualization.js +++ b/src/legacy/core_plugins/vis_type_vega/public/__tests__/vega_visualization.js @@ -41,7 +41,7 @@ import vegaMapImage256 from './vega_map_image_256.png'; import { VegaParser } from '../data_model/vega_parser'; import { SearchCache } from '../data_model/search_cache'; -import { visualizations } from '../../../visualizations/public/np_ready/public'; +import { setup } from '../../../visualizations/public/np_ready/public/legacy'; import { createVegaTypeDefinition } from '../vega_type'; const THRESHOLD = 0.1; @@ -65,7 +65,7 @@ describe('VegaVisualizations', () => { uiSettings: $injector.get('config'), }; - visualizations.types.registerVisualization(() => + setup.types.registerVisualization(() => createVegaTypeDefinition(vegaVisualizationDependencies) ); diff --git a/src/legacy/core_plugins/vis_type_vega/public/legacy.ts b/src/legacy/core_plugins/vis_type_vega/public/legacy.ts index 933c5e2210925..15cf97beb5717 100644 --- a/src/legacy/core_plugins/vis_type_vega/public/legacy.ts +++ b/src/legacy/core_plugins/vis_type_vega/public/legacy.ts @@ -20,13 +20,13 @@ import { PluginInitializerContext } from 'kibana/public'; import { npSetup, npStart } from 'ui/new_platform'; -import { visualizations } from '../../visualizations/public/np_ready/public'; +import { setup as setupVisualizations } from '../../visualizations/public/np_ready/public/legacy'; import { VegaPluginSetupDependencies } from './plugin'; import { LegacyDependenciesPlugin } from './shim'; import { plugin } from '.'; const plugins: Readonly = { - visualizations, + visualizations: setupVisualizations, data: npSetup.plugins.data, // Temporary solution diff --git a/src/legacy/core_plugins/visualizations/public/np_ready/public/index.ts b/src/legacy/core_plugins/visualizations/public/np_ready/public/index.ts index 519ba321b363b..d38acaa3cf3f2 100644 --- a/src/legacy/core_plugins/visualizations/public/np_ready/public/index.ts +++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/index.ts @@ -19,14 +19,6 @@ import { PluginInitializerContext } from 'src/core/public'; import { VisualizationsPublicPlugin, Setup } from './plugin'; -import { setup } from './legacy'; - -/** - * We export visualizations here so that users importing from 'plugins/visualizations' - * will automatically receive the response value of the `setup` contract, mimicking - * the data that will eventually be injected by the new platform. - */ -export const visualizations = setup; /** @public */ export type VisualizationsSetup = Setup; diff --git a/x-pack/legacy/plugins/maps/public/register_vis_type_alias.js b/x-pack/legacy/plugins/maps/public/register_vis_type_alias.js index 2e5b3f9f14854..0799e59bbb011 100644 --- a/x-pack/legacy/plugins/maps/public/register_vis_type_alias.js +++ b/x-pack/legacy/plugins/maps/public/register_vis_type_alias.js @@ -4,11 +4,11 @@ * you may not use this file except in compliance with the Elastic License. */ -import { visualizations } from '../../../../../src/legacy/core_plugins/visualizations/public/np_ready/public'; +import { setup } from '../../../../../src/legacy/core_plugins/visualizations/public/np_ready/public/legacy'; import { i18n } from '@kbn/i18n'; import { APP_ID, APP_ICON, MAP_BASE_URL } from '../common/constants'; -visualizations.types.visTypeAliasRegistry.add({ +setup.types.visTypeAliasRegistry.add({ aliasUrl: MAP_BASE_URL, name: APP_ID, title: i18n.translate('xpack.maps.visTypeAlias.title', {