parent
1563af8f34
commit
b9318aa53c
|
@ -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"
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1153,12 +1153,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 |
|
||||
|
|
|
@ -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'),
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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', () => {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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';
|
||||
|
||||
/**
|
||||
|
@ -63,7 +62,7 @@ const services = {
|
|||
|
||||
savedObjectManagementRegistry.register({
|
||||
id: 'savedVisualizations',
|
||||
service: visualizations.savedVisualizationsLoader,
|
||||
service: npStart.plugins.visualizations.savedVisualizationsLoader,
|
||||
title: 'visualizations',
|
||||
});
|
||||
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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;
|
||||
|
@ -50,6 +52,7 @@ describe('RegionMapsVisualizationTests', function() {
|
|||
let domNode;
|
||||
let RegionMapsVisualization;
|
||||
let vis;
|
||||
let regionMapVisType;
|
||||
let dependencies;
|
||||
|
||||
let imageComparator;
|
||||
|
@ -84,8 +87,6 @@ describe('RegionMapsVisualizationTests', function() {
|
|||
],
|
||||
};
|
||||
|
||||
let visRegComplete = false;
|
||||
|
||||
beforeEach(ngMock.module('kibana'));
|
||||
|
||||
let getManifestStub;
|
||||
|
@ -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() {
|
||||
|
@ -154,7 +151,7 @@ describe('RegionMapsVisualizationTests', function() {
|
|||
imageComparator = new ImageComparator();
|
||||
|
||||
vis = new ExprVis({
|
||||
type: 'region_map',
|
||||
type: regionMapVisType,
|
||||
});
|
||||
|
||||
vis.params.bucket = {
|
||||
|
|
|
@ -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 '.';
|
||||
|
@ -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.
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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];
|
||||
|
@ -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;
|
||||
|
||||
|
@ -82,10 +84,7 @@ describe('CoordinateMapsVisualizationTest', function() {
|
|||
$injector,
|
||||
};
|
||||
|
||||
if (!visRegComplete) {
|
||||
visRegComplete = true;
|
||||
visualizationsSetup.createBaseVisualization(createTileMapTypeDefinition(dependencies));
|
||||
}
|
||||
visType = new BaseVisType(createTileMapTypeDefinition(dependencies));
|
||||
|
||||
CoordinateMapsVisualization = createTileMapVisualization(dependencies);
|
||||
|
||||
|
@ -120,7 +119,7 @@ describe('CoordinateMapsVisualizationTest', function() {
|
|||
|
||||
imageComparator = new ImageComparator();
|
||||
vis = new ExprVis({
|
||||
type: 'tile_map',
|
||||
type: visType,
|
||||
});
|
||||
vis.params = {
|
||||
mapType: 'Scaled Circle Markers',
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -41,7 +41,6 @@ import './directives/saved_object_save_as_checkbox';
|
|||
import './services/saved_sheet_register';
|
||||
|
||||
import rootTemplate from 'plugins/timelion/index.html';
|
||||
import { start as visualizations } from '../../visualizations/public/np_ready/public/legacy';
|
||||
|
||||
import { loadKbnTopNavDirectives } from '../../../../plugins/kibana_legacy/public';
|
||||
loadKbnTopNavDirectives(npStart.plugins.navigation.ui);
|
||||
|
@ -125,7 +124,7 @@ app.controller('timelion', function(
|
|||
timefilter.enableAutoRefreshSelector();
|
||||
timefilter.enableTimeRangeSelector();
|
||||
|
||||
const savedVisualizations = visualizations.savedVisualizationsLoader;
|
||||
const savedVisualizations = npStart.plugins.visualizations.savedVisualizationsLoader;
|
||||
const timezone = getTimezone(config);
|
||||
|
||||
const defaultExpression = '.es(*)';
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { VisParams } from 'src/legacy/core_plugins/visualizations/public';
|
||||
import { VisParams } from 'src/plugins/visualizations/public';
|
||||
import { IAggType, IAggConfig, IAggGroupNames } from 'src/plugins/data/public';
|
||||
import { Schema } from '../schemas';
|
||||
import { EditorVisState } from './sidebar/state/reducers';
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { VisParams } from 'src/legacy/core_plugins/visualizations/public';
|
||||
import { VisParams } from 'src/plugins/visualizations/public';
|
||||
import { IAggConfig } from 'src/plugins/data/public';
|
||||
import { DefaultEditorAggCommonProps } from '../agg_common_props';
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ import { FormattedMessage } from '@kbn/i18n/react';
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import { useDebounce } from 'react-use';
|
||||
|
||||
import { Vis } from 'src/legacy/core_plugins/visualizations/public';
|
||||
import { Vis } from '../../../../../../plugins/visualizations/public';
|
||||
import { discardChanges, EditorAction } from './state';
|
||||
|
||||
interface DefaultEditorControlsProps {
|
||||
|
|
|
@ -23,7 +23,7 @@ import { i18n } from '@kbn/i18n';
|
|||
import { keyCodes, EuiButtonIcon, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
|
||||
import { EventEmitter } from 'events';
|
||||
|
||||
import { Vis } from 'src/legacy/core_plugins/visualizations/public';
|
||||
import { Vis } from 'src/plugins/visualizations/public';
|
||||
import { DefaultEditorNavBar, OptionTab } from './navbar';
|
||||
import { DefaultEditorControls } from './controls';
|
||||
import { setStateParamValue, useEditorReducer, useEditorFormState, discardChanges } from './state';
|
||||
|
|
|
@ -35,7 +35,7 @@ import {
|
|||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
import { Vis } from 'src/legacy/core_plugins/visualizations/public';
|
||||
import { Vis } from '../../../../../../plugins/visualizations/public';
|
||||
import { SavedSearch } from '../../../../../../plugins/discover/public';
|
||||
|
||||
interface LinkedSearchProps {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { Vis, VisParams } from 'src/legacy/core_plugins/visualizations/public';
|
||||
import { Vis, VisParams } from 'src/plugins/visualizations/public';
|
||||
import { IAggConfig } from 'src/plugins/data/public';
|
||||
import { EditorStateActionTypes } from './constants';
|
||||
import { Schema } from '../../../schemas';
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
import { useReducer, useCallback } from 'react';
|
||||
import { EventEmitter } from 'events';
|
||||
|
||||
import { Vis } from 'src/legacy/core_plugins/visualizations/public';
|
||||
import { Vis } from 'src/plugins/visualizations/public';
|
||||
import { createEditorStateReducer, initEditorState, EditorVisState } from './reducers';
|
||||
import { EditorStateActionTypes } from './constants';
|
||||
import { EditorAction } from './actions';
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
import { cloneDeep } from 'lodash';
|
||||
|
||||
import { Vis } from 'src/legacy/core_plugins/visualizations/public';
|
||||
import { Vis } from 'src/plugins/visualizations/public';
|
||||
import { AggGroupNames, DataPublicPluginStart } from '../../../../../../../plugins/data/public';
|
||||
import { EditorStateActionTypes } from './constants';
|
||||
import { getEnabledMetricAggsCount } from '../../agg_group_helper';
|
||||
|
|
|
@ -24,19 +24,18 @@ import { I18nProvider } from '@kbn/i18n/react';
|
|||
import { EventEmitter } from 'events';
|
||||
|
||||
import { EditorRenderProps } from 'src/legacy/core_plugins/kibana/public/visualize/np_ready/types';
|
||||
import { Vis } from 'src/legacy/core_plugins/visualizations/public/';
|
||||
import { Vis, VisualizeEmbeddableContract } from '../../../../plugins/visualizations/public';
|
||||
import { Storage } from '../../../../plugins/kibana_utils/public';
|
||||
import { KibanaContextProvider } from '../../../../plugins/kibana_react/public';
|
||||
import { DefaultEditor } from './default_editor';
|
||||
import { DefaultEditorDataTab, OptionTab } from './components/sidebar';
|
||||
import { VisualizeEmbeddable } from '../../visualizations/public/np_ready/public/embeddable';
|
||||
|
||||
const localStorage = new Storage(window.localStorage);
|
||||
|
||||
export interface DefaultEditorControllerState {
|
||||
vis: Vis;
|
||||
eventEmitter: EventEmitter;
|
||||
embeddableHandler: VisualizeEmbeddable;
|
||||
embeddableHandler: VisualizeEmbeddableContract;
|
||||
optionTabs: OptionTab[];
|
||||
}
|
||||
|
||||
|
|
|
@ -17,9 +17,8 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { PersistedState } from 'src/plugins/visualizations/public';
|
||||
import { Vis, PersistedState } from 'src/plugins/visualizations/public';
|
||||
import { IAggConfigs } from 'src/plugins/data/public';
|
||||
import { Vis } from '../../visualizations/public';
|
||||
|
||||
export interface VisOptionsProps<VisParamType = unknown> {
|
||||
aggs: IAggConfigs;
|
||||
|
|
|
@ -19,14 +19,12 @@
|
|||
|
||||
import { PluginInitializerContext } from 'kibana/public';
|
||||
import { npSetup, npStart } from 'ui/new_platform';
|
||||
|
||||
import { setup as visualizationsSetup } from '../../visualizations/public/np_ready/public/legacy';
|
||||
import { MarkdownPluginSetupDependencies } from './plugin';
|
||||
import { plugin } from '.';
|
||||
|
||||
const plugins: Readonly<MarkdownPluginSetupDependencies> = {
|
||||
expressions: npSetup.plugins.expressions,
|
||||
visualizations: visualizationsSetup,
|
||||
visualizations: npSetup.plugins.visualizations,
|
||||
};
|
||||
|
||||
const pluginInstance = plugin({} as PluginInitializerContext);
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from '../../../../core/public';
|
||||
import { Plugin as ExpressionsPublicPlugin } from '../../../../plugins/expressions/public';
|
||||
import { VisualizationsSetup } from '../../visualizations/public';
|
||||
import { VisualizationsSetup } from '../../../../plugins/visualizations/public';
|
||||
|
||||
import { markdownVisDefinition } from './markdown_vis';
|
||||
import { createMarkdownVisFn } from './markdown_fn';
|
||||
|
|
|
@ -21,7 +21,7 @@ import React from 'react';
|
|||
import { shallow } from 'enzyme';
|
||||
|
||||
import { MetricVisComponent, MetricVisComponentProps } from './metric_vis_component';
|
||||
import { ExprVis } from '../../../visualizations/public/np_ready/public/expressions/vis';
|
||||
import { ExprVis } from '../../../../../plugins/visualizations/public';
|
||||
|
||||
jest.mock('../services', () => ({
|
||||
getFormatService: () => ({
|
||||
|
|
|
@ -27,8 +27,7 @@ import { KibanaDatatable } from '../../../../../plugins/expressions/public';
|
|||
import { getHeatmapColors } from '../../../../../plugins/charts/public';
|
||||
import { VisParams, MetricVisMetric } from '../types';
|
||||
import { getFormatService } from '../services';
|
||||
import { SchemaConfig } from '../../../visualizations/public';
|
||||
import { ExprVis } from '../../../visualizations/public/np_ready/public/expressions/vis';
|
||||
import { SchemaConfig, ExprVis } from '../../../../../plugins/visualizations/public';
|
||||
|
||||
export interface MetricVisComponentProps {
|
||||
visParams: VisParams;
|
||||
|
|
|
@ -19,14 +19,12 @@
|
|||
|
||||
import { PluginInitializerContext } from 'kibana/public';
|
||||
import { npSetup, npStart } from 'ui/new_platform';
|
||||
|
||||
import { setup as visualizationsSetup } from '../../visualizations/public/np_ready/public/legacy';
|
||||
import { MetricVisPluginSetupDependencies } from './plugin';
|
||||
import { plugin } from '.';
|
||||
|
||||
const plugins: Readonly<MetricVisPluginSetupDependencies> = {
|
||||
expressions: npSetup.plugins.expressions,
|
||||
visualizations: visualizationsSetup,
|
||||
visualizations: npSetup.plugins.visualizations,
|
||||
charts: npSetup.plugins.charts,
|
||||
};
|
||||
|
||||
|
|
|
@ -17,112 +17,19 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import $ from 'jquery';
|
||||
|
||||
// TODO This is an integration test and thus requires a running platform. When moving to the new platform,
|
||||
// this test has to be migrated to a real unit test.
|
||||
// @ts-ignore
|
||||
import getStubIndexPattern from 'fixtures/stubbed_logstash_index_pattern';
|
||||
|
||||
import { Vis } from '../../visualizations/public';
|
||||
import {
|
||||
setup as visualizationsSetup,
|
||||
start as visualizationsStart,
|
||||
} from '../../visualizations/public/np_ready/public/legacy';
|
||||
import { createMetricVisTypeDefinition } from './metric_vis_type';
|
||||
import { MetricVisComponent } from './components/metric_vis_component';
|
||||
|
||||
jest.mock('ui/new_platform');
|
||||
|
||||
jest.mock('./services', () => ({
|
||||
getFormatService: () => ({
|
||||
deserialize: () => {
|
||||
return {
|
||||
convert: (x: unknown) => `<a href="http://ip.info?address={{${x}}">ip[${x}]</a>`,
|
||||
};
|
||||
},
|
||||
}),
|
||||
}));
|
||||
|
||||
jest.mock('../../vis_default_editor/public', () => ({
|
||||
Schemas: class {},
|
||||
}));
|
||||
|
||||
describe('metric_vis - createMetricVisTypeDefinition', () => {
|
||||
let vis: Vis;
|
||||
it('has metric vis component set', () => {
|
||||
const def = createMetricVisTypeDefinition();
|
||||
|
||||
beforeAll(() => {
|
||||
visualizationsSetup.createReactVisualization(createMetricVisTypeDefinition());
|
||||
});
|
||||
|
||||
const setup = () => {
|
||||
const stubIndexPattern = getStubIndexPattern();
|
||||
|
||||
stubIndexPattern.stubSetFieldFormat('ip', 'url', {
|
||||
urlTemplate: 'http://ip.info?address={{value}}',
|
||||
labelTemplate: 'ip[{{value}}]',
|
||||
});
|
||||
|
||||
const searchSource = {
|
||||
getField: (name: string) => {
|
||||
if (name === 'index') {
|
||||
return stubIndexPattern;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
// TODO: remove when Vis is converted to typescript. Only importing Vis as type
|
||||
// @ts-ignore
|
||||
vis = visualizationsStart.createVis('metric', {
|
||||
type: 'metric',
|
||||
data: {
|
||||
searchSource,
|
||||
aggs: [{ id: '1', type: 'top_hits', schema: 'metric', params: { field: 'ip' } }],
|
||||
},
|
||||
});
|
||||
|
||||
vis.params.dimensions = {
|
||||
metrics: [
|
||||
{
|
||||
accessor: 0,
|
||||
format: {
|
||||
id: 'url',
|
||||
params: {
|
||||
urlTemplate: 'http://ip.info?address={{value}}',
|
||||
labelTemplate: 'ip[{{value}}]',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const el = document.createElement('div');
|
||||
const metricVisType = visualizationsStart.get('metric');
|
||||
const Controller = metricVisType.visualization;
|
||||
const controller = new Controller(el, vis);
|
||||
const render = (esResponse: any) => {
|
||||
controller.render(esResponse, vis.params);
|
||||
};
|
||||
|
||||
return { el, render };
|
||||
};
|
||||
|
||||
it('renders html value from field formatter', () => {
|
||||
const { el, render } = setup();
|
||||
|
||||
const ip = '235.195.237.208';
|
||||
render({
|
||||
columns: [{ id: 'col-0', name: 'ip' }],
|
||||
rows: [{ 'col-0': ip }],
|
||||
});
|
||||
|
||||
const links = $(el)
|
||||
.find('a[href]')
|
||||
.filter(function() {
|
||||
// @ts-ignore
|
||||
return this.href.includes('ip.info');
|
||||
});
|
||||
|
||||
expect(links.length).toBe(1);
|
||||
expect(links.text()).toBe(`ip[${ip}]`);
|
||||
expect(def.visConfig.component).toBe(MetricVisComponent);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from '../../../../core/public';
|
||||
import { Plugin as ExpressionsPublicPlugin } from '../../../../plugins/expressions/public';
|
||||
import { VisualizationsSetup } from '../../visualizations/public';
|
||||
import { VisualizationsSetup } from '../../../../plugins/visualizations/public';
|
||||
|
||||
import { createMetricVisFn } from './metric_vis_fn';
|
||||
import { createMetricVisTypeDefinition } from './metric_vis_type';
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
import { Range } from '../../../../plugins/expressions/public';
|
||||
import { SchemaConfig } from '../../visualizations/public';
|
||||
import { SchemaConfig } from '../../../../plugins/visualizations/public';
|
||||
import { ColorModes, Labels, Style } from '../../vis_type_vislib/public';
|
||||
import { ColorSchemas } from '../../../../plugins/charts/public';
|
||||
|
||||
|
|
|
@ -21,105 +21,17 @@ import $ from 'jquery';
|
|||
import moment from 'moment';
|
||||
import ngMock from 'ng_mock';
|
||||
import expect from '@kbn/expect';
|
||||
import {
|
||||
metricOnly,
|
||||
threeTermBuckets,
|
||||
oneTermOneHistogramBucketWithTwoMetricsOneTopHitOneDerivative,
|
||||
} from 'fixtures/fake_hierarchical_data';
|
||||
import sinon from 'sinon';
|
||||
import { npStart } from '../../legacy_imports';
|
||||
import { search } from '../../../../../../plugins/data/public';
|
||||
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||
import { round } from 'lodash';
|
||||
import { tableVisTypeDefinition } from '../../table_vis_type';
|
||||
import {
|
||||
setup as visualizationsSetup,
|
||||
start as visualizationsStart,
|
||||
} from '../../../../visualizations/public/np_ready/public/legacy';
|
||||
import { getAngularModule } from '../../get_inner_angular';
|
||||
import { initTableVisLegacyModule } from '../../table_vis_legacy_module';
|
||||
import { tableVisResponseHandler } from '../../table_vis_response_handler';
|
||||
|
||||
const { tabifyAggResponse } = search;
|
||||
import { tabifiedData } from './tabified_data';
|
||||
|
||||
describe('Table Vis - AggTable Directive', function() {
|
||||
let $rootScope;
|
||||
let $compile;
|
||||
let indexPattern;
|
||||
let settings;
|
||||
const tabifiedData = {};
|
||||
|
||||
const init = () => {
|
||||
const searchSource = {
|
||||
getField: name => {
|
||||
if (name === 'index') {
|
||||
return indexPattern;
|
||||
}
|
||||
},
|
||||
};
|
||||
const vis1 = visualizationsStart.createVis('table', {
|
||||
type: 'table',
|
||||
data: { searchSource, aggs: [] },
|
||||
});
|
||||
tabifiedData.metricOnly = tabifyAggResponse(vis1.data.aggs, metricOnly);
|
||||
|
||||
const vis2 = visualizationsStart.createVis('table', {
|
||||
type: 'table',
|
||||
params: {
|
||||
showMetricsAtAllLevels: true,
|
||||
},
|
||||
data: {
|
||||
aggs: [
|
||||
{ type: 'avg', schema: 'metric', params: { field: 'bytes' } },
|
||||
{ type: 'terms', schema: 'bucket', params: { field: 'extension' } },
|
||||
{ type: 'terms', schema: 'bucket', params: { field: 'geo.src' } },
|
||||
{ type: 'terms', schema: 'bucket', params: { field: 'machine.os' } },
|
||||
],
|
||||
searchSource,
|
||||
},
|
||||
});
|
||||
vis2.data.aggs.aggs.forEach(function(agg, i) {
|
||||
agg.id = 'agg_' + (i + 1);
|
||||
});
|
||||
tabifiedData.threeTermBuckets = tabifyAggResponse(vis2.data.aggs, threeTermBuckets, {
|
||||
metricsAtAllLevels: true,
|
||||
});
|
||||
|
||||
const vis3 = visualizationsStart.createVis('table', {
|
||||
type: 'table',
|
||||
data: {
|
||||
aggs: [
|
||||
{ type: 'avg', schema: 'metric', params: { field: 'bytes' } },
|
||||
{ type: 'min', schema: 'metric', params: { field: '@timestamp' } },
|
||||
{ type: 'terms', schema: 'bucket', params: { field: 'extension' } },
|
||||
{
|
||||
type: 'date_histogram',
|
||||
schema: 'bucket',
|
||||
params: { field: '@timestamp', interval: 'd' },
|
||||
},
|
||||
{
|
||||
type: 'derivative',
|
||||
schema: 'metric',
|
||||
params: { metricAgg: 'custom', customMetric: { id: '5-orderAgg', type: 'count' } },
|
||||
},
|
||||
{
|
||||
type: 'top_hits',
|
||||
schema: 'metric',
|
||||
params: { field: 'bytes', aggregate: { val: 'min' }, size: 1 },
|
||||
},
|
||||
],
|
||||
searchSource,
|
||||
},
|
||||
});
|
||||
vis3.data.aggs.aggs.forEach(function(agg, i) {
|
||||
agg.id = 'agg_' + (i + 1);
|
||||
});
|
||||
|
||||
tabifiedData.oneTermOneHistogramBucketWithTwoMetricsOneTopHitOneDerivative = tabifyAggResponse(
|
||||
vis3.data.aggs,
|
||||
oneTermOneHistogramBucketWithTwoMetricsOneTopHitOneDerivative
|
||||
);
|
||||
};
|
||||
|
||||
const initLocalAngular = () => {
|
||||
const tableVisModule = getAngularModule('kibana/table_vis', npStart.core);
|
||||
|
@ -128,20 +40,13 @@ describe('Table Vis - AggTable Directive', function() {
|
|||
|
||||
beforeEach(initLocalAngular);
|
||||
|
||||
ngMock.inject(function() {
|
||||
visualizationsSetup.createBaseVisualization(tableVisTypeDefinition);
|
||||
});
|
||||
|
||||
beforeEach(ngMock.module('kibana/table_vis'));
|
||||
beforeEach(
|
||||
ngMock.inject(function($injector, Private, config) {
|
||||
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
||||
ngMock.inject(function($injector, config) {
|
||||
settings = config;
|
||||
|
||||
$rootScope = $injector.get('$rootScope');
|
||||
$compile = $injector.get('$compile');
|
||||
|
||||
init();
|
||||
})
|
||||
);
|
||||
|
||||
|
@ -158,7 +63,7 @@ describe('Table Vis - AggTable Directive', function() {
|
|||
metrics: [{ accessor: 0, format: { id: 'number' }, params: {} }],
|
||||
buckets: [],
|
||||
};
|
||||
$scope.table = tableVisResponseHandler(tabifiedData.metricOnly, $scope.dimensions).tables[0];
|
||||
$scope.table = tabifiedData.metricOnly.tables[0];
|
||||
|
||||
const $el = $compile('<kbn-agg-table table="table" dimensions="dimensions"></kbn-agg-table>')(
|
||||
$scope
|
||||
|
@ -194,10 +99,7 @@ describe('Table Vis - AggTable Directive', function() {
|
|||
{ accessor: 5, params: {} },
|
||||
],
|
||||
};
|
||||
$scope.table = tableVisResponseHandler(
|
||||
tabifiedData.threeTermBuckets,
|
||||
$scope.dimensions
|
||||
).tables[0];
|
||||
$scope.table = tabifiedData.threeTermBuckets.tables[0];
|
||||
const $el = $('<kbn-agg-table table="table" dimensions="dimensions"></kbn-agg-table>');
|
||||
$compile($el)($scope);
|
||||
$scope.$digest();
|
||||
|
@ -261,11 +163,8 @@ describe('Table Vis - AggTable Directive', function() {
|
|||
{ accessor: 5, format: { id: 'number' } },
|
||||
],
|
||||
};
|
||||
const response = tableVisResponseHandler(
|
||||
tabifiedData.oneTermOneHistogramBucketWithTwoMetricsOneTopHitOneDerivative,
|
||||
$scope.dimensions
|
||||
);
|
||||
$scope.table = response.tables[0];
|
||||
$scope.table =
|
||||
tabifiedData.oneTermOneHistogramBucketWithTwoMetricsOneTopHitOneDerivative.tables[0];
|
||||
$scope.showTotal = true;
|
||||
$scope.totalFunc = totalFunc;
|
||||
const $el = $(`<kbn-agg-table
|
||||
|
@ -361,10 +260,7 @@ describe('Table Vis - AggTable Directive', function() {
|
|||
{ accessor: 5, params: {} },
|
||||
],
|
||||
};
|
||||
$scope.table = tableVisResponseHandler(
|
||||
tabifiedData.threeTermBuckets,
|
||||
$scope.dimensions
|
||||
).tables[0];
|
||||
$scope.table = tabifiedData.threeTermBuckets.tables[0];
|
||||
|
||||
const $el = $compile('<kbn-agg-table table="table" dimensions="dimensions"></kbn-agg-table>')(
|
||||
$scope
|
||||
|
@ -419,10 +315,7 @@ describe('Table Vis - AggTable Directive', function() {
|
|||
{ accessor: 5, params: {} },
|
||||
],
|
||||
};
|
||||
$scope.table = tableVisResponseHandler(
|
||||
tabifiedData.threeTermBuckets,
|
||||
$scope.dimensions
|
||||
).tables[0];
|
||||
$scope.table = tabifiedData.threeTermBuckets.tables[0];
|
||||
|
||||
const $el = $compile('<kbn-agg-table table="table" dimensions="dimensions"></kbn-agg-table>')(
|
||||
$scope
|
||||
|
@ -481,11 +374,8 @@ describe('Table Vis - AggTable Directive', function() {
|
|||
{ accessor: 5, format: { id: 'number' } },
|
||||
],
|
||||
};
|
||||
const response = tableVisResponseHandler(
|
||||
tabifiedData.oneTermOneHistogramBucketWithTwoMetricsOneTopHitOneDerivative,
|
||||
$scope.dimensions
|
||||
);
|
||||
$scope.table = response.tables[0];
|
||||
$scope.table =
|
||||
tabifiedData.oneTermOneHistogramBucketWithTwoMetricsOneTopHitOneDerivative.tables[0];
|
||||
$scope.percentageCol = 'Average bytes';
|
||||
|
||||
const $el = $(`<kbn-agg-table
|
||||
|
|
|
@ -20,54 +20,14 @@
|
|||
import $ from 'jquery';
|
||||
import ngMock from 'ng_mock';
|
||||
import expect from '@kbn/expect';
|
||||
import { metricOnly, threeTermBuckets } from 'fixtures/fake_hierarchical_data';
|
||||
import { npStart } from '../../legacy_imports';
|
||||
import { search } from '../../../../../../plugins/data/public';
|
||||
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||
import { getAngularModule } from '../../get_inner_angular';
|
||||
import { initTableVisLegacyModule } from '../../table_vis_legacy_module';
|
||||
import { tableVisResponseHandler } from '../../table_vis_response_handler';
|
||||
import { start as visualizationsStart } from '../../../../visualizations/public/np_ready/public/legacy';
|
||||
|
||||
const { tabifyAggResponse } = search;
|
||||
import { tabifiedData } from './tabified_data';
|
||||
|
||||
describe('Table Vis - AggTableGroup Directive', function() {
|
||||
let $rootScope;
|
||||
let $compile;
|
||||
let indexPattern;
|
||||
const tabifiedData = {};
|
||||
|
||||
const init = () => {
|
||||
const searchSource = {
|
||||
getField: name => {
|
||||
if (name === 'index') {
|
||||
return indexPattern;
|
||||
}
|
||||
},
|
||||
};
|
||||
const vis1 = visualizationsStart.createVis('table', {
|
||||
type: 'table',
|
||||
data: { searchSource, aggs: [] },
|
||||
});
|
||||
tabifiedData.metricOnly = tabifyAggResponse(vis1.data.aggs, metricOnly);
|
||||
|
||||
const vis2 = visualizationsStart.createVis('pie', {
|
||||
type: 'pie',
|
||||
data: {
|
||||
aggs: [
|
||||
{ type: 'avg', schema: 'metric', params: { field: 'bytes' } },
|
||||
{ type: 'terms', schema: 'split', params: { field: 'extension' } },
|
||||
{ type: 'terms', schema: 'segment', params: { field: 'geo.src' } },
|
||||
{ type: 'terms', schema: 'segment', params: { field: 'machine.os' } },
|
||||
],
|
||||
searchSource,
|
||||
},
|
||||
});
|
||||
vis2.data.aggs.aggs.forEach(function(agg, i) {
|
||||
agg.id = 'agg_' + (i + 1);
|
||||
});
|
||||
tabifiedData.threeTermBuckets = tabifyAggResponse(vis2.data.aggs, threeTermBuckets);
|
||||
};
|
||||
|
||||
const initLocalAngular = () => {
|
||||
const tableVisModule = getAngularModule('kibana/table_vis', npStart.core);
|
||||
|
@ -78,23 +38,9 @@ describe('Table Vis - AggTableGroup Directive', function() {
|
|||
|
||||
beforeEach(ngMock.module('kibana/table_vis'));
|
||||
beforeEach(
|
||||
ngMock.inject(function($injector, Private) {
|
||||
// this is provided in table_vis_controller.js
|
||||
// tech debt that will be resolved through further deangularization and moving tests to jest
|
||||
/*
|
||||
legacyDependencies = {
|
||||
// eslint-disable-next-line new-cap
|
||||
createAngularVisualization: VisFactoryProvider(Private).createAngularVisualization,
|
||||
};
|
||||
|
||||
visualizationsSetup.types.registerVisualization(() => createTableVisTypeDefinition(legacyDependencies));
|
||||
*/
|
||||
|
||||
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
||||
ngMock.inject(function($injector) {
|
||||
$rootScope = $injector.get('$rootScope');
|
||||
$compile = $injector.get('$compile');
|
||||
|
||||
init();
|
||||
})
|
||||
);
|
||||
|
||||
|
@ -111,7 +57,7 @@ describe('Table Vis - AggTableGroup Directive', function() {
|
|||
metrics: [{ accessor: 0, format: { id: 'number' }, params: {} }],
|
||||
buckets: [],
|
||||
};
|
||||
$scope.group = tableVisResponseHandler(tabifiedData.metricOnly, $scope.dimensions);
|
||||
$scope.group = tabifiedData.metricOnly;
|
||||
$scope.sort = {
|
||||
columnIndex: null,
|
||||
direction: null,
|
||||
|
@ -156,10 +102,7 @@ describe('Table Vis - AggTableGroup Directive', function() {
|
|||
{ accessor: 5, params: {} },
|
||||
],
|
||||
};
|
||||
const group = ($scope.group = tableVisResponseHandler(
|
||||
tabifiedData.threeTermBuckets,
|
||||
$scope.dimensions
|
||||
));
|
||||
const group = ($scope.group = tabifiedData.threeTermBucketsWithSplit);
|
||||
const $el = $(
|
||||
'<kbn-agg-table-group dimensions="dimensions" group="group"></kbn-agg-table-group>'
|
||||
);
|
||||
|
|
|
@ -0,0 +1,795 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
export const tabifiedData = {
|
||||
metricOnly: {
|
||||
tables: [
|
||||
{
|
||||
columns: [
|
||||
{
|
||||
id: 'col-0-1',
|
||||
name: 'Count',
|
||||
},
|
||||
],
|
||||
rows: [
|
||||
{
|
||||
'col-0-1': 1000,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
threeTermBuckets: {
|
||||
tables: [
|
||||
{
|
||||
columns: [
|
||||
{
|
||||
id: 'col-0-agg_2',
|
||||
name: 'extension: Descending',
|
||||
},
|
||||
{
|
||||
id: 'col-1-agg_1',
|
||||
name: 'Average bytes',
|
||||
},
|
||||
{
|
||||
id: 'col-2-agg_3',
|
||||
name: 'geo.src: Descending',
|
||||
},
|
||||
{
|
||||
id: 'col-3-agg_1',
|
||||
name: 'Average bytes',
|
||||
},
|
||||
{
|
||||
id: 'col-4-agg_4',
|
||||
name: 'machine.os: Descending',
|
||||
},
|
||||
{
|
||||
id: 'col-5-agg_1',
|
||||
name: 'Average bytes',
|
||||
},
|
||||
],
|
||||
rows: [
|
||||
{
|
||||
'col-0-agg_2': 'png',
|
||||
'col-2-agg_3': 'IT',
|
||||
'col-4-agg_4': 'win',
|
||||
'col-1-agg_1': 412032,
|
||||
'col-3-agg_1': 9299,
|
||||
'col-5-agg_1': 0,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'png',
|
||||
'col-2-agg_3': 'IT',
|
||||
'col-4-agg_4': 'mac',
|
||||
'col-1-agg_1': 412032,
|
||||
'col-3-agg_1': 9299,
|
||||
'col-5-agg_1': 9299,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'png',
|
||||
'col-2-agg_3': 'US',
|
||||
'col-4-agg_4': 'linux',
|
||||
'col-1-agg_1': 412032,
|
||||
'col-3-agg_1': 8293,
|
||||
'col-5-agg_1': 3992,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'png',
|
||||
'col-2-agg_3': 'US',
|
||||
'col-4-agg_4': 'mac',
|
||||
'col-1-agg_1': 412032,
|
||||
'col-3-agg_1': 8293,
|
||||
'col-5-agg_1': 3029,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'css',
|
||||
'col-2-agg_3': 'MX',
|
||||
'col-4-agg_4': 'win',
|
||||
'col-1-agg_1': 412032,
|
||||
'col-3-agg_1': 9299,
|
||||
'col-5-agg_1': 4992,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'css',
|
||||
'col-2-agg_3': 'MX',
|
||||
'col-4-agg_4': 'mac',
|
||||
'col-1-agg_1': 412032,
|
||||
'col-3-agg_1': 9299,
|
||||
'col-5-agg_1': 5892,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'css',
|
||||
'col-2-agg_3': 'US',
|
||||
'col-4-agg_4': 'linux',
|
||||
'col-1-agg_1': 412032,
|
||||
'col-3-agg_1': 8293,
|
||||
'col-5-agg_1': 3992,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'css',
|
||||
'col-2-agg_3': 'US',
|
||||
'col-4-agg_4': 'mac',
|
||||
'col-1-agg_1': 412032,
|
||||
'col-3-agg_1': 8293,
|
||||
'col-5-agg_1': 3029,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'html',
|
||||
'col-2-agg_3': 'CN',
|
||||
'col-4-agg_4': 'win',
|
||||
'col-1-agg_1': 412032,
|
||||
'col-3-agg_1': 9299,
|
||||
'col-5-agg_1': 4992,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'html',
|
||||
'col-2-agg_3': 'CN',
|
||||
'col-4-agg_4': 'mac',
|
||||
'col-1-agg_1': 412032,
|
||||
'col-3-agg_1': 9299,
|
||||
'col-5-agg_1': 5892,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'html',
|
||||
'col-2-agg_3': 'FR',
|
||||
'col-4-agg_4': 'win',
|
||||
'col-1-agg_1': 412032,
|
||||
'col-3-agg_1': 8293,
|
||||
'col-5-agg_1': 3992,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'html',
|
||||
'col-2-agg_3': 'FR',
|
||||
'col-4-agg_4': 'mac',
|
||||
'col-1-agg_1': 412032,
|
||||
'col-3-agg_1': 8293,
|
||||
'col-5-agg_1': 3029,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
threeTermBucketsWithSplit: {
|
||||
tables: [
|
||||
{
|
||||
title: 'png: extension: Descending',
|
||||
name: 'extension: Descending',
|
||||
key: 'png',
|
||||
column: 0,
|
||||
row: 0,
|
||||
table: {
|
||||
columns: [
|
||||
{
|
||||
id: 'col-0-agg_2',
|
||||
name: 'extension: Descending',
|
||||
},
|
||||
{
|
||||
id: 'col-1-agg_3',
|
||||
name: 'geo.src: Descending',
|
||||
},
|
||||
{
|
||||
id: 'col-2-agg_4',
|
||||
name: 'machine.os: Descending',
|
||||
},
|
||||
{
|
||||
id: 'col-3-agg_1',
|
||||
name: 'Average bytes',
|
||||
},
|
||||
],
|
||||
rows: [
|
||||
{
|
||||
'col-0-agg_2': 'png',
|
||||
'col-1-agg_3': 'IT',
|
||||
'col-2-agg_4': 'win',
|
||||
'col-3-agg_1': 0,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'png',
|
||||
'col-1-agg_3': 'IT',
|
||||
'col-2-agg_4': 'mac',
|
||||
'col-3-agg_1': 9299,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'png',
|
||||
'col-1-agg_3': 'US',
|
||||
'col-2-agg_4': 'linux',
|
||||
'col-3-agg_1': 3992,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'png',
|
||||
'col-1-agg_3': 'US',
|
||||
'col-2-agg_4': 'mac',
|
||||
'col-3-agg_1': 3029,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'css',
|
||||
'col-1-agg_3': 'MX',
|
||||
'col-2-agg_4': 'win',
|
||||
'col-3-agg_1': 4992,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'css',
|
||||
'col-1-agg_3': 'MX',
|
||||
'col-2-agg_4': 'mac',
|
||||
'col-3-agg_1': 5892,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'css',
|
||||
'col-1-agg_3': 'US',
|
||||
'col-2-agg_4': 'linux',
|
||||
'col-3-agg_1': 3992,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'css',
|
||||
'col-1-agg_3': 'US',
|
||||
'col-2-agg_4': 'mac',
|
||||
'col-3-agg_1': 3029,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'html',
|
||||
'col-1-agg_3': 'CN',
|
||||
'col-2-agg_4': 'win',
|
||||
'col-3-agg_1': 4992,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'html',
|
||||
'col-1-agg_3': 'CN',
|
||||
'col-2-agg_4': 'mac',
|
||||
'col-3-agg_1': 5892,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'html',
|
||||
'col-1-agg_3': 'FR',
|
||||
'col-2-agg_4': 'win',
|
||||
'col-3-agg_1': 3992,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'html',
|
||||
'col-1-agg_3': 'FR',
|
||||
'col-2-agg_4': 'mac',
|
||||
'col-3-agg_1': 3029,
|
||||
},
|
||||
],
|
||||
},
|
||||
tables: [
|
||||
{
|
||||
columns: [
|
||||
{
|
||||
id: 'col-0-agg_2',
|
||||
name: 'extension: Descending',
|
||||
},
|
||||
{
|
||||
id: 'col-1-agg_3',
|
||||
name: 'geo.src: Descending',
|
||||
},
|
||||
{
|
||||
id: 'col-2-agg_4',
|
||||
name: 'machine.os: Descending',
|
||||
},
|
||||
{
|
||||
id: 'col-3-agg_1',
|
||||
name: 'Average bytes',
|
||||
},
|
||||
],
|
||||
rows: [
|
||||
{
|
||||
'col-0-agg_2': 'png',
|
||||
'col-1-agg_3': 'IT',
|
||||
'col-2-agg_4': 'win',
|
||||
'col-3-agg_1': 0,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'png',
|
||||
'col-1-agg_3': 'IT',
|
||||
'col-2-agg_4': 'mac',
|
||||
'col-3-agg_1': 9299,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'png',
|
||||
'col-1-agg_3': 'US',
|
||||
'col-2-agg_4': 'linux',
|
||||
'col-3-agg_1': 3992,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'png',
|
||||
'col-1-agg_3': 'US',
|
||||
'col-2-agg_4': 'mac',
|
||||
'col-3-agg_1': 3029,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: 'css: extension: Descending',
|
||||
name: 'extension: Descending',
|
||||
key: 'css',
|
||||
column: 0,
|
||||
row: 4,
|
||||
table: {
|
||||
columns: [
|
||||
{
|
||||
id: 'col-0-agg_2',
|
||||
name: 'extension: Descending',
|
||||
},
|
||||
{
|
||||
id: 'col-1-agg_3',
|
||||
name: 'geo.src: Descending',
|
||||
},
|
||||
{
|
||||
id: 'col-2-agg_4',
|
||||
name: 'machine.os: Descending',
|
||||
},
|
||||
{
|
||||
id: 'col-3-agg_1',
|
||||
name: 'Average bytes',
|
||||
},
|
||||
],
|
||||
rows: [
|
||||
{
|
||||
'col-0-agg_2': 'png',
|
||||
'col-1-agg_3': 'IT',
|
||||
'col-2-agg_4': 'win',
|
||||
'col-3-agg_1': 0,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'png',
|
||||
'col-1-agg_3': 'IT',
|
||||
'col-2-agg_4': 'mac',
|
||||
'col-3-agg_1': 9299,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'png',
|
||||
'col-1-agg_3': 'US',
|
||||
'col-2-agg_4': 'linux',
|
||||
'col-3-agg_1': 3992,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'png',
|
||||
'col-1-agg_3': 'US',
|
||||
'col-2-agg_4': 'mac',
|
||||
'col-3-agg_1': 3029,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'css',
|
||||
'col-1-agg_3': 'MX',
|
||||
'col-2-agg_4': 'win',
|
||||
'col-3-agg_1': 4992,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'css',
|
||||
'col-1-agg_3': 'MX',
|
||||
'col-2-agg_4': 'mac',
|
||||
'col-3-agg_1': 5892,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'css',
|
||||
'col-1-agg_3': 'US',
|
||||
'col-2-agg_4': 'linux',
|
||||
'col-3-agg_1': 3992,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'css',
|
||||
'col-1-agg_3': 'US',
|
||||
'col-2-agg_4': 'mac',
|
||||
'col-3-agg_1': 3029,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'html',
|
||||
'col-1-agg_3': 'CN',
|
||||
'col-2-agg_4': 'win',
|
||||
'col-3-agg_1': 4992,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'html',
|
||||
'col-1-agg_3': 'CN',
|
||||
'col-2-agg_4': 'mac',
|
||||
'col-3-agg_1': 5892,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'html',
|
||||
'col-1-agg_3': 'FR',
|
||||
'col-2-agg_4': 'win',
|
||||
'col-3-agg_1': 3992,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'html',
|
||||
'col-1-agg_3': 'FR',
|
||||
'col-2-agg_4': 'mac',
|
||||
'col-3-agg_1': 3029,
|
||||
},
|
||||
],
|
||||
},
|
||||
tables: [
|
||||
{
|
||||
columns: [
|
||||
{
|
||||
id: 'col-0-agg_2',
|
||||
name: 'extension: Descending',
|
||||
},
|
||||
{
|
||||
id: 'col-1-agg_3',
|
||||
name: 'geo.src: Descending',
|
||||
},
|
||||
{
|
||||
id: 'col-2-agg_4',
|
||||
name: 'machine.os: Descending',
|
||||
},
|
||||
{
|
||||
id: 'col-3-agg_1',
|
||||
name: 'Average bytes',
|
||||
},
|
||||
],
|
||||
rows: [
|
||||
{
|
||||
'col-0-agg_2': 'css',
|
||||
'col-1-agg_3': 'MX',
|
||||
'col-2-agg_4': 'win',
|
||||
'col-3-agg_1': 4992,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'css',
|
||||
'col-1-agg_3': 'MX',
|
||||
'col-2-agg_4': 'mac',
|
||||
'col-3-agg_1': 5892,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'css',
|
||||
'col-1-agg_3': 'US',
|
||||
'col-2-agg_4': 'linux',
|
||||
'col-3-agg_1': 3992,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'css',
|
||||
'col-1-agg_3': 'US',
|
||||
'col-2-agg_4': 'mac',
|
||||
'col-3-agg_1': 3029,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: 'html: extension: Descending',
|
||||
name: 'extension: Descending',
|
||||
key: 'html',
|
||||
column: 0,
|
||||
row: 8,
|
||||
table: {
|
||||
columns: [
|
||||
{
|
||||
id: 'col-0-agg_2',
|
||||
name: 'extension: Descending',
|
||||
},
|
||||
{
|
||||
id: 'col-1-agg_3',
|
||||
name: 'geo.src: Descending',
|
||||
},
|
||||
{
|
||||
id: 'col-2-agg_4',
|
||||
name: 'machine.os: Descending',
|
||||
},
|
||||
{
|
||||
id: 'col-3-agg_1',
|
||||
name: 'Average bytes',
|
||||
},
|
||||
],
|
||||
rows: [
|
||||
{
|
||||
'col-0-agg_2': 'png',
|
||||
'col-1-agg_3': 'IT',
|
||||
'col-2-agg_4': 'win',
|
||||
'col-3-agg_1': 0,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'png',
|
||||
'col-1-agg_3': 'IT',
|
||||
'col-2-agg_4': 'mac',
|
||||
'col-3-agg_1': 9299,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'png',
|
||||
'col-1-agg_3': 'US',
|
||||
'col-2-agg_4': 'linux',
|
||||
'col-3-agg_1': 3992,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'png',
|
||||
'col-1-agg_3': 'US',
|
||||
'col-2-agg_4': 'mac',
|
||||
'col-3-agg_1': 3029,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'css',
|
||||
'col-1-agg_3': 'MX',
|
||||
'col-2-agg_4': 'win',
|
||||
'col-3-agg_1': 4992,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'css',
|
||||
'col-1-agg_3': 'MX',
|
||||
'col-2-agg_4': 'mac',
|
||||
'col-3-agg_1': 5892,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'css',
|
||||
'col-1-agg_3': 'US',
|
||||
'col-2-agg_4': 'linux',
|
||||
'col-3-agg_1': 3992,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'css',
|
||||
'col-1-agg_3': 'US',
|
||||
'col-2-agg_4': 'mac',
|
||||
'col-3-agg_1': 3029,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'html',
|
||||
'col-1-agg_3': 'CN',
|
||||
'col-2-agg_4': 'win',
|
||||
'col-3-agg_1': 4992,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'html',
|
||||
'col-1-agg_3': 'CN',
|
||||
'col-2-agg_4': 'mac',
|
||||
'col-3-agg_1': 5892,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'html',
|
||||
'col-1-agg_3': 'FR',
|
||||
'col-2-agg_4': 'win',
|
||||
'col-3-agg_1': 3992,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'html',
|
||||
'col-1-agg_3': 'FR',
|
||||
'col-2-agg_4': 'mac',
|
||||
'col-3-agg_1': 3029,
|
||||
},
|
||||
],
|
||||
},
|
||||
tables: [
|
||||
{
|
||||
columns: [
|
||||
{
|
||||
id: 'col-0-agg_2',
|
||||
name: 'extension: Descending',
|
||||
},
|
||||
{
|
||||
id: 'col-1-agg_3',
|
||||
name: 'geo.src: Descending',
|
||||
},
|
||||
{
|
||||
id: 'col-2-agg_4',
|
||||
name: 'machine.os: Descending',
|
||||
},
|
||||
{
|
||||
id: 'col-3-agg_1',
|
||||
name: 'Average bytes',
|
||||
},
|
||||
],
|
||||
rows: [
|
||||
{
|
||||
'col-0-agg_2': 'html',
|
||||
'col-1-agg_3': 'CN',
|
||||
'col-2-agg_4': 'win',
|
||||
'col-3-agg_1': 4992,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'html',
|
||||
'col-1-agg_3': 'CN',
|
||||
'col-2-agg_4': 'mac',
|
||||
'col-3-agg_1': 5892,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'html',
|
||||
'col-1-agg_3': 'FR',
|
||||
'col-2-agg_4': 'win',
|
||||
'col-3-agg_1': 3992,
|
||||
},
|
||||
{
|
||||
'col-0-agg_2': 'html',
|
||||
'col-1-agg_3': 'FR',
|
||||
'col-2-agg_4': 'mac',
|
||||
'col-3-agg_1': 3029,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
direction: 'row',
|
||||
},
|
||||
oneTermOneHistogramBucketWithTwoMetricsOneTopHitOneDerivative: {
|
||||
tables: [
|
||||
{
|
||||
columns: [
|
||||
{
|
||||
id: 'col-0-agg_3',
|
||||
name: 'extension: Descending',
|
||||
},
|
||||
{
|
||||
id: 'col-1-agg_4',
|
||||
name: '@timestamp per day',
|
||||
},
|
||||
{
|
||||
id: 'col-2-agg_1',
|
||||
name: 'Average bytes',
|
||||
},
|
||||
{
|
||||
id: 'col-3-agg_2',
|
||||
name: 'Min @timestamp',
|
||||
},
|
||||
{
|
||||
id: 'col-4-agg_5',
|
||||
name: 'Derivative of Count',
|
||||
},
|
||||
{
|
||||
id: 'col-5-agg_6',
|
||||
name: 'Last bytes',
|
||||
},
|
||||
],
|
||||
rows: [
|
||||
{
|
||||
'col-0-agg_3': 'png',
|
||||
'col-1-agg_4': 1411862400000,
|
||||
'col-2-agg_1': 9283,
|
||||
'col-3-agg_2': 1411862400000,
|
||||
'col-5-agg_6': 23,
|
||||
},
|
||||
{
|
||||
'col-0-agg_3': 'png',
|
||||
'col-1-agg_4': 1411948800000,
|
||||
'col-2-agg_1': 28349,
|
||||
'col-3-agg_2': 1411948800000,
|
||||
'col-4-agg_5': 203,
|
||||
'col-5-agg_6': 39,
|
||||
},
|
||||
{
|
||||
'col-0-agg_3': 'png',
|
||||
'col-1-agg_4': 1412035200000,
|
||||
'col-2-agg_1': 84330,
|
||||
'col-3-agg_2': 1412035200000,
|
||||
'col-4-agg_5': 200,
|
||||
'col-5-agg_6': 329,
|
||||
},
|
||||
{
|
||||
'col-0-agg_3': 'png',
|
||||
'col-1-agg_4': 1412121600000,
|
||||
'col-2-agg_1': 34992,
|
||||
'col-3-agg_2': 1412121600000,
|
||||
'col-4-agg_5': 103,
|
||||
'col-5-agg_6': 22,
|
||||
},
|
||||
{
|
||||
'col-0-agg_3': 'png',
|
||||
'col-1-agg_4': 1412208000000,
|
||||
'col-2-agg_1': 145432,
|
||||
'col-3-agg_2': 1412208000000,
|
||||
'col-4-agg_5': 153,
|
||||
'col-5-agg_6': 93,
|
||||
},
|
||||
{
|
||||
'col-0-agg_3': 'png',
|
||||
'col-1-agg_4': 1412294400000,
|
||||
'col-2-agg_1': 220943,
|
||||
'col-3-agg_2': 1412294400000,
|
||||
'col-4-agg_5': 239,
|
||||
'col-5-agg_6': 72,
|
||||
},
|
||||
{
|
||||
'col-0-agg_3': 'css',
|
||||
'col-1-agg_4': 1411862400000,
|
||||
'col-2-agg_1': 9283,
|
||||
'col-3-agg_2': 1411862400000,
|
||||
'col-5-agg_6': 75,
|
||||
},
|
||||
{
|
||||
'col-0-agg_3': 'css',
|
||||
'col-1-agg_4': 1411948800000,
|
||||
'col-2-agg_1': 28349,
|
||||
'col-3-agg_2': 1411948800000,
|
||||
'col-4-agg_5': 10,
|
||||
'col-5-agg_6': 11,
|
||||
},
|
||||
{
|
||||
'col-0-agg_3': 'css',
|
||||
'col-1-agg_4': 1412035200000,
|
||||
'col-2-agg_1': 84330,
|
||||
'col-3-agg_2': 1412035200000,
|
||||
'col-4-agg_5': 24,
|
||||
'col-5-agg_6': 238,
|
||||
},
|
||||
{
|
||||
'col-0-agg_3': 'css',
|
||||
'col-1-agg_4': 1412121600000,
|
||||
'col-2-agg_1': 34992,
|
||||
'col-3-agg_2': 1412121600000,
|
||||
'col-4-agg_5': 49,
|
||||
'col-5-agg_6': 343,
|
||||
},
|
||||
{
|
||||
'col-0-agg_3': 'css',
|
||||
'col-1-agg_4': 1412208000000,
|
||||
'col-2-agg_1': 145432,
|
||||
'col-3-agg_2': 1412208000000,
|
||||
'col-4-agg_5': 100,
|
||||
'col-5-agg_6': 837,
|
||||
},
|
||||
{
|
||||
'col-0-agg_3': 'css',
|
||||
'col-1-agg_4': 1412294400000,
|
||||
'col-2-agg_1': 220943,
|
||||
'col-3-agg_2': 1412294400000,
|
||||
'col-4-agg_5': 23,
|
||||
'col-5-agg_6': 302,
|
||||
},
|
||||
{
|
||||
'col-0-agg_3': 'html',
|
||||
'col-1-agg_4': 1411862400000,
|
||||
'col-2-agg_1': 9283,
|
||||
'col-3-agg_2': 1411862400000,
|
||||
'col-5-agg_6': 30,
|
||||
},
|
||||
{
|
||||
'col-0-agg_3': 'html',
|
||||
'col-1-agg_4': 1411948800000,
|
||||
'col-2-agg_1': 28349,
|
||||
'col-3-agg_2': 1411948800000,
|
||||
'col-4-agg_5': 1,
|
||||
'col-5-agg_6': 43,
|
||||
},
|
||||
{
|
||||
'col-0-agg_3': 'html',
|
||||
'col-1-agg_4': 1412035200000,
|
||||
'col-2-agg_1': 84330,
|
||||
'col-3-agg_2': 1412035200000,
|
||||
'col-4-agg_5': 5,
|
||||
'col-5-agg_6': 88,
|
||||
},
|
||||
{
|
||||
'col-0-agg_3': 'html',
|
||||
'col-1-agg_4': 1412121600000,
|
||||
'col-2-agg_1': 34992,
|
||||
'col-3-agg_2': 1412121600000,
|
||||
'col-4-agg_5': 10,
|
||||
'col-5-agg_6': 91,
|
||||
},
|
||||
{
|
||||
'col-0-agg_3': 'html',
|
||||
'col-1-agg_4': 1412208000000,
|
||||
'col-2-agg_1': 145432,
|
||||
'col-3-agg_2': 1412208000000,
|
||||
'col-4-agg_5': 43,
|
||||
'col-5-agg_6': 534,
|
||||
},
|
||||
{
|
||||
'col-0-agg_3': 'html',
|
||||
'col-1-agg_4': 1412294400000,
|
||||
'col-2-agg_1': 220943,
|
||||
'col-3-agg_2': 1412294400000,
|
||||
'col-4-agg_5': 1,
|
||||
'col-5-agg_6': 553,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
|
@ -22,11 +22,10 @@ import { npSetup, npStart } from './legacy_imports';
|
|||
import { plugin } from '.';
|
||||
|
||||
import { TablePluginSetupDependencies } from './plugin';
|
||||
import { setup as visualizationsSetup } from '../../visualizations/public/np_ready/public/legacy';
|
||||
|
||||
const plugins: Readonly<TablePluginSetupDependencies> = {
|
||||
expressions: npSetup.plugins.expressions,
|
||||
visualizations: visualizationsSetup,
|
||||
visualizations: npSetup.plugins.visualizations,
|
||||
};
|
||||
|
||||
const pluginInstance = plugin({} as PluginInitializerContext);
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
import { Plugin as ExpressionsPublicPlugin } from '../../../../plugins/expressions/public';
|
||||
import { VisualizationsSetup } from '../../visualizations/public';
|
||||
import { VisualizationsSetup } from '../../../../plugins/visualizations/public';
|
||||
|
||||
import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from '../../../../core/public';
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ import StubIndexPattern from 'test_utils/stub_index_pattern';
|
|||
import { getAngularModule } from './get_inner_angular';
|
||||
import { initTableVisLegacyModule } from './table_vis_legacy_module';
|
||||
import { tableVisTypeDefinition } from './table_vis_type';
|
||||
import { Vis } from '../../visualizations/public';
|
||||
import { Vis } from '../../../../plugins/visualizations/public';
|
||||
// eslint-disable-next-line
|
||||
import { stubFields } from '../../../../plugins/data/public/stubs';
|
||||
// eslint-disable-next-line
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import { AggGroupNames } from '../../../../plugins/data/public';
|
||||
import { Schemas } from '../../vis_default_editor/public';
|
||||
import { Vis } from '../../visualizations/public';
|
||||
import { Vis } from '../../../../plugins/visualizations/public';
|
||||
import { tableVisResponseHandler } from './table_vis_response_handler';
|
||||
// @ts-ignore
|
||||
import tableVisTemplate from './table_vis.html';
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { SchemaConfig } from '../../visualizations/public';
|
||||
import { SchemaConfig } from '../../../../plugins/visualizations/public';
|
||||
|
||||
export enum AggTypes {
|
||||
SUM = 'sum',
|
||||
|
|
|
@ -20,11 +20,10 @@
|
|||
import angular, { IModule, auto, IRootScopeService, IScope, ICompileService } from 'angular';
|
||||
import $ from 'jquery';
|
||||
|
||||
import { VisParams } from '../../visualizations/public';
|
||||
import { VisParams, ExprVis } from '../../../../plugins/visualizations/public';
|
||||
import { npStart } from './legacy_imports';
|
||||
import { getAngularModule } from './get_inner_angular';
|
||||
import { initTableVisLegacyModule } from './table_vis_legacy_module';
|
||||
import { ExprVis } from '../../visualizations/public/np_ready/public/expressions/vis';
|
||||
|
||||
const innerAngularName = 'kibana/table_vis';
|
||||
|
||||
|
|
|
@ -19,20 +19,23 @@
|
|||
|
||||
import expect from '@kbn/expect';
|
||||
import ngMock from 'ng_mock';
|
||||
import { start as visualizationsStart } from '../../../../../core_plugins/visualizations/public/np_ready/public/legacy';
|
||||
import { ImageComparator } from 'test_utils/image_comparator';
|
||||
import { createTagCloudVisualization } from '../tag_cloud_visualization';
|
||||
import basicdrawPng from './basicdraw.png';
|
||||
import afterresizePng from './afterresize.png';
|
||||
import afterparamChange from './afterparamchange.png';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { ExprVis } from '../../../../../../plugins/visualizations/public/expressions/vis';
|
||||
|
||||
// Replace with mock when converting to jest tests
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { seedColors } from '../../../../../../plugins/charts/public/services/colors/seed_colors';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { BaseVisType } from '../../../../../../plugins/visualizations/public/vis_types/base_vis_type';
|
||||
import { createTagCloudVisTypeDefinition } from '../../tag_cloud_type';
|
||||
|
||||
const THRESHOLD = 0.65;
|
||||
const PIXEL_DIFF = 64;
|
||||
|
||||
describe('TagCloudVisualizationTest', function() {
|
||||
let domNode;
|
||||
let vis;
|
||||
|
@ -67,10 +70,11 @@ describe('TagCloudVisualizationTest', function() {
|
|||
|
||||
describe('TagCloudVisualization - basics', function() {
|
||||
beforeEach(async function() {
|
||||
const visType = new BaseVisType(createTagCloudVisTypeDefinition({ colors: seedColors }));
|
||||
setupDOM('512px', '512px');
|
||||
imageComparator = new ImageComparator();
|
||||
vis = visualizationsStart.createVis('tagcloud', {
|
||||
type: 'tagcloud',
|
||||
vis = new ExprVis({
|
||||
type: visType,
|
||||
params: {
|
||||
bucket: { accessor: 0, format: {} },
|
||||
metric: { accessor: 0, format: {} },
|
||||
|
|
|
@ -19,14 +19,12 @@
|
|||
|
||||
import { PluginInitializerContext } from 'kibana/public';
|
||||
import { npSetup, npStart } from 'ui/new_platform';
|
||||
|
||||
import { setup as visualizationsSetup } from '../../visualizations/public/np_ready/public/legacy';
|
||||
import { TagCloudPluginSetupDependencies } from './plugin';
|
||||
import { plugin } from '.';
|
||||
|
||||
const plugins: Readonly<TagCloudPluginSetupDependencies> = {
|
||||
expressions: npSetup.plugins.expressions,
|
||||
visualizations: visualizationsSetup,
|
||||
visualizations: npSetup.plugins.visualizations,
|
||||
charts: npSetup.plugins.charts,
|
||||
};
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from '../../../../core/public';
|
||||
import { Plugin as ExpressionsPublicPlugin } from '../../../../plugins/expressions/public';
|
||||
import { VisualizationsSetup } from '../../visualizations/public';
|
||||
import { VisualizationsSetup } from '../../../../plugins/visualizations/public';
|
||||
import { ChartsPluginSetup } from '../../../../plugins/charts/public';
|
||||
|
||||
import { createTagCloudFn } from './tag_cloud_fn';
|
||||
|
|
|
@ -23,3 +23,5 @@ import { DataPublicPluginStart } from '../../../../plugins/data/public';
|
|||
export const [getFormatService, setFormatService] = createGetterSetter<
|
||||
DataPublicPluginStart['fieldFormats']
|
||||
>('data.fieldFormats');
|
||||
|
||||
export { npStart } from 'ui/new_platform';
|
||||
|
|
|
@ -25,7 +25,7 @@ import { LegacyPluginApi, LegacyPluginInitializer } from '../../../../src/legacy
|
|||
const timelionVisPluginInitializer: LegacyPluginInitializer = ({ Plugin }: LegacyPluginApi) =>
|
||||
new Plugin({
|
||||
id: 'timelion_vis',
|
||||
require: ['kibana', 'elasticsearch', 'visualizations'],
|
||||
require: ['kibana', 'elasticsearch'],
|
||||
publicDir: resolve(__dirname, 'public'),
|
||||
uiExports: {
|
||||
styleSheetPaths: resolve(__dirname, 'public/index.scss'),
|
||||
|
|
|
@ -23,7 +23,7 @@ import { IUiSettingsClient } from 'kibana/public';
|
|||
import { ChartComponent } from './chart';
|
||||
import { VisParams } from '../timelion_vis_fn';
|
||||
import { TimelionSuccessResponse } from '../helpers/timelion_request_handler';
|
||||
import { ExprVis } from '../../../visualizations/public/np_ready/public/expressions/vis';
|
||||
import { ExprVis } from '../../../../../plugins/visualizations/public';
|
||||
|
||||
export interface TimelionVisComponentProp {
|
||||
config: IUiSettingsClient;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { KIBANA_CONTEXT_NAME } from 'src/plugins/expressions/public';
|
||||
import { VisParams } from 'src/legacy/core_plugins/visualizations/public';
|
||||
import { VisParams } from '../../../../../plugins/visualizations/public';
|
||||
import { TimeRange, Filter, esQuery, Query } from '../../../../../plugins/data/public';
|
||||
import { TimelionVisDependencies } from '../plugin';
|
||||
import { getTimezone } from './get_timezone';
|
||||
|
|
|
@ -20,15 +20,13 @@
|
|||
import { PluginInitializerContext } from 'kibana/public';
|
||||
|
||||
import { npSetup, npStart } from './legacy_imports';
|
||||
|
||||
import { setup as visualizationsSetup } from '../../visualizations/public/np_ready/public/legacy';
|
||||
import { TimelionVisSetupDependencies } from './plugin';
|
||||
import { plugin } from '.';
|
||||
|
||||
const setupPlugins: Readonly<TimelionVisSetupDependencies> = {
|
||||
expressions: npSetup.plugins.expressions,
|
||||
data: npSetup.plugins.data,
|
||||
visualizations: visualizationsSetup,
|
||||
visualizations: npSetup.plugins.visualizations,
|
||||
};
|
||||
|
||||
const pluginInstance = plugin({} as PluginInitializerContext);
|
||||
|
|
|
@ -29,7 +29,7 @@ import { Plugin as ExpressionsPlugin } from 'src/plugins/expressions/public';
|
|||
import { DataPublicPluginSetup, TimefilterContract } from 'src/plugins/data/public';
|
||||
|
||||
import { PluginsStart } from './legacy_imports';
|
||||
import { VisualizationsSetup } from '../../visualizations/public/np_ready/public';
|
||||
import { VisualizationsSetup } from '../../../../plugins/visualizations/public';
|
||||
|
||||
import { getTimelionVisualizationConfig } from './timelion_vis_fn';
|
||||
import { getTimelionVisDefinition } from './timelion_vis_type';
|
||||
|
|
|
@ -19,14 +19,12 @@
|
|||
|
||||
import { PluginInitializerContext } from 'kibana/public';
|
||||
import { npSetup, npStart } from 'ui/new_platform';
|
||||
|
||||
import { setup as visualizationsSetup } from '../../visualizations/public/np_ready/public/legacy';
|
||||
import { MetricsPluginSetupDependencies } from './plugin';
|
||||
import { plugin } from '.';
|
||||
|
||||
const plugins: Readonly<MetricsPluginSetupDependencies> = {
|
||||
expressions: npSetup.plugins.expressions,
|
||||
visualizations: visualizationsSetup,
|
||||
visualizations: npSetup.plugins.visualizations,
|
||||
};
|
||||
|
||||
const pluginInstance = plugin({} as PluginInitializerContext);
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from 'kibana/public';
|
||||
import { Plugin as ExpressionsPublicPlugin } from '../../../../plugins/expressions/public';
|
||||
import { VisualizationsSetup } from '../../visualizations/public';
|
||||
import { VisualizationsSetup } from '../../../../plugins/visualizations/public';
|
||||
|
||||
import { createMetricsFn } from './metrics_fn';
|
||||
import { metricsVisDefinition } from './metrics_type';
|
||||
|
|
|
@ -39,15 +39,15 @@ import vegaMapImage256 from './vega_map_image_256.png';
|
|||
import { VegaParser } from '../data_model/vega_parser';
|
||||
import { SearchCache } from '../data_model/search_cache';
|
||||
|
||||
import {
|
||||
setup as visualizationsSetup,
|
||||
start as visualizationsStart,
|
||||
} from '../../../visualizations/public/np_ready/public/legacy';
|
||||
import { createVegaTypeDefinition } from '../vega_type';
|
||||
// TODO This is an integration test and thus requires a running platform. When moving to the new platform,
|
||||
// this test has to be migrated to the newly created integration test environment.
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { npStart } from 'ui/new_platform';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { BaseVisType } from '../../../../../plugins/visualizations/public/vis_types/base_vis_type';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { ExprVis } from '../../../../../plugins/visualizations/public/expressions/vis';
|
||||
import { setInjectedVars } from '../services';
|
||||
|
||||
const THRESHOLD = 0.1;
|
||||
|
@ -59,7 +59,7 @@ describe('VegaVisualizations', () => {
|
|||
let vis;
|
||||
let imageComparator;
|
||||
let vegaVisualizationDependencies;
|
||||
let visRegComplete = false;
|
||||
let vegaVisType;
|
||||
|
||||
setInjectedVars({
|
||||
emsTileLayerId: {},
|
||||
|
@ -89,13 +89,7 @@ describe('VegaVisualizations', () => {
|
|||
},
|
||||
};
|
||||
|
||||
if (!visRegComplete) {
|
||||
visRegComplete = true;
|
||||
visualizationsSetup.createBaseVisualization(
|
||||
createVegaTypeDefinition(vegaVisualizationDependencies)
|
||||
);
|
||||
}
|
||||
|
||||
vegaVisType = new BaseVisType(createVegaTypeDefinition(vegaVisualizationDependencies));
|
||||
VegaVisualization = createVegaVisualization(vegaVisualizationDependencies);
|
||||
})
|
||||
);
|
||||
|
@ -105,7 +99,9 @@ describe('VegaVisualizations', () => {
|
|||
setupDOM('512px', '512px');
|
||||
imageComparator = new ImageComparator();
|
||||
|
||||
vis = visualizationsStart.createVis('vega', { type: 'vega' });
|
||||
vis = new ExprVis({
|
||||
type: vegaVisType,
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
|
|
|
@ -19,15 +19,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 { VegaPluginSetupDependencies, VegaPluginStartDependencies } from './plugin';
|
||||
import { LegacyDependenciesPlugin } from './shim';
|
||||
import { plugin } from '.';
|
||||
|
||||
const setupPlugins: Readonly<VegaPluginSetupDependencies> = {
|
||||
...npSetup.plugins,
|
||||
visualizations: visualizationsSetup,
|
||||
visualizations: npSetup.plugins.visualizations,
|
||||
|
||||
// Temporary solution
|
||||
// It will be removed when all dependent services are migrated to the new platform.
|
||||
|
|
|
@ -20,7 +20,7 @@ import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from '../../..
|
|||
import { LegacyDependenciesPlugin, LegacyDependenciesPluginSetup } from './shim';
|
||||
import { Plugin as ExpressionsPublicPlugin } from '../../../../plugins/expressions/public';
|
||||
import { Plugin as DataPublicPlugin } from '../../../../plugins/data/public';
|
||||
import { VisualizationsSetup } from '../../visualizations/public';
|
||||
import { VisualizationsSetup } from '../../../../plugins/visualizations/public';
|
||||
import {
|
||||
setNotifications,
|
||||
setData,
|
||||
|
|
|
@ -25,7 +25,7 @@ import { LegacyPluginApi, LegacyPluginInitializer } from '../../types';
|
|||
const visTypeVislibPluginInitializer: LegacyPluginInitializer = ({ Plugin }: LegacyPluginApi) =>
|
||||
new Plugin({
|
||||
id: 'vis_type_vislib',
|
||||
require: ['kibana', 'elasticsearch', 'visualizations', 'interpreter'],
|
||||
require: ['kibana', 'elasticsearch', 'interpreter'],
|
||||
publicDir: resolve(__dirname, 'public'),
|
||||
styleSheetPaths: resolve(__dirname, 'public/index.scss'),
|
||||
uiExports: {
|
||||
|
|
|
@ -22,7 +22,7 @@ import React, { useMemo, useCallback } from 'react';
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import { EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@elastic/eui';
|
||||
|
||||
import { Vis } from 'src/legacy/core_plugins/visualizations/public';
|
||||
import { Vis } from '../../../../../../../plugins/visualizations/public';
|
||||
import { SeriesParam, ValueAxis } from '../../../types';
|
||||
import { ChartTypes } from '../../../utils/collections';
|
||||
import { SelectOption } from '../../common';
|
||||
|
|
|
@ -22,7 +22,7 @@ import React, { useCallback } from 'react';
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import { EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@elastic/eui';
|
||||
|
||||
import { Vis } from 'src/legacy/core_plugins/visualizations/public';
|
||||
import { Vis } from '../../../../../../../plugins/visualizations/public';
|
||||
import { SeriesParam } from '../../../types';
|
||||
import { NumberInputOption, SelectOption, SwitchOption } from '../../common';
|
||||
import { SetChart } from './chart_options';
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { Vis } from 'src/legacy/core_plugins/visualizations/public';
|
||||
import { Vis } from '../../../../../../../plugins/visualizations/public';
|
||||
import { Axis, ValueAxis, SeriesParam, Style } from '../../../types';
|
||||
import {
|
||||
ChartTypes,
|
||||
|
|
|
@ -23,7 +23,7 @@ import { EuiPanel, EuiTitle, EuiSpacer, EuiAccordion } from '@elastic/eui';
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
|
||||
import { Vis } from 'src/legacy/core_plugins/visualizations/public';
|
||||
import { Vis } from '../../../../../../../plugins/visualizations/public';
|
||||
import { ValueAxis, SeriesParam } from '../../../types';
|
||||
import { ChartOptions } from './chart_options';
|
||||
import { SetParamByIndex, ChangeValueAxis } from './';
|
||||
|
|
|
@ -31,7 +31,7 @@ import {
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
|
||||
import { Vis } from 'src/legacy/core_plugins/visualizations/public';
|
||||
import { Vis } from '../../../../../../../plugins/visualizations/public';
|
||||
import { SeriesParam, ValueAxis } from '../../../types';
|
||||
import { ValueAxisOptions } from './value_axis_options';
|
||||
import { SetParamByIndex } from './';
|
||||
|
|
|
@ -21,7 +21,7 @@ import React, { useCallback, useMemo } from 'react';
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import { EuiSpacer, EuiAccordion, EuiHorizontalRule } from '@elastic/eui';
|
||||
|
||||
import { Vis } from 'src/legacy/core_plugins/visualizations/public';
|
||||
import { Vis } from '../../../../../../../plugins/visualizations/public';
|
||||
import { ValueAxis } from '../../../types';
|
||||
import { Positions } from '../../../utils/collections';
|
||||
import { SelectOption, SwitchOption, TextInputOption } from '../../common';
|
||||
|
|
|
@ -25,11 +25,10 @@ import {
|
|||
VisTypeVislibPluginSetupDependencies,
|
||||
VisTypeVislibPluginStartDependencies,
|
||||
} from './plugin';
|
||||
import { setup as visualizationsSetup } from '../../visualizations/public/np_ready/public/legacy';
|
||||
|
||||
const setupPlugins: Readonly<VisTypeVislibPluginSetupDependencies> = {
|
||||
expressions: npSetup.plugins.expressions,
|
||||
visualizations: visualizationsSetup,
|
||||
visualizations: npSetup.plugins.visualizations,
|
||||
charts: npSetup.plugins.charts,
|
||||
};
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
import { search } from '../../../../plugins/data/public';
|
||||
export const { tabifyAggResponse, tabifyGetColumns } = search;
|
||||
|
||||
// @ts-ignore
|
||||
export { buildHierarchicalData } from 'ui/agg_response/hierarchical/build_hierarchical_data';
|
||||
// @ts-ignore
|
||||
|
|
|
@ -25,7 +25,7 @@ import {
|
|||
} from 'kibana/public';
|
||||
|
||||
import { Plugin as ExpressionsPublicPlugin } from '../../../../plugins/expressions/public';
|
||||
import { VisualizationsSetup } from '../../visualizations/public';
|
||||
import { VisualizationsSetup } from '../../../../plugins/visualizations/public';
|
||||
import { createVisTypeVislibVisFn } from './vis_type_vislib_vis_fn';
|
||||
import { createPieVisFn } from './pie_fn';
|
||||
import {
|
||||
|
|
|
@ -26,8 +26,7 @@ import { Positions } from './utils/collections';
|
|||
import { VisTypeVislibDependencies } from './plugin';
|
||||
import { mountReactNode } from '../../../../core/public/utils';
|
||||
import { VisLegend, CUSTOM_LEGEND_VIS_TYPES } from './vislib/components/legend';
|
||||
import { VisParams } from '../../visualizations/public';
|
||||
import { ExprVis } from '../../visualizations/public/np_ready/public/expressions/vis';
|
||||
import { VisParams, ExprVis } from '../../../../plugins/visualizations/public';
|
||||
|
||||
const legendClassName = {
|
||||
top: 'visLib--legend-top',
|
||||
|
|
|
@ -22,91 +22,8 @@ import _ from 'lodash';
|
|||
import $ from 'jquery';
|
||||
import expect from '@kbn/expect';
|
||||
|
||||
import { threeTermBuckets } from 'fixtures/fake_hierarchical_data';
|
||||
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||
|
||||
import { start as visualizationsStart } from '../../../../../visualizations/public/np_ready/public/legacy';
|
||||
import { getVis, getMockUiState } from '../lib/fixtures/_vis_fixture';
|
||||
import { tabifyAggResponse } from '../../../legacy_imports';
|
||||
import { vislibSlicesResponseHandler } from '../../response_handler';
|
||||
|
||||
const rowAgg = [
|
||||
{ type: 'avg', schema: 'metric', params: { field: 'bytes' } },
|
||||
{ type: 'terms', schema: 'split', params: { field: 'extension', rows: true } },
|
||||
{ type: 'terms', schema: 'segment', params: { field: 'machine.os' } },
|
||||
{ type: 'terms', schema: 'segment', params: { field: 'geo.src' } },
|
||||
];
|
||||
|
||||
const rowAggDimensions = {
|
||||
splitRow: [
|
||||
{
|
||||
accessor: 0,
|
||||
},
|
||||
],
|
||||
buckets: [
|
||||
{
|
||||
accessor: 2,
|
||||
},
|
||||
{
|
||||
accessor: 4,
|
||||
},
|
||||
],
|
||||
metric: {
|
||||
accessor: 5,
|
||||
},
|
||||
};
|
||||
|
||||
const colAgg = [
|
||||
{ type: 'avg', schema: 'metric', params: { field: 'bytes' } },
|
||||
{ type: 'terms', schema: 'split', params: { field: 'extension', row: false } },
|
||||
{ type: 'terms', schema: 'segment', params: { field: 'machine.os' } },
|
||||
{ type: 'terms', schema: 'segment', params: { field: 'geo.src' } },
|
||||
];
|
||||
|
||||
const colAggDimensions = {
|
||||
splitColumn: [
|
||||
{
|
||||
accessor: 0,
|
||||
},
|
||||
],
|
||||
buckets: [
|
||||
{
|
||||
accessor: 2,
|
||||
},
|
||||
{
|
||||
accessor: 4,
|
||||
},
|
||||
],
|
||||
metric: {
|
||||
accessor: 5,
|
||||
},
|
||||
};
|
||||
|
||||
const sliceAgg = [
|
||||
{ type: 'avg', schema: 'metric', params: { field: 'bytes' } },
|
||||
{ type: 'terms', schema: 'segment', params: { field: 'machine.os' } },
|
||||
{ type: 'terms', schema: 'segment', params: { field: 'geo.src' } },
|
||||
];
|
||||
|
||||
const sliceAggDimensions = {
|
||||
buckets: [
|
||||
{
|
||||
accessor: 0,
|
||||
},
|
||||
{
|
||||
accessor: 2,
|
||||
},
|
||||
],
|
||||
metric: {
|
||||
accessor: 3,
|
||||
},
|
||||
};
|
||||
|
||||
const aggArray = [
|
||||
[rowAgg, rowAggDimensions],
|
||||
[colAgg, colAggDimensions],
|
||||
[sliceAgg, sliceAggDimensions],
|
||||
];
|
||||
import { pieChartMockData } from './pie_chart_mock_data';
|
||||
|
||||
const names = ['rows', 'columns', 'slices'];
|
||||
|
||||
|
@ -121,47 +38,14 @@ describe('No global chart settings', function() {
|
|||
};
|
||||
let chart1;
|
||||
let mockUiState;
|
||||
let indexPattern;
|
||||
let responseHandler;
|
||||
let data1;
|
||||
let stubVis1;
|
||||
|
||||
beforeEach(() => {
|
||||
chart1 = getVis(visLibParams1);
|
||||
mockUiState = getMockUiState();
|
||||
indexPattern = new FixturesStubbedLogstashIndexPatternProvider();
|
||||
responseHandler = vislibSlicesResponseHandler;
|
||||
|
||||
let id1 = 1;
|
||||
stubVis1 = visualizationsStart.createVis('pie', {
|
||||
type: 'pie',
|
||||
data: {
|
||||
aggs: rowAgg,
|
||||
searchSource: {
|
||||
getField: name => {
|
||||
if (name === 'index') {
|
||||
return indexPattern;
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
stubVis1.isHierarchical = () => true;
|
||||
|
||||
// We need to set the aggs to a known value.
|
||||
_.each(stubVis1.data.aggs.aggs, function(agg) {
|
||||
agg.id = 'agg_' + id1++;
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
const table1 = tabifyAggResponse(stubVis1.data.aggs, threeTermBuckets, {
|
||||
metricsAtAllLevels: true,
|
||||
});
|
||||
data1 = await responseHandler(table1, rowAggDimensions);
|
||||
|
||||
chart1.render(data1, mockUiState);
|
||||
chart1.render(pieChartMockData.rowData, mockUiState);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
|
@ -209,55 +93,21 @@ describe('No global chart settings', function() {
|
|||
});
|
||||
|
||||
describe('Vislib PieChart Class Test Suite', function() {
|
||||
aggArray.forEach(function(aggItem, i) {
|
||||
const [dataAgg, dataDimensions] = aggItem;
|
||||
['rowData', 'columnData', 'sliceData'].forEach(function(aggItem, i) {
|
||||
describe('Vislib PieChart Class Test Suite for ' + names[i] + ' data', function() {
|
||||
const mockPieData = pieChartMockData[aggItem];
|
||||
|
||||
const visLibParams = {
|
||||
type: 'pie',
|
||||
addLegend: true,
|
||||
addTooltip: true,
|
||||
};
|
||||
let vis;
|
||||
let mockUiState;
|
||||
let indexPattern;
|
||||
let data;
|
||||
let stubVis;
|
||||
let responseHandler;
|
||||
|
||||
beforeEach(() => {
|
||||
vis = getVis(visLibParams);
|
||||
mockUiState = getMockUiState();
|
||||
indexPattern = new FixturesStubbedLogstashIndexPatternProvider();
|
||||
responseHandler = vislibSlicesResponseHandler;
|
||||
|
||||
let id = 1;
|
||||
stubVis = visualizationsStart.createVis('pie', {
|
||||
type: 'pie',
|
||||
data: {
|
||||
aggs: dataAgg,
|
||||
searchSource: {
|
||||
getField: name => {
|
||||
if (name === 'index') {
|
||||
return indexPattern;
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// We need to set the aggs to a known value.
|
||||
_.each(stubVis.data.aggs.aggs, function(agg) {
|
||||
agg.id = 'agg_' + id++;
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
const table = tabifyAggResponse(stubVis.data.aggs, threeTermBuckets, {
|
||||
metricsAtAllLevels: true,
|
||||
});
|
||||
data = await responseHandler(table, dataDimensions);
|
||||
|
||||
vis.render(data, mockUiState);
|
||||
vis = getVis(visLibParams);
|
||||
const mockUiState = getMockUiState();
|
||||
vis.render(mockPieData, mockUiState);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -22,20 +22,16 @@ import { PluginInitializerContext } from 'kibana/public';
|
|||
|
||||
import { plugin } from '.';
|
||||
import { VisTypeXyPluginSetupDependencies, VisTypeXyPluginStartDependencies } from './plugin';
|
||||
import {
|
||||
setup as visualizationsSetup,
|
||||
start as visualizationsStart,
|
||||
} from '../../visualizations/public/np_ready/public/legacy';
|
||||
|
||||
const setupPlugins: Readonly<VisTypeXyPluginSetupDependencies> = {
|
||||
expressions: npSetup.plugins.expressions,
|
||||
visualizations: visualizationsSetup,
|
||||
visualizations: npSetup.plugins.visualizations,
|
||||
charts: npSetup.plugins.charts,
|
||||
};
|
||||
|
||||
const startPlugins: Readonly<VisTypeXyPluginStartDependencies> = {
|
||||
expressions: npStart.plugins.expressions,
|
||||
visualizations: visualizationsStart,
|
||||
visualizations: npStart.plugins.visualizations,
|
||||
};
|
||||
|
||||
const pluginInstance = plugin({} as PluginInitializerContext);
|
||||
|
|
|
@ -26,7 +26,10 @@ import {
|
|||
} from 'kibana/public';
|
||||
|
||||
import { Plugin as ExpressionsPublicPlugin } from '../../../../plugins/expressions/public';
|
||||
import { VisualizationsSetup, VisualizationsStart } from '../../visualizations/public';
|
||||
import {
|
||||
VisualizationsSetup,
|
||||
VisualizationsStart,
|
||||
} from '../../../../plugins/visualizations/public';
|
||||
import { ChartsPluginSetup } from '../../../../plugins/charts/public';
|
||||
|
||||
export interface VisTypeXyDependencies {
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { resolve } from 'path';
|
||||
import { LegacyPluginInitializer } from '../../../../src/legacy/types';
|
||||
|
||||
export const visualizations: LegacyPluginInitializer = kibana =>
|
||||
new kibana.Plugin({
|
||||
id: 'visualizations',
|
||||
publicDir: resolve(__dirname, 'public'),
|
||||
require: [],
|
||||
uiExports: {
|
||||
styleSheetPaths: resolve(__dirname, 'public/index.scss'),
|
||||
},
|
||||
});
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default visualizations;
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
"name": "visualizations",
|
||||
"version": "kibana"
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
@import 'src/legacy/ui/public/styles/styling_constants';
|
||||
@import './np_ready/public/index';
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"id": "visualizations",
|
||||
"version": "kibana",
|
||||
"server": false,
|
||||
"ui": true,
|
||||
"requiredPlugins": ["data", "expressions", "uiActions", "embeddable", "usageCollection"]
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Visualizations Plugin - public
|
||||
*
|
||||
* This is the entry point for the entire client-side public contract of the plugin.
|
||||
* If something is not explicitly exported here, you can safely assume it is private
|
||||
* to the plugin and not considered stable.
|
||||
*
|
||||
* All stateful contracts will be injected by the platform at runtime, and are defined
|
||||
* in the setup/start interfaces in `plugin.ts`. The remaining items exported here are
|
||||
* either types, or static code.
|
||||
*/
|
||||
|
||||
import { PublicContract } from '@kbn/utility-types';
|
||||
import { PluginInitializerContext } from '../../../../../../core/public';
|
||||
import { VisualizationsPlugin, VisualizationsSetup, VisualizationsStart } from './plugin';
|
||||
|
||||
/** @public */
|
||||
export { VisualizationsSetup, VisualizationsStart };
|
||||
|
||||
/** @public types */
|
||||
export { VisTypeAlias, VisType } from './vis_types';
|
||||
export { VisSavedObject } from './types';
|
||||
export { Vis, VisParams, SerializedVis, SerializedVisData, VisData } from './vis';
|
||||
import { VisualizeEmbeddableFactory, VisualizeEmbeddable } from './embeddable';
|
||||
export type VisualizeEmbeddableFactoryContract = PublicContract<VisualizeEmbeddableFactory>;
|
||||
export type VisualizeEmbeddableContract = PublicContract<VisualizeEmbeddable>;
|
||||
export { TypesService } from './vis_types/types_service';
|
||||
export { VISUALIZE_EMBEDDABLE_TYPE, VisualizeInput } from './embeddable';
|
||||
export { SchemaConfig } from './legacy/build_pipeline';
|
||||
|
||||
export function plugin(initializerContext: PluginInitializerContext) {
|
||||
return new VisualizationsPlugin(initializerContext);
|
||||
}
|
|
@ -1,107 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import _ from 'lodash';
|
||||
import ngMock from 'ng_mock';
|
||||
import expect from '@kbn/expect';
|
||||
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||
import { start as visualizations } from '../../legacy';
|
||||
|
||||
describe('Vis Class', function() {
|
||||
let indexPattern;
|
||||
let visTypes;
|
||||
|
||||
let vis;
|
||||
const stateFixture = {
|
||||
type: 'pie',
|
||||
aggs: [
|
||||
{ type: 'avg', schema: 'metric', params: { field: 'bytes' } },
|
||||
{ type: 'terms', schema: 'segment', params: { field: 'machine.os' } },
|
||||
{ type: 'terms', schema: 'segment', params: { field: 'geo.src' } },
|
||||
],
|
||||
params: { isDonut: true },
|
||||
listeners: { click: _.noop },
|
||||
};
|
||||
|
||||
beforeEach(ngMock.module('kibana'));
|
||||
beforeEach(
|
||||
ngMock.inject(function(Private) {
|
||||
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
||||
visTypes = visualizations;
|
||||
})
|
||||
);
|
||||
|
||||
beforeEach(function() {
|
||||
vis = visualizations.createVis(indexPattern, stateFixture);
|
||||
});
|
||||
|
||||
const verifyVis = function(vis) {
|
||||
expect(vis).to.have.property('aggs');
|
||||
expect(vis.aggs.aggs).to.have.length(3);
|
||||
|
||||
expect(vis).to.have.property('type');
|
||||
expect(vis.type).to.eql(visTypes.get('pie'));
|
||||
|
||||
expect(vis).to.have.property('params');
|
||||
expect(vis.params).to.have.property('isDonut', true);
|
||||
expect(vis).to.have.property('indexPattern', indexPattern);
|
||||
};
|
||||
|
||||
describe('initialization', function() {
|
||||
it('should set the state', function() {
|
||||
verifyVis(vis);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getState()', function() {
|
||||
it('should get a state that represents the... er... state', function() {
|
||||
const state = vis.getEnabledState();
|
||||
expect(state).to.have.property('type', 'pie');
|
||||
|
||||
expect(state).to.have.property('params');
|
||||
expect(state.params).to.have.property('isDonut', true);
|
||||
|
||||
expect(state).to.have.property('aggs');
|
||||
expect(state.aggs).to.have.length(3);
|
||||
});
|
||||
});
|
||||
|
||||
describe('setState()', function() {
|
||||
it('should set the state to defaults', function() {
|
||||
const vis = visualizations.createVis(indexPattern);
|
||||
expect(vis).to.have.property('type');
|
||||
expect(vis.type).to.eql(visTypes.get('histogram'));
|
||||
expect(vis).to.have.property('aggs');
|
||||
expect(vis.aggs.aggs).to.have.length(1);
|
||||
expect(vis).to.have.property('params');
|
||||
expect(vis.params).to.have.property('addLegend', true);
|
||||
expect(vis.params).to.have.property('addTooltip', true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isHierarchical()', function() {
|
||||
it('should return true for hierarchical vis (like pie)', function() {
|
||||
expect(vis.isHierarchical()).to.be(true);
|
||||
});
|
||||
it('should return false for non-hierarchical vis (like histogram)', function() {
|
||||
const vis = visualizations.createVis(indexPattern);
|
||||
expect(vis.isHierarchical()).to.be(false);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import expect from '@kbn/expect';
|
||||
import ngMock from 'ng_mock';
|
||||
import { BaseVisType } from '../../../vis_types/base_vis_type';
|
||||
|
||||
describe('Base Vis Type', function() {
|
||||
beforeEach(ngMock.module('kibana'));
|
||||
|
||||
describe('initialization', () => {
|
||||
it('should throw if mandatory properties are missing', () => {
|
||||
expect(() => {
|
||||
new BaseVisType({});
|
||||
}).to.throwError('vis_type must define its name');
|
||||
|
||||
expect(() => {
|
||||
new BaseVisType({ name: 'test' });
|
||||
}).to.throwError('vis_type must define its title');
|
||||
|
||||
expect(() => {
|
||||
new BaseVisType({ name: 'test', title: 'test' });
|
||||
}).to.throwError('vis_type must define its description');
|
||||
|
||||
expect(() => {
|
||||
new BaseVisType({ name: 'test', title: 'test', description: 'test' });
|
||||
}).to.throwError('vis_type must define its icon or image');
|
||||
|
||||
expect(() => {
|
||||
new BaseVisType({ name: 'test', title: 'test', description: 'test', icon: 'test' });
|
||||
}).to.throwError('vis_type must define visualization controller');
|
||||
|
||||
expect(() => {
|
||||
new BaseVisType({
|
||||
name: 'test',
|
||||
title: 'test',
|
||||
description: 'test',
|
||||
icon: 'test',
|
||||
visualization: {},
|
||||
});
|
||||
}).to.not.throwError();
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,75 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { PluginInitializerContext } from '../../../../../../core/public';
|
||||
import { VisualizationsSetup, VisualizationsStart } from './';
|
||||
import { VisualizationsPlugin } from './plugin';
|
||||
import { coreMock } from '../../../../../../core/public/mocks';
|
||||
import { embeddablePluginMock } from '../../../../../../plugins/embeddable/public/mocks';
|
||||
import { expressionsPluginMock } from '../../../../../../plugins/expressions/public/mocks';
|
||||
import { dataPluginMock } from '../../../../../../plugins/data/public/mocks';
|
||||
import { usageCollectionPluginMock } from '../../../../../../plugins/usage_collection/public/mocks';
|
||||
import { uiActionsPluginMock } from '../../../../../../plugins/ui_actions/public/mocks';
|
||||
|
||||
const createSetupContract = (): VisualizationsSetup => ({
|
||||
createBaseVisualization: jest.fn(),
|
||||
createReactVisualization: jest.fn(),
|
||||
registerAlias: jest.fn(),
|
||||
hideTypes: jest.fn(),
|
||||
});
|
||||
|
||||
const createStartContract = (): VisualizationsStart => ({
|
||||
get: jest.fn(),
|
||||
all: jest.fn(),
|
||||
getAliases: jest.fn(),
|
||||
savedVisualizationsLoader: {} as any,
|
||||
showNewVisModal: jest.fn(),
|
||||
createVis: jest.fn(),
|
||||
convertFromSerializedVis: jest.fn(),
|
||||
convertToSerializedVis: jest.fn(),
|
||||
});
|
||||
|
||||
const createInstance = async () => {
|
||||
const plugin = new VisualizationsPlugin({} as PluginInitializerContext);
|
||||
|
||||
const setup = plugin.setup(coreMock.createSetup(), {
|
||||
data: dataPluginMock.createSetupContract(),
|
||||
expressions: expressionsPluginMock.createSetupContract(),
|
||||
embeddable: embeddablePluginMock.createSetupContract(),
|
||||
usageCollection: usageCollectionPluginMock.createSetupContract(),
|
||||
});
|
||||
const doStart = () =>
|
||||
plugin.start(coreMock.createStart(), {
|
||||
data: dataPluginMock.createStartContract(),
|
||||
expressions: expressionsPluginMock.createStartContract(),
|
||||
uiActions: uiActionsPluginMock.createStartContract(),
|
||||
});
|
||||
|
||||
return {
|
||||
plugin,
|
||||
setup,
|
||||
doStart,
|
||||
};
|
||||
};
|
||||
|
||||
export const visualizationsPluginMock = {
|
||||
createSetupContract,
|
||||
createStartContract,
|
||||
createInstance,
|
||||
};
|
|
@ -1,176 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import {
|
||||
PluginInitializerContext,
|
||||
CoreSetup,
|
||||
CoreStart,
|
||||
Plugin,
|
||||
} from '../../../../../../core/public';
|
||||
import { TypesService, TypesSetup, TypesStart } from './vis_types';
|
||||
import {
|
||||
setUISettings,
|
||||
setTypes,
|
||||
setI18n,
|
||||
setCapabilities,
|
||||
setHttp,
|
||||
setIndexPatterns,
|
||||
setSavedObjects,
|
||||
setUsageCollector,
|
||||
setFilterManager,
|
||||
setExpressions,
|
||||
setUiActions,
|
||||
setSavedVisualizationsLoader,
|
||||
setTimeFilter,
|
||||
setAggs,
|
||||
setChrome,
|
||||
setOverlays,
|
||||
} from './services';
|
||||
import { VISUALIZE_EMBEDDABLE_TYPE, VisualizeEmbeddableFactory } from './embeddable';
|
||||
import { ExpressionsSetup, ExpressionsStart } from '../../../../../../plugins/expressions/public';
|
||||
import { EmbeddableSetup } from '../../../../../../plugins/embeddable/public';
|
||||
import { visualization as visualizationFunction } from './expressions/visualization_function';
|
||||
import { visualization as visualizationRenderer } from './expressions/visualization_renderer';
|
||||
import {
|
||||
DataPublicPluginSetup,
|
||||
DataPublicPluginStart,
|
||||
} from '../../../../../../plugins/data/public';
|
||||
import { UsageCollectionSetup } from '../../../../../../plugins/usage_collection/public';
|
||||
import { createSavedVisLoader, SavedVisualizationsLoader } from './saved_visualizations';
|
||||
import { SerializedVis, Vis } from './vis';
|
||||
import { showNewVisModal } from './wizard';
|
||||
import { UiActionsStart } from '../../../../../../plugins/ui_actions/public';
|
||||
import {
|
||||
convertFromSerializedVis,
|
||||
convertToSerializedVis,
|
||||
} from './saved_visualizations/_saved_vis';
|
||||
|
||||
/**
|
||||
* Interface for this plugin's returned setup/start contracts.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
|
||||
export type VisualizationsSetup = TypesSetup;
|
||||
|
||||
export interface VisualizationsStart extends TypesStart {
|
||||
savedVisualizationsLoader: SavedVisualizationsLoader;
|
||||
createVis: (visType: string, visState?: SerializedVis) => Vis;
|
||||
convertToSerializedVis: typeof convertToSerializedVis;
|
||||
convertFromSerializedVis: typeof convertFromSerializedVis;
|
||||
showNewVisModal: typeof showNewVisModal;
|
||||
}
|
||||
|
||||
export interface VisualizationsSetupDeps {
|
||||
expressions: ExpressionsSetup;
|
||||
embeddable: EmbeddableSetup;
|
||||
usageCollection: UsageCollectionSetup;
|
||||
data: DataPublicPluginSetup;
|
||||
}
|
||||
|
||||
export interface VisualizationsStartDeps {
|
||||
data: DataPublicPluginStart;
|
||||
expressions: ExpressionsStart;
|
||||
uiActions: UiActionsStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Visualizations Plugin - public
|
||||
*
|
||||
* This plugin's stateful contracts are returned from the `setup` and `start` methods
|
||||
* below. The interfaces for these contracts are provided above.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export class VisualizationsPlugin
|
||||
implements
|
||||
Plugin<
|
||||
VisualizationsSetup,
|
||||
VisualizationsStart,
|
||||
VisualizationsSetupDeps,
|
||||
VisualizationsStartDeps
|
||||
> {
|
||||
private readonly types: TypesService = new TypesService();
|
||||
|
||||
constructor(initializerContext: PluginInitializerContext) {}
|
||||
|
||||
public setup(
|
||||
core: CoreSetup,
|
||||
{ expressions, embeddable, usageCollection, data }: VisualizationsSetupDeps
|
||||
): VisualizationsSetup {
|
||||
setUISettings(core.uiSettings);
|
||||
setUsageCollector(usageCollection);
|
||||
|
||||
expressions.registerFunction(visualizationFunction);
|
||||
expressions.registerRenderer(visualizationRenderer);
|
||||
|
||||
const embeddableFactory = new VisualizeEmbeddableFactory();
|
||||
embeddable.registerEmbeddableFactory(VISUALIZE_EMBEDDABLE_TYPE, embeddableFactory);
|
||||
|
||||
return {
|
||||
...this.types.setup(),
|
||||
};
|
||||
}
|
||||
|
||||
public start(
|
||||
core: CoreStart,
|
||||
{ data, expressions, uiActions }: VisualizationsStartDeps
|
||||
): VisualizationsStart {
|
||||
const types = this.types.start();
|
||||
setI18n(core.i18n);
|
||||
setTypes(types);
|
||||
setCapabilities(core.application.capabilities);
|
||||
setHttp(core.http);
|
||||
setSavedObjects(core.savedObjects);
|
||||
setIndexPatterns(data.indexPatterns);
|
||||
setFilterManager(data.query.filterManager);
|
||||
setExpressions(expressions);
|
||||
setUiActions(uiActions);
|
||||
setTimeFilter(data.query.timefilter.timefilter);
|
||||
setAggs(data.search.aggs);
|
||||
setOverlays(core.overlays);
|
||||
setChrome(core.chrome);
|
||||
const savedVisualizationsLoader = createSavedVisLoader({
|
||||
savedObjectsClient: core.savedObjects.client,
|
||||
indexPatterns: data.indexPatterns,
|
||||
chrome: core.chrome,
|
||||
overlays: core.overlays,
|
||||
visualizationTypes: types,
|
||||
});
|
||||
setSavedVisualizationsLoader(savedVisualizationsLoader);
|
||||
|
||||
return {
|
||||
...types,
|
||||
showNewVisModal,
|
||||
/**
|
||||
* creates new instance of Vis
|
||||
* @param {IIndexPattern} indexPattern - index pattern to use
|
||||
* @param {VisState} visState - visualization configuration
|
||||
*/
|
||||
createVis: (visType: string, visState?: SerializedVis) => new Vis(visType, visState),
|
||||
convertToSerializedVis,
|
||||
convertFromSerializedVis,
|
||||
savedVisualizationsLoader,
|
||||
};
|
||||
}
|
||||
|
||||
public stop() {
|
||||
this.types.stop();
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { SavedObject } from '../../../../../../plugins/saved_objects/public';
|
||||
import { ISearchSource, AggConfigOptions } from '../../../../../../plugins/data/public';
|
||||
import { SerializedVis, Vis, VisParams } from './vis';
|
||||
|
||||
export { Vis, SerializedVis, VisParams };
|
||||
|
||||
export interface VisualizationController {
|
||||
render(visData: any, visParams: any): Promise<void>;
|
||||
destroy(): void;
|
||||
isLoaded?(): Promise<void> | void;
|
||||
}
|
||||
|
||||
export interface SavedVisState {
|
||||
type: string;
|
||||
params: VisParams;
|
||||
aggs: AggConfigOptions[];
|
||||
}
|
||||
|
||||
export interface ISavedVis {
|
||||
id: string;
|
||||
title: string;
|
||||
description?: string;
|
||||
visState: SavedVisState;
|
||||
searchSource?: ISearchSource;
|
||||
uiStateJSON?: string;
|
||||
savedSearchRefName?: string;
|
||||
savedSearchId?: string;
|
||||
}
|
||||
|
||||
// @ts-ignore-next-line
|
||||
export interface VisSavedObject extends SavedObject, ISavedVis {}
|
|
@ -1,80 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import _ from 'lodash';
|
||||
|
||||
export class BaseVisType {
|
||||
constructor(opts = {}) {
|
||||
if (!opts.name) {
|
||||
throw 'vis_type must define its name';
|
||||
}
|
||||
if (!opts.title) {
|
||||
throw 'vis_type must define its title';
|
||||
}
|
||||
if (!opts.description) {
|
||||
throw 'vis_type must define its description';
|
||||
}
|
||||
if (!opts.icon && !opts.image) {
|
||||
throw 'vis_type must define its icon or image';
|
||||
}
|
||||
if (!opts.visualization) {
|
||||
throw 'vis_type must define visualization controller';
|
||||
}
|
||||
|
||||
const _defaults = {
|
||||
// name, title, description, icon, image
|
||||
visualization: null, // must be a class with render/resize/destroy methods
|
||||
visConfig: {
|
||||
defaults: {}, // default configuration
|
||||
},
|
||||
requestHandler: 'courier', // select one from registry or pass a function
|
||||
responseHandler: 'none',
|
||||
editor: null, // no default is provided
|
||||
editorConfig: {
|
||||
collections: {}, // collections used for configuration (list of positions, ...)
|
||||
},
|
||||
options: {
|
||||
// controls the visualize editor
|
||||
showTimePicker: true,
|
||||
showQueryBar: true,
|
||||
showFilterBar: true,
|
||||
showIndexSelection: true,
|
||||
hierarchicalData: false, // we should get rid of this i guess ?
|
||||
},
|
||||
stage: 'production',
|
||||
feedbackMessage: '',
|
||||
hidden: false,
|
||||
};
|
||||
|
||||
_.defaultsDeep(this, opts, _defaults);
|
||||
|
||||
this.requiresSearch = this.requestHandler !== 'none';
|
||||
}
|
||||
|
||||
shouldMarkAsExperimentalInUI() {
|
||||
return this.stage === 'experimental';
|
||||
}
|
||||
|
||||
get schemas() {
|
||||
if (this.editorConfig && this.editorConfig.schemas) {
|
||||
return this.editorConfig.schemas;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
|
@ -31,6 +31,7 @@ import { kibanaLegacyPluginMock } from '../../../../../plugins/kibana_legacy/pub
|
|||
import { chartPluginMock } from '../../../../../plugins/charts/public/mocks';
|
||||
import { advancedSettingsMock } from '../../../../../plugins/advanced_settings/public/mocks';
|
||||
import { savedObjectsManagementPluginMock } from '../../../../../plugins/saved_objects_management/public/mocks';
|
||||
import { visualizationsPluginMock } from '../../../../../plugins/visualizations/public/mocks';
|
||||
/* eslint-enable @kbn/eslint/no-restricted-paths */
|
||||
|
||||
export const pluginsMock = {
|
||||
|
@ -44,6 +45,7 @@ export const pluginsMock = {
|
|||
uiActions: uiActionsPluginMock.createSetupContract(),
|
||||
usageCollection: usageCollectionPluginMock.createSetupContract(),
|
||||
advancedSettings: advancedSettingsMock.createSetupContract(),
|
||||
visualizations: visualizationsPluginMock.createSetupContract(),
|
||||
kibanaLegacy: kibanaLegacyPluginMock.createSetupContract(),
|
||||
savedObjectsManagement: savedObjectsManagementPluginMock.createSetupContract(),
|
||||
}),
|
||||
|
@ -57,6 +59,7 @@ export const pluginsMock = {
|
|||
uiActions: uiActionsPluginMock.createStartContract(),
|
||||
management: managementPluginMock.createStartContract(),
|
||||
advancedSettings: advancedSettingsMock.createStartContract(),
|
||||
visualizations: visualizationsPluginMock.createStartContract(),
|
||||
kibanaLegacy: kibanaLegacyPluginMock.createStartContract(),
|
||||
savedObjectsManagement: savedObjectsManagementPluginMock.createStartContract(),
|
||||
}),
|
||||
|
|
|
@ -20,20 +20,7 @@
|
|||
import sinon from 'sinon';
|
||||
import { getFieldFormatsRegistry } from '../../../../test_utils/public/stub_field_formats';
|
||||
import { METRIC_TYPE } from '@kbn/analytics';
|
||||
import {
|
||||
setFieldFormats,
|
||||
setIndexPatterns,
|
||||
setInjectedMetadata,
|
||||
setHttp,
|
||||
setNotifications,
|
||||
setOverlays,
|
||||
setQueryService,
|
||||
setSearchService,
|
||||
setUiSettings,
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
} from '../../../../plugins/data/public/services';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { setAggs } from '../../../../../src/legacy/core_plugins/visualizations/public/np_ready/public/services';
|
||||
import { setSetupServices, setStartServices } from './set_services';
|
||||
import {
|
||||
AggTypesRegistry,
|
||||
getAggTypes,
|
||||
|
@ -76,14 +63,37 @@ export const mockUiSettings = {
|
|||
'format:defaultTypeMap': {},
|
||||
};
|
||||
|
||||
const mockCore = {
|
||||
const mockCoreSetup = {
|
||||
chrome: {},
|
||||
uiSettings: mockUiSettings,
|
||||
http: {
|
||||
basePath: {
|
||||
get: sinon.fake.returns(''),
|
||||
},
|
||||
},
|
||||
injectedMetadata: {},
|
||||
uiSettings: mockUiSettings,
|
||||
};
|
||||
|
||||
const mockCoreStart = {
|
||||
application: {
|
||||
capabilities: {},
|
||||
},
|
||||
chrome: {
|
||||
overlays: {
|
||||
openModal: sinon.fake(),
|
||||
},
|
||||
},
|
||||
http: {
|
||||
basePath: {
|
||||
get: sinon.fake.returns(''),
|
||||
},
|
||||
},
|
||||
i18n: {},
|
||||
overlays: {},
|
||||
savedObjects: {
|
||||
client: {},
|
||||
},
|
||||
uiSettings: mockUiSettings,
|
||||
};
|
||||
|
||||
const querySetup = {
|
||||
|
@ -153,8 +163,8 @@ const mockAggTypesRegistry = () => {
|
|||
const registry = new AggTypesRegistry();
|
||||
const registrySetup = registry.setup();
|
||||
const aggTypes = getAggTypes({
|
||||
uiSettings: mockCore.uiSettings,
|
||||
notifications: mockCore.notifications,
|
||||
uiSettings: mockCoreSetup.uiSettings,
|
||||
notifications: mockCoreStart.notifications,
|
||||
query: querySetup,
|
||||
});
|
||||
aggTypes.buckets.forEach(type => registrySetup.registerBucket(type));
|
||||
|
@ -166,7 +176,7 @@ const mockAggTypesRegistry = () => {
|
|||
const aggTypesRegistry = mockAggTypesRegistry();
|
||||
|
||||
export const npSetup = {
|
||||
core: mockCore,
|
||||
core: mockCoreSetup,
|
||||
plugins: {
|
||||
advancedSettings: {
|
||||
component: {
|
||||
|
@ -216,7 +226,7 @@ export const npSetup = {
|
|||
},
|
||||
},
|
||||
},
|
||||
fieldFormats: getFieldFormatsRegistry(mockCore),
|
||||
fieldFormats: getFieldFormatsRegistry(mockCoreSetup),
|
||||
},
|
||||
share: {
|
||||
register: () => {},
|
||||
|
@ -283,17 +293,17 @@ export const npSetup = {
|
|||
visTypeVega: {
|
||||
config: sinon.fake(),
|
||||
},
|
||||
visualizations: {
|
||||
createBaseVisualization: sinon.fake(),
|
||||
createReactVisualization: sinon.fake(),
|
||||
registerAlias: sinon.fake(),
|
||||
hideTypes: sinon.fake(),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const npStart = {
|
||||
core: {
|
||||
chrome: {
|
||||
overlays: {
|
||||
openModal: sinon.fake(),
|
||||
},
|
||||
},
|
||||
},
|
||||
core: mockCoreStart,
|
||||
plugins: {
|
||||
management: {
|
||||
legacy: {
|
||||
|
@ -437,7 +447,7 @@ export const npStart = {
|
|||
},
|
||||
},
|
||||
},
|
||||
fieldFormats: getFieldFormatsRegistry(mockCore),
|
||||
fieldFormats: getFieldFormatsRegistry(mockCoreStart),
|
||||
},
|
||||
share: {
|
||||
toggleShareContextMenu: () => {},
|
||||
|
@ -459,6 +469,16 @@ export const npStart = {
|
|||
getTriggerActions: sinon.fake(),
|
||||
getTriggerCompatibleActions: sinon.fake(),
|
||||
},
|
||||
visualizations: {
|
||||
get: sinon.fake(),
|
||||
all: sinon.fake(),
|
||||
getAliases: sinon.fake(),
|
||||
savedVisualizationsLoader: {},
|
||||
showNewVisModal: sinon.fake(),
|
||||
createVis: sinon.fake(),
|
||||
convertFromSerializedVis: sinon.fake(),
|
||||
convertToSerializedVis: sinon.fake(),
|
||||
},
|
||||
navigation: {
|
||||
ui: {
|
||||
TopNavMenu: mockComponent,
|
||||
|
@ -485,23 +505,15 @@ export function __setup__(coreSetup) {
|
|||
// bootstrap an LP plugin outside of tests)
|
||||
npSetup.core.application.register = () => {};
|
||||
|
||||
// Services that need to be set in the legacy platform since the legacy data plugin
|
||||
// which previously provided them has been removed.
|
||||
setInjectedMetadata(npSetup.core.injectedMetadata);
|
||||
// Services that need to be set in the legacy platform since the legacy data
|
||||
// & vis plugins which previously provided them have been removed.
|
||||
setSetupServices(npSetup);
|
||||
}
|
||||
|
||||
export function __start__(coreStart) {
|
||||
npStart.core = coreStart;
|
||||
|
||||
// Services that need to be set in the legacy platform since the legacy data plugin
|
||||
// which previously provided them has been removed.
|
||||
setHttp(npStart.core.http);
|
||||
setNotifications(npStart.core.notifications);
|
||||
setOverlays(npStart.core.overlays);
|
||||
setUiSettings(npStart.core.uiSettings);
|
||||
setFieldFormats(npStart.plugins.data.fieldFormats);
|
||||
setIndexPatterns(npStart.plugins.data.indexPatterns);
|
||||
setQueryService(npStart.plugins.data.query);
|
||||
setSearchService(npStart.plugins.data.search);
|
||||
setAggs(npStart.plugins.data.search.aggs);
|
||||
// Services that need to be set in the legacy platform since the legacy data
|
||||
// & vis plugins which previously provided them have been removed.
|
||||
setStartServices(npStart);
|
||||
}
|
||||
|
|
|
@ -20,19 +20,8 @@
|
|||
jest.mock('history');
|
||||
|
||||
import { setRootControllerMock, historyMock } from './new_platform.test.mocks';
|
||||
import {
|
||||
legacyAppRegister,
|
||||
__reset__,
|
||||
__setup__,
|
||||
__start__,
|
||||
PluginsSetup,
|
||||
PluginsStart,
|
||||
} from './new_platform';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import * as dataServices from '../../../../plugins/data/public/services';
|
||||
import { LegacyCoreSetup, LegacyCoreStart } from '../../../../core/public';
|
||||
import { legacyAppRegister, __reset__, __setup__, __start__ } from './new_platform';
|
||||
import { coreMock } from '../../../../core/public/mocks';
|
||||
import { npSetup, npStart } from './__mocks__';
|
||||
|
||||
describe('ui/new_platform', () => {
|
||||
describe('legacyAppRegister', () => {
|
||||
|
@ -119,25 +108,4 @@ describe('ui/new_platform', () => {
|
|||
expect(unmountMock).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('service getters', () => {
|
||||
const services: Record<string, Function> = dataServices;
|
||||
const getters = Object.keys(services).filter(k => k.substring(0, 3) === 'get');
|
||||
|
||||
getters.forEach(g => {
|
||||
it(`sets a value for ${g}`, () => {
|
||||
__reset__();
|
||||
__setup__(
|
||||
(coreMock.createSetup() as unknown) as LegacyCoreSetup,
|
||||
(npSetup.plugins as unknown) as PluginsSetup
|
||||
);
|
||||
__start__(
|
||||
(coreMock.createStart() as unknown) as LegacyCoreStart,
|
||||
(npStart.plugins as unknown) as PluginsStart
|
||||
);
|
||||
|
||||
expect(services[g]()).toBeDefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -23,6 +23,7 @@ import { UiActionsStart, UiActionsSetup } from 'src/plugins/ui_actions/public';
|
|||
import { EmbeddableStart, EmbeddableSetup } from 'src/plugins/embeddable/public';
|
||||
import { createBrowserHistory } from 'history';
|
||||
import { DashboardStart } from '../../../../plugins/dashboard/public';
|
||||
import { setSetupServices, setStartServices } from './set_services';
|
||||
import {
|
||||
LegacyCoreSetup,
|
||||
LegacyCoreStart,
|
||||
|
@ -31,18 +32,6 @@ import {
|
|||
ScopedHistory,
|
||||
} from '../../../../core/public';
|
||||
import { Plugin as DataPlugin } from '../../../../plugins/data/public';
|
||||
import {
|
||||
setFieldFormats,
|
||||
setIndexPatterns,
|
||||
setInjectedMetadata,
|
||||
setHttp,
|
||||
setNotifications,
|
||||
setOverlays,
|
||||
setQueryService,
|
||||
setSearchService,
|
||||
setUiSettings,
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
} from '../../../../plugins/data/public/services';
|
||||
import { Plugin as ExpressionsPlugin } from '../../../../plugins/expressions/public';
|
||||
import {
|
||||
Setup as InspectorSetup,
|
||||
|
@ -71,6 +60,10 @@ import {
|
|||
SavedObjectsManagementPluginSetup,
|
||||
SavedObjectsManagementPluginStart,
|
||||
} from '../../../../plugins/saved_objects_management/public';
|
||||
import {
|
||||
VisualizationsSetup,
|
||||
VisualizationsStart,
|
||||
} from '../../../../plugins/visualizations/public';
|
||||
|
||||
export interface PluginsSetup {
|
||||
bfetch: BfetchPublicSetup;
|
||||
|
@ -90,6 +83,7 @@ export interface PluginsSetup {
|
|||
management: ManagementSetup;
|
||||
visTypeVega: VisTypeVegaSetup;
|
||||
discover: DiscoverSetup;
|
||||
visualizations: VisualizationsSetup;
|
||||
telemetry?: TelemetryPluginSetup;
|
||||
savedObjectsManagement: SavedObjectsManagementPluginSetup;
|
||||
}
|
||||
|
@ -109,6 +103,7 @@ export interface PluginsStart {
|
|||
management: ManagementStart;
|
||||
advancedSettings: AdvancedSettingsStart;
|
||||
discover: DiscoverStart;
|
||||
visualizations: VisualizationsStart;
|
||||
telemetry?: TelemetryPluginStart;
|
||||
dashboard: DashboardStart;
|
||||
savedObjectsManagement: SavedObjectsManagementPluginStart;
|
||||
|
@ -143,25 +138,18 @@ export function __setup__(coreSetup: LegacyCoreSetup, plugins: PluginsSetup) {
|
|||
// Setup compatibility layer for AppService in legacy platform
|
||||
npSetup.core.application.register = legacyAppRegister;
|
||||
|
||||
// Services that need to be set in the legacy platform since the legacy data plugin
|
||||
// which previously provided them has been removed.
|
||||
setInjectedMetadata(npSetup.core.injectedMetadata);
|
||||
// Services that need to be set in the legacy platform since the legacy data
|
||||
// & vis plugins which previously provided them have been removed.
|
||||
setSetupServices(npSetup);
|
||||
}
|
||||
|
||||
export function __start__(coreStart: LegacyCoreStart, plugins: PluginsStart) {
|
||||
npStart.core = coreStart;
|
||||
npStart.plugins = plugins;
|
||||
|
||||
// Services that need to be set in the legacy platform since the legacy data plugin
|
||||
// which previously provided them has been removed.
|
||||
setHttp(npStart.core.http);
|
||||
setNotifications(npStart.core.notifications);
|
||||
setOverlays(npStart.core.overlays);
|
||||
setUiSettings(npStart.core.uiSettings);
|
||||
setFieldFormats(npStart.plugins.data.fieldFormats);
|
||||
setIndexPatterns(npStart.plugins.data.indexPatterns);
|
||||
setQueryService(npStart.plugins.data.query);
|
||||
setSearchService(npStart.plugins.data.search);
|
||||
// Services that need to be set in the legacy platform since the legacy data
|
||||
// & vis plugins which previously provided them have been removed.
|
||||
setStartServices(npStart);
|
||||
}
|
||||
|
||||
/** Flag used to ensure `legacyAppRegister` is only called once. */
|
||||
|
|
53
src/legacy/ui/public/new_platform/set_services.test.ts
Normal file
53
src/legacy/ui/public/new_platform/set_services.test.ts
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { __reset__, __setup__, __start__, PluginsSetup, PluginsStart } from './new_platform';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import * as dataServices from '../../../../plugins/data/public/services';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import * as visualizationsServices from '../../../../plugins/visualizations/public/services';
|
||||
import { LegacyCoreSetup, LegacyCoreStart } from '../../../../core/public';
|
||||
import { coreMock } from '../../../../core/public/mocks';
|
||||
import { npSetup, npStart } from './__mocks__';
|
||||
|
||||
describe('ui/new_platform', () => {
|
||||
describe('set service getters', () => {
|
||||
const testServiceGetters = (name: string, services: Record<string, Function>) => {
|
||||
const getters = Object.keys(services).filter(k => k.substring(0, 3) === 'get');
|
||||
getters.forEach(g => {
|
||||
it(`ui/new_platform sets a value for ${name} getter ${g}`, () => {
|
||||
__reset__();
|
||||
__setup__(
|
||||
(coreMock.createSetup() as unknown) as LegacyCoreSetup,
|
||||
(npSetup.plugins as unknown) as PluginsSetup
|
||||
);
|
||||
__start__(
|
||||
(coreMock.createStart() as unknown) as LegacyCoreStart,
|
||||
(npStart.plugins as unknown) as PluginsStart
|
||||
);
|
||||
|
||||
expect(services[g]()).toBeDefined();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
testServiceGetters('data', dataServices);
|
||||
testServiceGetters('visualizations', visualizationsServices);
|
||||
});
|
||||
});
|
83
src/legacy/ui/public/new_platform/set_services.ts
Normal file
83
src/legacy/ui/public/new_platform/set_services.ts
Normal file
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { pick } from 'lodash';
|
||||
|
||||
import { PluginsSetup, PluginsStart } from './new_platform';
|
||||
import { LegacyCoreSetup, LegacyCoreStart } from '../../../../core/public';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import * as dataServices from '../../../../plugins/data/public/services';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import * as visualizationsServices from '../../../../plugins/visualizations/public/services';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { createSavedVisLoader } from '../../../../plugins/visualizations/public/saved_visualizations/saved_visualizations';
|
||||
|
||||
interface NpSetup {
|
||||
core: LegacyCoreSetup;
|
||||
plugins: PluginsSetup;
|
||||
}
|
||||
|
||||
interface NpStart {
|
||||
core: LegacyCoreStart;
|
||||
plugins: PluginsStart;
|
||||
}
|
||||
|
||||
export function setSetupServices(npSetup: NpSetup) {
|
||||
// Services that need to be set in the legacy platform since the legacy data plugin
|
||||
// which previously provided them has been removed.
|
||||
dataServices.setInjectedMetadata(npSetup.core.injectedMetadata);
|
||||
visualizationsServices.setUISettings(npSetup.core.uiSettings);
|
||||
visualizationsServices.setUsageCollector(npSetup.plugins.usageCollection);
|
||||
}
|
||||
|
||||
export function setStartServices(npStart: NpStart) {
|
||||
// Services that need to be set in the legacy platform since the legacy data plugin
|
||||
// which previously provided them has been removed.
|
||||
dataServices.setHttp(npStart.core.http);
|
||||
dataServices.setNotifications(npStart.core.notifications);
|
||||
dataServices.setOverlays(npStart.core.overlays);
|
||||
dataServices.setUiSettings(npStart.core.uiSettings);
|
||||
dataServices.setFieldFormats(npStart.plugins.data.fieldFormats);
|
||||
dataServices.setIndexPatterns(npStart.plugins.data.indexPatterns);
|
||||
dataServices.setQueryService(npStart.plugins.data.query);
|
||||
dataServices.setSearchService(npStart.plugins.data.search);
|
||||
visualizationsServices.setI18n(npStart.core.i18n);
|
||||
visualizationsServices.setTypes(
|
||||
pick(npStart.plugins.visualizations, ['get', 'all', 'getAliases'])
|
||||
);
|
||||
visualizationsServices.setCapabilities(npStart.core.application.capabilities);
|
||||
visualizationsServices.setHttp(npStart.core.http);
|
||||
visualizationsServices.setSavedObjects(npStart.core.savedObjects);
|
||||
visualizationsServices.setIndexPatterns(npStart.plugins.data.indexPatterns);
|
||||
visualizationsServices.setFilterManager(npStart.plugins.data.query.filterManager);
|
||||
visualizationsServices.setExpressions(npStart.plugins.expressions);
|
||||
visualizationsServices.setUiActions(npStart.plugins.uiActions);
|
||||
visualizationsServices.setTimeFilter(npStart.plugins.data.query.timefilter.timefilter);
|
||||
visualizationsServices.setAggs(npStart.plugins.data.search.aggs);
|
||||
visualizationsServices.setOverlays(npStart.core.overlays);
|
||||
visualizationsServices.setChrome(npStart.core.chrome);
|
||||
const savedVisualizationsLoader = createSavedVisLoader({
|
||||
savedObjectsClient: npStart.core.savedObjects.client,
|
||||
indexPatterns: npStart.plugins.data.indexPatterns,
|
||||
chrome: npStart.core.chrome,
|
||||
overlays: npStart.core.overlays,
|
||||
visualizationTypes: visualizationsServices.getTypes(),
|
||||
});
|
||||
visualizationsServices.setSavedVisualizationsLoader(savedVisualizationsLoader);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue