Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NP] Vega migration #63849

Merged
merged 17 commits into from
Apr 24, 2020
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"visTypeTable": "src/plugins/vis_type_table",
"visTypeTagCloud": "src/legacy/core_plugins/vis_type_tagcloud",
"visTypeTimeseries": ["src/legacy/core_plugins/vis_type_timeseries", "src/plugins/vis_type_timeseries"],
"visTypeVega": "src/legacy/core_plugins/vis_type_vega",
"visTypeVega": "src/plugins/vis_type_vega",
"visTypeVislib": "src/legacy/core_plugins/vis_type_vislib",
"visTypeXy": "src/legacy/core_plugins/vis_type_xy",
"visualizations": "src/plugins/visualizations",
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-optimizer/src/worker/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ export function getWebpackConfig(bundle: Bundle, worker: WorkerConfig) {

resolve: {
extensions: ['.js', '.ts', '.tsx', '.json'],
mainFields: ['browser', 'main'],
alias: {
tinymath: require.resolve('tinymath/lib/tinymath.es5.js'),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import Bluebird from 'bluebird';
import expect from '@kbn/expect';
import ngMock from 'ng_mock';
import $ from 'jquery';
import { createVegaVisualization } from '../vega_visualization';
// Will be replaced with new path when tests are moved
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { createVegaVisualization } from '../../../../../../plugins/vis_type_vega/public/vega_visualization';
import { ImageComparator } from 'test_utils/image_comparator';

import vegaliteGraph from '!!raw-loader!./vegalite_graph.hjson';
Expand All @@ -35,24 +37,34 @@ import vegaTooltipGraph from '!!raw-loader!./vega_tooltip_test.hjson';

import vegaMapGraph from '!!raw-loader!./vega_map_test.hjson';
import vegaMapImage256 from './vega_map_image_256.png';
// Will be replaced with new path when tests are moved
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { VegaParser } from '../../../../../../plugins/vis_type_vega/public/data_model/vega_parser';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { SearchCache } from '../../../../../../plugins/vis_type_vega/public/data_model/search_cache';

import { VegaParser } from '../data_model/vega_parser';
import { SearchCache } from '../data_model/search_cache';

import { createVegaTypeDefinition } from '../vega_type';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { createVegaTypeDefinition } from '../../../../../../plugins/vis_type_vega/public/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';
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';
import { ExprVis } from '../../../../../../plugins/visualizations/public/expressions/vis';

import {
setInjectedVars,
setData,
setSavedObjects,
setNotifications,
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
} from '../../../../../../plugins/vis_type_vega/public/services';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { setInjectedVarFunc } from '../../../../../plugins/maps_legacy/public/kibana_services';
import { setInjectedVarFunc } from '../../../../../../plugins/maps_legacy/public/kibana_services';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { ServiceSettings } from '../../../../../plugins/maps_legacy/public/map/service_settings';
import { ServiceSettings } from '../../../../../../plugins/maps_legacy/public/map/service_settings';

const THRESHOLD = 0.1;
const PIXEL_DIFF = 30;
Expand All @@ -70,6 +82,9 @@ describe('VegaVisualizations', () => {
enableExternalUrls: true,
esShardTimeout: 10000,
});
setData(npStart.plugins.data);
setSavedObjects(npStart.core.savedObjects);
setNotifications(npStart.core.notifications);

beforeEach(ngMock.module('kibana'));
beforeEach(
Expand Down Expand Up @@ -111,9 +126,6 @@ describe('VegaVisualizations', () => {
timefilter: {},
},
},
__LEGACY: {
esClient: npStart.plugins.data.search.__LEGACY.esClient,
},
},
},
};
Expand Down
55 changes: 0 additions & 55 deletions src/legacy/core_plugins/vis_type_vega/index.ts

This file was deleted.

6 changes: 0 additions & 6 deletions src/legacy/core_plugins/vis_type_vega/package.json

This file was deleted.

25 changes: 0 additions & 25 deletions src/legacy/core_plugins/vis_type_vega/public/index.ts

This file was deleted.

38 changes: 0 additions & 38 deletions src/legacy/core_plugins/vis_type_vega/public/legacy.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/legacy/ui/public/new_platform/new_platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ import {
NavigationPublicPluginSetup,
NavigationPublicPluginStart,
} from '../../../../plugins/navigation/public';
import { VisTypeVegaSetup } from '../../../../plugins/vis_type_vega/public';
import { DiscoverSetup, DiscoverStart } from '../../../../plugins/discover/public';
import {
SavedObjectsManagementPluginSetup,
Expand Down Expand Up @@ -88,7 +87,6 @@ export interface PluginsSetup {
usageCollection: UsageCollectionSetup;
advancedSettings: AdvancedSettingsSetup;
management: ManagementSetup;
visTypeVega: VisTypeVegaSetup;
discover: DiscoverSetup;
visualizations: VisualizationsSetup;
telemetry?: TelemetryPluginSetup;
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/vis_type_vega/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"id": "visTypeVega",
"version": "kibana",
"server": true,
"ui": true
"ui": true,
"requiredPlugins": ["data", "visualizations", "mapsLegacy", "expressions"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
* under the License.
*/

import { createGetterSetter } from '../../../../../plugins/kibana_utils/public';
import { DataPublicPluginStart } from '../../../../../plugins/data/public';
import { createGetterSetter } from '../../../kibana_utils/public';
import { DataPublicPluginStart } from '../../../data/public';
import { IUiSettingsClient, NotificationsStart, SavedObjectsStart } from 'kibana/public';
import { dataPluginMock } from '../../../../../plugins/data/public/mocks';
import { coreMock } from '../../../../../core/public/mocks';
import { dataPluginMock } from '../../../data/public/mocks';
import { coreMock } from '../../../../core/public/mocks';

export const [getData, setData] = createGetterSetter<DataPublicPluginStart>('Data');
setData(dataPluginMock.createStartContract());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import 'src/legacy/ui/public/styles/styling_constants';

// Prefix all styles with "vga" to avoid conflicts.
// Examples
// vgaChart
Expand Down
20 changes: 4 additions & 16 deletions src/plugins/vis_type_vega/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,8 @@

import { PluginInitializerContext } from 'kibana/public';
import { ConfigSchema } from '../config';
import { VegaPlugin as Plugin } from './plugin';

export const plugin = (initializerContext: PluginInitializerContext<ConfigSchema>) => ({
setup() {
return {
/**
* The configuration is temporarily exposed to allow the legacy vega plugin to consume
* the setting. Once the vega plugin is migrated completely, this will become an implementation
* detail.
* @deprecated
*/
config: initializerContext.config.get(),
};
},
start() {},
});

export type VisTypeVegaSetup = ReturnType<ReturnType<typeof plugin>['setup']>;
export function plugin(initializerContext: PluginInitializerContext<ConfigSchema>) {
return new Plugin(initializerContext);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from '../../../../core/public';
import { Plugin as ExpressionsPublicPlugin } from '../../../../plugins/expressions/public';
import { Plugin as DataPublicPlugin } from '../../../../plugins/data/public';
import { VisualizationsSetup } from '../../../../plugins/visualizations/public';
import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from '../../../core/public';
import { Plugin as ExpressionsPublicPlugin } from '../../expressions/public';
import { Plugin as DataPublicPlugin } from '../../data/public';
import { VisualizationsSetup } from '../../visualizations/public';
import {
setNotifications,
setData,
Expand All @@ -30,8 +30,10 @@ import {

import { createVegaFn } from './vega_fn';
import { createVegaTypeDefinition } from './vega_type';
import { VisTypeVegaSetup } from '../../../../plugins/vis_type_vega/public';
import { IServiceSettings } from '../../../../plugins/maps_legacy/public';
import { IServiceSettings } from '../../maps_legacy/public';
import { ConfigSchema } from '../config';

import './index.scss';

/** @internal */
export interface VegaVisualizationDependencies {
Expand All @@ -47,7 +49,6 @@ export interface VegaPluginSetupDependencies {
expressions: ReturnType<ExpressionsPublicPlugin['setup']>;
visualizations: VisualizationsSetup;
data: ReturnType<DataPublicPlugin['setup']>;
visTypeVega: VisTypeVegaSetup;
mapsLegacy: any;
}

Expand All @@ -58,18 +59,18 @@ export interface VegaPluginStartDependencies {

/** @internal */
export class VegaPlugin implements Plugin<Promise<void>, void> {
initializerContext: PluginInitializerContext;
initializerContext: PluginInitializerContext<ConfigSchema>;

constructor(initializerContext: PluginInitializerContext) {
constructor(initializerContext: PluginInitializerContext<ConfigSchema>) {
this.initializerContext = initializerContext;
}

public async setup(
core: CoreSetup,
{ data, expressions, visualizations, visTypeVega, mapsLegacy }: VegaPluginSetupDependencies
{ data, expressions, visualizations, mapsLegacy }: VegaPluginSetupDependencies
) {
setInjectedVars({
enableExternalUrls: visTypeVega.config.enableExternalUrls,
enableExternalUrls: this.initializerContext.config.get().enableExternalUrls,
esShardTimeout: core.injectedMetadata.getInjectedVar('esShardTimeout') as number,
emsTileLayerId: core.injectedMetadata.getInjectedVar('emsTileLayerId', true),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
*/

import { SavedObjectsStart } from 'kibana/public';
import { NotificationsStart } from 'src/core/public';
import { DataPublicPluginStart } from '../../../../plugins/data/public';
import { createGetterSetter } from '../../../../plugins/kibana_utils/public';
import { IUiSettingsClient } from '../../../../core/public';
import { NotificationsStart, IUiSettingsClient } from 'src/core/public';
import { DataPublicPluginStart } from '../../data/public';
import { createGetterSetter } from '../../kibana_utils/public';

export const [getData, setData] = createGetterSetter<DataPublicPluginStart>('Data');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@

import { get } from 'lodash';
import { i18n } from '@kbn/i18n';
import {
ExpressionFunctionDefinition,
KibanaContext,
Render,
} from '../../../../plugins/expressions/public';
import { ExpressionFunctionDefinition, KibanaContext, Render } from '../../expressions/public';
import { VegaVisualizationDependencies } from './plugin';
import { createVegaRequestHandler } from './vega_request_handler';

Expand Down
Loading