diff --git a/src/legacy/core_plugins/interpreter/public/renderers/visualization.tsx b/src/legacy/core_plugins/interpreter/public/renderers/visualization.tsx index 9de6cdeaf5ec..f15cdf23fe15 100644 --- a/src/legacy/core_plugins/interpreter/public/renderers/visualization.tsx +++ b/src/legacy/core_plugins/interpreter/public/renderers/visualization.tsx @@ -21,7 +21,7 @@ import chrome from 'ui/chrome'; import React from 'react'; import { render, unmountComponentAtNode } from 'react-dom'; // @ts-ignore -import { VisProvider } from '../../../../ui/public/visualize/loader/vis'; +import { Vis } from '../../../../ui/public/visualize/loader/vis'; import { Visualization } from '../../../../ui/public/visualize/components'; export const visualization = () => ({ @@ -33,8 +33,6 @@ export const visualization = () => ({ const visType = config.visType || visConfig.type; const $injector = await chrome.dangerouslyGetActiveInjector(); const $rootScope = $injector.get('$rootScope') as any; - const Private = $injector.get('Private') as any; - const Vis = Private(VisProvider); if (handlers.vis) { // special case in visualize, we need to render first (without executing the expression), for maps to work diff --git a/src/legacy/core_plugins/kibana/public/discover/angular/discover.js b/src/legacy/core_plugins/kibana/public/discover/angular/discover.js index ed5049aa912e..3a3f58ca83af 100644 --- a/src/legacy/core_plugins/kibana/public/discover/angular/discover.js +++ b/src/legacy/core_plugins/kibana/public/discover/angular/discover.js @@ -57,7 +57,7 @@ import { subscribeWithScope, tabifyAggResponse, vislibSeriesResponseHandlerProvider, - VisProvider, + Vis, SavedObjectSaveModal, } from '../kibana_services'; @@ -190,7 +190,6 @@ function discoverController( localStorage, uiCapabilities ) { - const Vis = Private(VisProvider); const responseHandler = vislibSeriesResponseHandlerProvider().handler; const getUnhashableStates = Private(getUnhashableStatesProvider); const shareContextMenuExtensions = Private(ShareContextMenuExtensionsRegistryProvider); diff --git a/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts b/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts index b78d05e68aca..a220cf59f6cf 100644 --- a/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts +++ b/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts @@ -114,7 +114,7 @@ export { tabifyAggResponse } from 'ui/agg_response/tabify'; export { vislibSeriesResponseHandlerProvider } from 'ui/vis/response_handlers/vislib'; // EXPORT types -export { VisProvider } from 'ui/vis'; +export { Vis } from 'ui/vis'; export { StaticIndexPattern, IndexPatterns, IndexPattern, FieldType } from 'ui/index_patterns'; export { SearchSource } from 'ui/courier'; export { ElasticSearchHit } from 'ui/registry/doc_views_types'; diff --git a/src/legacy/core_plugins/kibana/public/visualize/saved_visualizations/_saved_vis.js b/src/legacy/core_plugins/kibana/public/visualize/saved_visualizations/_saved_vis.js index f8adaed0bf58..aec80b8d1355 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/saved_visualizations/_saved_vis.js +++ b/src/legacy/core_plugins/kibana/public/visualize/saved_visualizations/_saved_vis.js @@ -25,7 +25,7 @@ * NOTE: It's a type of SavedObject, but specific to visualizations. */ -import { VisProvider } from 'ui/vis'; +import { Vis } from 'ui/vis'; import { uiModules } from 'ui/modules'; import { updateOldState } from 'ui/vis/vis_update_state'; import { VisualizeConstants } from '../visualize_constants'; @@ -39,7 +39,6 @@ import { uiModules .get('app/visualize') .factory('SavedVis', function (Promise, savedSearches, Private) { - const Vis = Private(VisProvider); const SavedObject = Private(SavedObjectProvider); createLegacyClass(SavedVis).inherits(SavedObject); function SavedVis(opts) { 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 9bfa41325796..b57fbd637f0b 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 @@ -22,7 +22,7 @@ import ngMock from 'ng_mock'; import _ from 'lodash'; import ChoroplethLayer from '../choropleth_layer'; import LogstashIndexPatternStubProvider from 'fixtures/stubbed_logstash_index_pattern'; -import * as visModule from 'ui/vis'; +import { Vis } from 'ui/vis'; import { ImageComparator } from 'test_utils/image_comparator'; import worldJson from './world.json'; import EMS_CATALOGUE from '../../../../ui/public/vis/__tests__/map/ems_mocks/sample_manifest.json'; @@ -50,7 +50,6 @@ const PIXEL_DIFF = 96; describe('RegionMapsVisualizationTests', function () { let domNode; let RegionMapsVisualization; - let Vis; let indexPattern; let vis; let dependencies; @@ -113,7 +112,6 @@ describe('RegionMapsVisualizationTests', function () { visualizationsSetup.types.registerVisualization(() => createRegionMapTypeDefinition(dependencies)); } - Vis = Private(visModule.VisProvider); RegionMapsVisualization = createRegionMapVisualization(dependencies); indexPattern = Private(LogstashIndexPatternStubProvider); 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 751f92fe8821..0e3c4fdd9d35 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 @@ -20,7 +20,7 @@ import expect from '@kbn/expect'; import ngMock from 'ng_mock'; import LogstashIndexPatternStubProvider from 'fixtures/stubbed_logstash_index_pattern'; -import * as visModule from 'ui/vis'; +import { Vis } from 'ui/vis'; import { ImageComparator } from 'test_utils/image_comparator'; import dummyESResponse from './dummy_es_response.json'; import initial from './initial.png'; @@ -65,7 +65,6 @@ let visRegComplete = false; describe('CoordinateMapsVisualizationTest', function () { let domNode; let CoordinateMapsVisualization; - let Vis; let indexPattern; let vis; let dependencies; @@ -91,7 +90,6 @@ describe('CoordinateMapsVisualizationTest', function () { } - Vis = Private(visModule.VisProvider); CoordinateMapsVisualization = createTileMapVisualization(dependencies); indexPattern = Private(LogstashIndexPatternStubProvider); 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 7f626df6a4ea..384beb3764e2 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 @@ -21,7 +21,7 @@ import $ from 'jquery'; import ngMock from 'ng_mock'; import expect from '@kbn/expect'; -import { VisProvider } from 'ui/vis'; +import { Vis } from 'ui/vis'; import LogstashIndexPatternStubProvider from 'fixtures/stubbed_logstash_index_pattern'; import { createMetricVisTypeDefinition } from '../metric_vis_type'; @@ -34,7 +34,6 @@ describe('metric_vis - createMetricVisTypeDefinition', () => { beforeEach( ngMock.inject(Private => { setup = () => { - const Vis = Private(VisProvider); const metricVisType = createMetricVisTypeDefinition(); const indexPattern = Private(LogstashIndexPatternStubProvider); 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 abebf8190dc9..4153ce2da36a 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 @@ -21,7 +21,7 @@ import $ from 'jquery'; import expect from '@kbn/expect'; import ngMock from 'ng_mock'; import { legacyResponseHandlerProvider } from 'ui/vis/response_handlers/legacy'; -import { VisProvider } from 'ui/vis'; +import { Vis } from 'ui/vis'; import { VisFactoryProvider } from 'ui/vis/vis_factory'; import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern'; import { AppStateProvider } from 'ui/state_management/app_state'; @@ -36,7 +36,6 @@ describe('Table Vis - Controller', async function () { let Private; let $scope; let $el; - let Vis; let fixtures; let AppState; let tableAggResponse; @@ -63,7 +62,6 @@ describe('Table Vis - Controller', async function () { $compile = $injector.get('$compile'); fixtures = require('fixtures/fake_hierarchical_data'); AppState = Private(AppStateProvider); - Vis = Private(VisProvider); tableAggResponse = legacyResponseHandlerProvider().handler; }) ); 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 d22ff92c4d3f..13e8a4fd9535 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 @@ -25,7 +25,7 @@ import fixtures from 'fixtures/fake_hierarchical_data'; import sinon from 'sinon'; import { legacyResponseHandlerProvider } from 'ui/vis/response_handlers/legacy'; import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern'; -import { VisProvider } from 'ui/vis'; +import { Vis } from 'ui/vis'; import { tabifyAggResponse } from 'ui/agg_response/tabify'; import { round } from 'lodash'; @@ -36,7 +36,6 @@ import { setup as visualizationsSetup } from '../../../../visualizations/public/ describe('Table Vis - AggTable Directive', function () { let $rootScope; let $compile; - let Vis; let indexPattern; let settings; let tableAggResponse; @@ -113,7 +112,6 @@ describe('Table Vis - AggTable Directive', function () { ngMock.inject(function ($injector, Private, config) { tableAggResponse = legacyResponseHandlerProvider().handler; indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider); - Vis = Private(VisProvider); settings = config; $rootScope = $injector.get('$rootScope'); 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 e8359e37d618..f4e3a8e36605 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 @@ -23,13 +23,12 @@ import expect from '@kbn/expect'; import fixtures from 'fixtures/fake_hierarchical_data'; import { legacyResponseHandlerProvider } from 'ui/vis/response_handlers/legacy'; import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern'; -import { VisProvider } from 'ui/vis'; +import { Vis } from 'ui/vis'; import { tabifyAggResponse } from 'ui/agg_response/tabify'; describe('Table Vis - AggTableGroup Directive', function () { let $rootScope; let $compile; - let Vis; let indexPattern; let tableAggResponse; const tabifiedData = {}; @@ -69,7 +68,6 @@ describe('Table Vis - AggTableGroup Directive', function () { tableAggResponse = legacyResponseHandlerProvider().handler; indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider); - Vis = Private(VisProvider); $rootScope = $injector.get('$rootScope'); $compile = $injector.get('$compile'); diff --git a/src/legacy/core_plugins/vis_type_tagcloud/public/components/__tests__/tag_cloud_visualization.js b/src/legacy/core_plugins/vis_type_tagcloud/public/components/__tests__/tag_cloud_visualization.js index 69d08d8cb3f7..0cb903faac47 100644 --- a/src/legacy/core_plugins/vis_type_tagcloud/public/components/__tests__/tag_cloud_visualization.js +++ b/src/legacy/core_plugins/vis_type_tagcloud/public/components/__tests__/tag_cloud_visualization.js @@ -20,7 +20,7 @@ import expect from '@kbn/expect'; import ngMock from 'ng_mock'; import LogstashIndexPatternStubProvider from 'fixtures/stubbed_logstash_index_pattern'; -import * as visModule from 'ui/vis'; +import { Vis } from 'ui/vis'; import { ImageComparator } from 'test_utils/image_comparator'; import { TagCloudVisualization } from '../tag_cloud_visualization'; import basicdrawPng from './basicdraw.png'; @@ -33,7 +33,6 @@ const PIXEL_DIFF = 64; describe('TagCloudVisualizationTest', function () { let domNode; - let Vis; let indexPattern; let vis; let imageComparator; @@ -57,7 +56,6 @@ describe('TagCloudVisualizationTest', function () { beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject((Private) => { - Vis = Private(visModule.VisProvider); indexPattern = Private(LogstashIndexPatternStubProvider); })); diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_editor.js b/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_editor.js index 842d3aa6c4ad..2b42c22ad7c4 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_editor.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_editor.js @@ -44,8 +44,7 @@ const APP_NAME = 'VisEditor'; export class VisEditor extends Component { constructor(props) { super(props); - const { vis } = props; - this.appState = vis.API.getAppState(); + this.appState = props.appState; this.localStorage = new Storage(window.localStorage); this.state = { model: props.visParams, @@ -183,7 +182,6 @@ export class VisEditor extends Component { dirty={this.state.dirty} autoApply={this.state.autoApply} model={model} - appState={this.appState} savedObj={this.props.savedObj} timeRange={this.props.timeRange} uiState={this.uiState} @@ -239,4 +237,5 @@ VisEditor.propTypes = { isEditorMode: PropTypes.bool, savedObj: PropTypes.object, timeRange: PropTypes.object, + appState: PropTypes.object, }; 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 46725a2c5d01..191f35d2e03e 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 @@ -23,7 +23,7 @@ import ngMock from 'ng_mock'; import $ from 'jquery'; import { createVegaVisualization } from '../vega_visualization'; import LogstashIndexPatternStubProvider from 'fixtures/stubbed_logstash_index_pattern'; -import * as visModule from 'ui/vis'; +import { Vis } from 'ui/vis'; import { ImageComparator } from 'test_utils/image_comparator'; import vegaliteGraph from '!!raw-loader!./vegalite_graph.hjson'; @@ -50,7 +50,6 @@ const PIXEL_DIFF = 30; describe('VegaVisualizations', () => { let domNode; let VegaVisualization; - let Vis; let indexPattern; let vis; let imageComparator; @@ -73,7 +72,6 @@ describe('VegaVisualizations', () => { ); } - Vis = Private(visModule.VisProvider); VegaVisualization = createVegaVisualization(vegaVisualizationDependencies); indexPattern = Private(LogstashIndexPatternStubProvider); diff --git a/src/legacy/core_plugins/visualizations/public/index.ts b/src/legacy/core_plugins/visualizations/public/index.ts index ad86c9ddb14c..ca79f547890f 100644 --- a/src/legacy/core_plugins/visualizations/public/index.ts +++ b/src/legacy/core_plugins/visualizations/public/index.ts @@ -39,7 +39,6 @@ export { DefaultEditorSize } from 'ui/vis/editor_size'; import * as types from 'ui/vis/vis'; export type Vis = types.Vis; export type VisParams = types.VisParams; -export type VisProvider = types.VisProvider; export type VisState = types.VisState; export { VisualizationController } from 'ui/vis/vis_types/vis_type'; export { Status } from 'ui/vis/update_status'; diff --git a/src/legacy/ui/public/agg_response/tabify/__tests__/_get_columns.js b/src/legacy/ui/public/agg_response/tabify/__tests__/_get_columns.js index 27b390ed7e47..39303e94adc6 100644 --- a/src/legacy/ui/public/agg_response/tabify/__tests__/_get_columns.js +++ b/src/legacy/ui/public/agg_response/tabify/__tests__/_get_columns.js @@ -20,15 +20,13 @@ import expect from '@kbn/expect'; import ngMock from 'ng_mock'; import { tabifyGetColumns } from '../_get_columns'; -import { VisProvider } from '../../../vis'; +import { Vis } from '../../../vis'; import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern'; describe('get columns', function () { - let Vis; let indexPattern; beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private) { - Vis = Private(VisProvider); indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider); })); diff --git a/src/legacy/ui/public/agg_response/tabify/__tests__/_integration.js b/src/legacy/ui/public/agg_response/tabify/__tests__/_integration.js index fd8df904b600..dabd66a22fcd 100644 --- a/src/legacy/ui/public/agg_response/tabify/__tests__/_integration.js +++ b/src/legacy/ui/public/agg_response/tabify/__tests__/_integration.js @@ -22,16 +22,14 @@ import fixtures from 'fixtures/fake_hierarchical_data'; import expect from '@kbn/expect'; import ngMock from 'ng_mock'; import { tabifyAggResponse } from '../tabify'; -import { VisProvider } from '../../../vis'; +import { Vis } from '../../../vis'; import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern'; describe('tabifyAggResponse Integration', function () { - let Vis; let indexPattern; beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private) { - Vis = Private(VisProvider); indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider); })); diff --git a/src/legacy/ui/public/agg_response/tabify/__tests__/_response_writer.js b/src/legacy/ui/public/agg_response/tabify/__tests__/_response_writer.js index 09668c638d69..001132f97c95 100644 --- a/src/legacy/ui/public/agg_response/tabify/__tests__/_response_writer.js +++ b/src/legacy/ui/public/agg_response/tabify/__tests__/_response_writer.js @@ -20,11 +20,10 @@ import expect from '@kbn/expect'; import ngMock from 'ng_mock'; import { TabbedAggResponseWriter } from '../_response_writer'; -import { VisProvider } from '../../../vis'; +import { Vis } from '../../../vis'; import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern'; describe('TabbedAggResponseWriter class', function () { - let Vis; let Private; let indexPattern; @@ -32,7 +31,6 @@ describe('TabbedAggResponseWriter class', function () { beforeEach(ngMock.inject(function ($injector) { Private = $injector.get('Private'); - Vis = Private(VisProvider); indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider); })); diff --git a/src/legacy/ui/public/agg_types/__tests__/buckets/_terms_other_bucket_helper.js b/src/legacy/ui/public/agg_types/__tests__/buckets/_terms_other_bucket_helper.js index dcadeacb3d1f..759a6b80d8fa 100644 --- a/src/legacy/ui/public/agg_types/__tests__/buckets/_terms_other_bucket_helper.js +++ b/src/legacy/ui/public/agg_types/__tests__/buckets/_terms_other_bucket_helper.js @@ -20,7 +20,7 @@ import expect from '@kbn/expect'; import ngMock from 'ng_mock'; import { buildOtherBucketAgg, mergeOtherBucketAggResponse, updateMissingBucket } from '../../buckets/_terms_other_bucket_helper'; -import { VisProvider } from '../../../vis'; +import { Vis } from '../../../vis'; import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern'; const visConfigSingleTerm = { @@ -158,7 +158,6 @@ describe('Terms Agg Other bucket helper', () => { function init(aggConfig) { ngMock.module('kibana'); ngMock.inject((Private) => { - const Vis = Private(VisProvider); const indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider); vis = new Vis(indexPattern, aggConfig); diff --git a/src/legacy/ui/public/vis/__tests__/_agg_config.js b/src/legacy/ui/public/vis/__tests__/_agg_config.js index 46d7ed4601f2..2e2e0c31bdb8 100644 --- a/src/legacy/ui/public/vis/__tests__/_agg_config.js +++ b/src/legacy/ui/public/vis/__tests__/_agg_config.js @@ -20,7 +20,7 @@ import sinon from 'sinon'; import expect from '@kbn/expect'; import ngMock from 'ng_mock'; -import { VisProvider } from '..'; +import { Vis } from '..'; import { AggType } from '../../agg_types/agg_type'; import { AggConfig } from '../../agg_types/agg_config'; import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern'; @@ -28,12 +28,10 @@ import { fieldFormats } from '../../registry/field_formats'; describe('AggConfig', function () { - let Vis; let indexPattern; beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private) { - Vis = Private(VisProvider); indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider); })); diff --git a/src/legacy/ui/public/vis/__tests__/_agg_configs.js b/src/legacy/ui/public/vis/__tests__/_agg_configs.js index 96e4aa943ed1..3240bd56f150 100644 --- a/src/legacy/ui/public/vis/__tests__/_agg_configs.js +++ b/src/legacy/ui/public/vis/__tests__/_agg_configs.js @@ -22,7 +22,7 @@ import sinon from 'sinon'; import expect from '@kbn/expect'; import ngMock from 'ng_mock'; import { AggConfig } from '../../agg_types/agg_config'; -import { VisProvider } from '..'; +import { Vis } from '..'; import { AggConfigs } from '../../agg_types/agg_configs'; import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern'; import { Schemas } from '../editors/default/schemas'; @@ -30,13 +30,11 @@ import { AggGroupNames } from '../editors/default/agg_groups'; describe('AggConfigs', function () { - let Vis; let indexPattern; beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private) { // load main deps - Vis = Private(VisProvider); indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider); })); diff --git a/src/legacy/ui/public/vis/__tests__/_vis.js b/src/legacy/ui/public/vis/__tests__/_vis.js index 5a2f93ab35b5..1d5e2de6dafe 100644 --- a/src/legacy/ui/public/vis/__tests__/_vis.js +++ b/src/legacy/ui/public/vis/__tests__/_vis.js @@ -20,13 +20,12 @@ import _ from 'lodash'; import ngMock from 'ng_mock'; import expect from '@kbn/expect'; -import { VisProvider } from '..'; +import { Vis } from '..'; import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern'; import { start as visualizations } from '../../../../core_plugins/visualizations/public/np_ready/public/legacy'; describe('Vis Class', function () { let indexPattern; - let Vis; let visTypes; let vis; @@ -43,7 +42,6 @@ describe('Vis Class', function () { beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private) { - Vis = Private(VisProvider); indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider); visTypes = visualizations.types; })); diff --git a/src/legacy/ui/public/vis/index.d.ts b/src/legacy/ui/public/vis/index.d.ts index 5a2a7edb6329..791ce2563e0f 100644 --- a/src/legacy/ui/public/vis/index.d.ts +++ b/src/legacy/ui/public/vis/index.d.ts @@ -18,5 +18,5 @@ */ export { AggConfig } from '../agg_types/agg_config'; -export { Vis, VisProvider, VisParams, VisState } from './vis'; +export { Vis, VisParams, VisState } from './vis'; export { VisualizationController, VisType } from './vis_types/vis_type'; diff --git a/src/legacy/ui/public/vis/index.js b/src/legacy/ui/public/vis/index.js index 711b465a1e8a..05cd030f7d10 100644 --- a/src/legacy/ui/public/vis/index.js +++ b/src/legacy/ui/public/vis/index.js @@ -17,4 +17,4 @@ * under the License. */ -export { VisProvider } from './vis'; +export { Vis } from './vis'; diff --git a/src/legacy/ui/public/vis/vis.d.ts b/src/legacy/ui/public/vis/vis.d.ts index be73cccf06a5..e16562641801 100644 --- a/src/legacy/ui/public/vis/vis.d.ts +++ b/src/legacy/ui/public/vis/vis.d.ts @@ -30,8 +30,6 @@ export interface Vis { [key: string]: any; } -export type VisProvider = (...dependencies: any[]) => Vis; - export interface VisParams { [key: string]: any; } diff --git a/src/legacy/ui/public/vis/vis.js b/src/legacy/ui/public/vis/vis.js index c1fff1556e3a..304289a5cfa0 100644 --- a/src/legacy/ui/public/vis/vis.js +++ b/src/legacy/ui/public/vis/vis.js @@ -38,181 +38,178 @@ import { start as visualizations } from '../../../core_plugins/visualizations/pu import '../directives/bind'; -export function VisProvider(Private, getAppState) { - const visTypes = visualizations.types; +const visTypes = visualizations.types; - class Vis extends EventEmitter { - constructor(indexPattern, visState) { - super(); - visState = visState || {}; +class Vis extends EventEmitter { + constructor(indexPattern, visState) { + super(); + visState = visState || {}; - if (_.isString(visState)) { - visState = { - type: visState - }; - } - this.indexPattern = indexPattern; - this._setUiState(new PersistedState()); - this.setCurrentState(visState); - this.setState(this.getCurrentState(), false); - - // Session state is for storing information that is transitory, and will not be saved with the visualization. - // For instance, map bounds, which depends on the view port, browser window size, etc. - this.sessionState = {}; - - this.API = { - SearchSource: SearchSource, - events: { - filter: data => this.eventsSubject.next({ name: 'filterBucket', data }), - brush: data => this.eventsSubject.next({ name: 'brush', data }), - }, - getAppState, + if (_.isString(visState)) { + visState = { + type: visState }; } + this.indexPattern = indexPattern; + this._setUiState(new PersistedState()); + this.setCurrentState(visState); + this.setState(this.getCurrentState(), false); - setCurrentState(state) { - this.title = state.title || ''; - const type = state.type || this.type; - if (_.isString(type)) { - this.type = visTypes.get(type); - if (!this.type) { - throw new Error(`Invalid type "${type}"`); - } - } else { - this.type = type; - } - - this.params = _.defaults({}, - _.cloneDeep(state.params || {}), - _.cloneDeep(this.type.visConfig.defaults || {}) - ); - - updateVisualizationConfig(state.params, this.params); - - if (state.aggs || !this.aggs) { - this.aggs = new AggConfigs(this.indexPattern, state.aggs ? state.aggs.aggs || state.aggs : [], this.type.schemas.all); + // Session state is for storing information that is transitory, and will not be saved with the visualization. + // For instance, map bounds, which depends on the view port, browser window size, etc. + this.sessionState = {}; + + this.API = { + SearchSource: SearchSource, + events: { + filter: data => this.eventsSubject.next({ name: 'filterBucket', data }), + brush: data => this.eventsSubject.next({ name: 'brush', data }), + }, + }; + } + + setCurrentState(state) { + this.title = state.title || ''; + const type = state.type || this.type; + if (_.isString(type)) { + this.type = visTypes.get(type); + if (!this.type) { + throw new Error(`Invalid type "${type}"`); } + } else { + this.type = type; } - setState(state, updateCurrentState = true) { - this._state = _.cloneDeep(state); - if (updateCurrentState) { - this.setCurrentState(this._state); - } - } + this.params = _.defaults({}, + _.cloneDeep(state.params || {}), + _.cloneDeep(this.type.visConfig.defaults || {}) + ); - updateState() { - this.setState(this.getCurrentState(true)); - this.emit('update'); - } + updateVisualizationConfig(state.params, this.params); - forceReload() { - this.emit('reload'); - } - - getCurrentState(includeDisabled) { - return { - title: this.title, - type: this.type.name, - params: _.cloneDeep(this.params), - aggs: this.aggs.aggs - .map(agg => agg.toJSON()) - .filter(agg => includeDisabled || agg.enabled) - .filter(Boolean) - }; - } - - getSerializableState(state) { - return { - title: state.title, - type: state.type, - params: _.cloneDeep(state.params), - aggs: state.aggs.aggs - .map(agg => agg.toJSON()) - .filter(agg => agg.enabled) - .filter(Boolean) - }; - } - - copyCurrentState(includeDisabled = false) { - const state = this.getCurrentState(includeDisabled); - state.aggs = new AggConfigs(this.indexPattern, state.aggs.aggs || state.aggs, this.type.schemas.all); - return state; - } - - getStateInternal(includeDisabled) { - return { - title: this._state.title, - type: this._state.type, - params: this._state.params, - aggs: this._state.aggs - .filter(agg => includeDisabled || agg.enabled) - }; - } - - getEnabledState() { - return this.getStateInternal(false); - } - - getAggConfig() { - return this.aggs.clone({ enabledOnly: true }); - } - - getState() { - return this.getStateInternal(true); - } - - isHierarchical() { - if (_.isFunction(this.type.hierarchicalData)) { - return !!this.type.hierarchicalData(this); - } else { - return !!this.type.hierarchicalData; - } - } - - hasSchemaAgg(schemaName, aggTypeName) { - const aggs = this.aggs.bySchemaName(schemaName) || []; - return aggs.some(function (agg) { - if (!agg.type || !agg.type.name) return false; - return agg.type.name === aggTypeName; - }); - } - - hasUiState() { - return !!this.__uiState; - } - - /*** - * this should not be used outside of visualize - * @param uiState - * @private - */ - _setUiState(uiState) { - if (uiState instanceof PersistedState) { - this.__uiState = uiState; - } - } - - getUiState() { - return this.__uiState; - } - - /** - * Currently this is only used to extract map-specific information - * (e.g. mapZoom, mapCenter). - */ - uiStateVal(key, val) { - if (this.hasUiState()) { - if (_.isUndefined(val)) { - return this.__uiState.get(key); - } - return this.__uiState.set(key, val); - } - return val; + if (state.aggs || !this.aggs) { + this.aggs = new AggConfigs(this.indexPattern, state.aggs ? state.aggs.aggs || state.aggs : [], this.type.schemas.all); } } - Vis.prototype.type = 'histogram'; + setState(state, updateCurrentState = true) { + this._state = _.cloneDeep(state); + if (updateCurrentState) { + this.setCurrentState(this._state); + } + } - return Vis; + updateState() { + this.setState(this.getCurrentState(true)); + this.emit('update'); + } + + forceReload() { + this.emit('reload'); + } + + getCurrentState(includeDisabled) { + return { + title: this.title, + type: this.type.name, + params: _.cloneDeep(this.params), + aggs: this.aggs.aggs + .map(agg => agg.toJSON()) + .filter(agg => includeDisabled || agg.enabled) + .filter(Boolean) + }; + } + + getSerializableState(state) { + return { + title: state.title, + type: state.type, + params: _.cloneDeep(state.params), + aggs: state.aggs.aggs + .map(agg => agg.toJSON()) + .filter(agg => agg.enabled) + .filter(Boolean) + }; + } + + copyCurrentState(includeDisabled = false) { + const state = this.getCurrentState(includeDisabled); + state.aggs = new AggConfigs(this.indexPattern, state.aggs.aggs || state.aggs, this.type.schemas.all); + return state; + } + + getStateInternal(includeDisabled) { + return { + title: this._state.title, + type: this._state.type, + params: this._state.params, + aggs: this._state.aggs + .filter(agg => includeDisabled || agg.enabled) + }; + } + + getEnabledState() { + return this.getStateInternal(false); + } + + getAggConfig() { + return this.aggs.clone({ enabledOnly: true }); + } + + getState() { + return this.getStateInternal(true); + } + + isHierarchical() { + if (_.isFunction(this.type.hierarchicalData)) { + return !!this.type.hierarchicalData(this); + } else { + return !!this.type.hierarchicalData; + } + } + + hasSchemaAgg(schemaName, aggTypeName) { + const aggs = this.aggs.bySchemaName(schemaName) || []; + return aggs.some(function (agg) { + if (!agg.type || !agg.type.name) return false; + return agg.type.name === aggTypeName; + }); + } + + hasUiState() { + return !!this.__uiState; + } + + /*** + * this should not be used outside of visualize + * @param uiState + * @private + */ + _setUiState(uiState) { + if (uiState instanceof PersistedState) { + this.__uiState = uiState; + } + } + + getUiState() { + return this.__uiState; + } + + /** + * Currently this is only used to extract map-specific information + * (e.g. mapZoom, mapCenter). + */ + uiStateVal(key, val) { + if (this.hasUiState()) { + if (_.isUndefined(val)) { + return this.__uiState.get(key); + } + return this.__uiState.set(key, val); + } + return val; + } } + +Vis.prototype.type = 'histogram'; + +export { Vis }; diff --git a/src/legacy/ui/public/vis/vis_types/__tests__/vislib_vis_legend.js b/src/legacy/ui/public/vis/vis_types/__tests__/vislib_vis_legend.js index 18eef99f05a7..afb3fea15a43 100644 --- a/src/legacy/ui/public/vis/vis_types/__tests__/vislib_vis_legend.js +++ b/src/legacy/ui/public/vis/vis_types/__tests__/vislib_vis_legend.js @@ -21,7 +21,7 @@ import $ from 'jquery'; import _ from 'lodash'; import expect from '@kbn/expect'; import ngMock from 'ng_mock'; -import { VisProvider } from '../../vis'; +import { Vis } from '../../vis'; import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern'; describe('visualize_legend directive', function () { @@ -29,7 +29,6 @@ describe('visualize_legend directive', function () { let $compile; let $timeout; let $el; - let Vis; let indexPattern; let fixtures; @@ -39,7 +38,6 @@ describe('visualize_legend directive', function () { $compile = $injector.get('$compile'); $timeout = $injector.get('$timeout'); fixtures = require('fixtures/fake_hierarchical_data'); - Vis = Private(VisProvider); indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider); })); diff --git a/src/legacy/ui/public/vislib/__tests__/visualizations/pie_chart.js b/src/legacy/ui/public/vislib/__tests__/visualizations/pie_chart.js index a4f62e6ceb43..5692ae65af28 100644 --- a/src/legacy/ui/public/vislib/__tests__/visualizations/pie_chart.js +++ b/src/legacy/ui/public/vislib/__tests__/visualizations/pie_chart.js @@ -24,7 +24,7 @@ import _ from 'lodash'; import fixtures from 'fixtures/fake_hierarchical_data'; import $ from 'jquery'; import FixturesVislibVisFixtureProvider from 'fixtures/vislib/_vis_fixture'; -import { VisProvider } from '../../../vis'; +import { Vis } from '../../../vis'; import '../../../persisted_state'; import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern'; import { vislibSlicesResponseHandlerProvider } from '../../../vis/response_handlers/vislib'; @@ -113,7 +113,6 @@ describe('No global chart settings', function () { addTooltip: true }; let chart1; - let Vis; let persistedState; let indexPattern; let responseHandler; @@ -123,7 +122,6 @@ describe('No global chart settings', function () { beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private, $injector) { chart1 = Private(FixturesVislibVisFixtureProvider)(visLibParams1); - Vis = Private(VisProvider); persistedState = new ($injector.get('PersistedState'))(); indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider); responseHandler = vislibSlicesResponseHandlerProvider().handler; @@ -203,7 +201,6 @@ describe('Vislib PieChart Class Test Suite', function () { addTooltip: true }; let vis; - let Vis; let persistedState; let indexPattern; let data; @@ -213,7 +210,6 @@ describe('Vislib PieChart Class Test Suite', function () { beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private, $injector) { vis = Private(FixturesVislibVisFixtureProvider)(visLibParams); - Vis = Private(VisProvider); persistedState = new ($injector.get('PersistedState'))(); indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider); responseHandler = vislibSlicesResponseHandlerProvider().handler; diff --git a/src/legacy/ui/public/visualize/loader/vis.js b/src/legacy/ui/public/visualize/loader/vis.js index 1942fd58afeb..29208563055d 100644 --- a/src/legacy/ui/public/visualize/loader/vis.js +++ b/src/legacy/ui/public/visualize/loader/vis.js @@ -33,114 +33,109 @@ import { PersistedState } from '../../persisted_state'; import { start as visualizations } from '../../../../core_plugins/visualizations/public/np_ready/public/legacy'; -export function VisProvider(getAppState) { - const visTypes = visualizations.types; +const visTypes = visualizations.types; - class Vis extends EventEmitter { - constructor(visState = { type: 'histogram' }) { - super(); +export class Vis extends EventEmitter { + constructor(visState = { type: 'histogram' }) { + super(); - this._setUiState(new PersistedState()); - this.setState(visState); + this._setUiState(new PersistedState()); + this.setState(visState); - // Session state is for storing information that is transitory, and will not be saved with the visualization. - // For instance, map bounds, which depends on the view port, browser window size, etc. - this.sessionState = {}; + // Session state is for storing information that is transitory, and will not be saved with the visualization. + // For instance, map bounds, which depends on the view port, browser window size, etc. + this.sessionState = {}; - this.API = { - events: { - filter: data => { - if (!this.eventsSubject) return; - this.eventsSubject.next({ name: 'filterBucket', data }); - }, - brush: data => { - if (!this.eventsSubject) return; - this.eventsSubject.next({ name: 'brush', data }); - }, + this.API = { + events: { + filter: data => { + if (!this.eventsSubject) return; + this.eventsSubject.next({ name: 'filterBucket', data }); }, - getAppState, - }; - } + brush: data => { + if (!this.eventsSubject) return; + this.eventsSubject.next({ name: 'brush', data }); + }, + }, + }; + } - setState(state) { - this.title = state.title || ''; - const type = state.type || this.type; - if (_.isString(type)) { - this.type = visTypes.get(type); - if (!this.type) { - throw new Error(`Invalid type "${type}"`); - } - } else { - this.type = type; + setState(state) { + this.title = state.title || ''; + const type = state.type || this.type; + if (_.isString(type)) { + this.type = visTypes.get(type); + if (!this.type) { + throw new Error(`Invalid type "${type}"`); } - - this.params = _.defaultsDeep({}, - _.cloneDeep(state.params || {}), - _.cloneDeep(this.type.visConfig.defaults || {}) - ); + } else { + this.type = type; } - setCurrentState(state) { - this.setState(state); - } + this.params = _.defaultsDeep({}, + _.cloneDeep(state.params || {}), + _.cloneDeep(this.type.visConfig.defaults || {}) + ); + } - getState() { - return { - title: this.title, - type: this.type.name, - params: _.cloneDeep(this.params), - }; - } + setCurrentState(state) { + this.setState(state); + } - updateState() { - this.emit('update'); - } + getState() { + return { + title: this.title, + type: this.type.name, + params: _.cloneDeep(this.params), + }; + } - forceReload() { - this.emit('reload'); - } + updateState() { + this.emit('update'); + } - isHierarchical() { - if (_.isFunction(this.type.hierarchicalData)) { - return !!this.type.hierarchicalData(this); - } else { - return !!this.type.hierarchicalData; - } - } + forceReload() { + this.emit('reload'); + } - hasUiState() { - return !!this.__uiState; - } - - /*** - * this should not be used outside of visualize - * @param uiState - * @private - */ - _setUiState(uiState) { - if (uiState instanceof PersistedState) { - this.__uiState = uiState; - } - } - - getUiState() { - return this.__uiState; - } - - /** - * Currently this is only used to extract map-specific information - * (e.g. mapZoom, mapCenter). - */ - uiStateVal(key, val) { - if (this.hasUiState()) { - if (_.isUndefined(val)) { - return this.__uiState.get(key); - } - return this.__uiState.set(key, val); - } - return val; + isHierarchical() { + if (_.isFunction(this.type.hierarchicalData)) { + return !!this.type.hierarchicalData(this); + } else { + return !!this.type.hierarchicalData; } } - return Vis; + hasUiState() { + return !!this.__uiState; + } + + /*** + * this should not be used outside of visualize + * @param uiState + * @private + */ + _setUiState(uiState) { + if (uiState instanceof PersistedState) { + this.__uiState = uiState; + } + } + + getUiState() { + return this.__uiState; + } + + /** + * Currently this is only used to extract map-specific information + * (e.g. mapZoom, mapCenter). + */ + uiStateVal(key, val) { + if (this.hasUiState()) { + if (_.isUndefined(val)) { + return this.__uiState.get(key); + } + return this.__uiState.set(key, val); + } + return val; + } }