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

[Maps] Isolate maps-setting froms maps_legacy #92918

Merged
merged 33 commits into from
Mar 15, 2021
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
22de368
init boiler
thomasneirynck Feb 25, 2021
bc68048
Merge branch 'master' of github.com:elastic/kibana into maps/add_maps…
thomasneirynck Feb 25, 2021
fcd19cf
type fixes (1)
thomasneirynck Feb 25, 2021
d1a5870
Merge branch 'master' of github.com:elastic/kibana into maps/add_maps…
thomasneirynck Mar 1, 2021
3fb1cee
ts fixes
thomasneirynck Mar 1, 2021
322f737
remove comma
thomasneirynck Mar 1, 2021
b52d925
convert to ts
thomasneirynck Mar 1, 2021
c00731a
fix deps
thomasneirynck Mar 1, 2021
6fe19b9
more typing
thomasneirynck Mar 1, 2021
2259d9e
Merge branch 'master' of github.com:elastic/kibana into maps/add_maps…
thomasneirynck Mar 2, 2021
37060ff
Merge branch 'master' of github.com:elastic/kibana into maps/add_maps…
thomasneirynck Mar 2, 2021
63013cf
fix ts types
thomasneirynck Mar 2, 2021
dbee0c6
align ts with ems-client
thomasneirynck Mar 2, 2021
1515d43
build plugin list
thomasneirynck Mar 2, 2021
c1662e3
Merge branch 'master' of github.com:elastic/kibana into maps/add_maps…
thomasneirynck Mar 3, 2021
fb30c5d
make typing more strict
thomasneirynck Mar 3, 2021
afbd3b2
Merge branch 'master' of github.com:elastic/kibana into maps/add_maps…
thomasneirynck Mar 4, 2021
e835b39
move to common
thomasneirynck Mar 4, 2021
a7ac778
remove duplicate tilemap/regionmap configs
thomasneirynck Mar 4, 2021
3a773f8
remove dupe types
thomasneirynck Mar 4, 2021
e85fded
only import type
thomasneirynck Mar 5, 2021
32ce7de
type import
thomasneirynck Mar 5, 2021
357c9b3
remove export
thomasneirynck Mar 5, 2021
ac9ac35
remove export
thomasneirynck Mar 5, 2021
424a4a1
add typing
thomasneirynck Mar 5, 2021
788be87
generate bundles
thomasneirynck Mar 10, 2021
3fbd3d8
Merge branch 'master' of github.com:elastic/kibana into maps/add_maps…
thomasneirynck Mar 10, 2021
40d3f90
remove autogen
thomasneirynck Mar 10, 2021
5b4b6c7
feedback
thomasneirynck Mar 11, 2021
37aa88b
re move unused
thomasneirynck Mar 11, 2021
2c152e0
ts fixes
thomasneirynck Mar 11, 2021
f515a7c
update limit
thomasneirynck Mar 11, 2021
929ca7b
Merge branch 'master' into maps/add_maps_ems
kibanamachine Mar 15, 2021
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
4 changes: 4 additions & 0 deletions docs/developer/plugin-list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ to link individual managment section into it. This plugin does not contain any i
management section itself.


|{kib-repo}blob/{branch}/src/plugins/maps_ems/README.md[mapsEms]
|Configuration of kibana-wide EMS settings and some higher level utilities.


|{kib-repo}blob/{branch}/src/plugins/maps_legacy/README.md[mapsLegacy]
|Internal objects used by the Coordinate, Region, and Vega visualizations.

Expand Down
1 change: 1 addition & 0 deletions packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,4 @@ pageLoadAssetSize:
osquery: 107090
fileUpload: 25664
banners: 17946
mapsEms: 26072
Copy link
Contributor

@tylersmalley tylersmalley Mar 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could mapsLegacy be reduced since this was broken out?

Running node scripts/build_kibana_platform_plugins.js --update-limits it looks like mapsLegacy could be set to 87859 which is 5k above the current size.

3 changes: 3 additions & 0 deletions src/plugins/maps_ems/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Maps EMS

Configuration of kibana-wide EMS settings and some higher level utilities.
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@

export const TMS_IN_YML_ID = 'TMS in config/kibana.yml';

export * from './ems_defaults';
export { ORIGIN } from './origin';
87 changes: 87 additions & 0 deletions src/plugins/maps_ems/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { schema, TypeOf } from '@kbn/config-schema';

import {
DEFAULT_EMS_FONT_LIBRARY_URL,
DEFAULT_EMS_LANDING_PAGE_URL,
DEFAULT_EMS_TILE_API_URL,
DEFAULT_EMS_FILE_API_URL,
} from './common';

const tileMapConfigOptionsSchema = schema.object({
attribution: schema.string({ defaultValue: '' }),
minZoom: schema.number({ defaultValue: 0, min: 0 }),
maxZoom: schema.number({ defaultValue: 10 }),
tileSize: schema.maybe(schema.number()),
subdomains: schema.maybe(schema.arrayOf(schema.string())),
errorTileUrl: schema.maybe(schema.string()),
tms: schema.maybe(schema.boolean()),
reuseTiles: schema.maybe(schema.boolean()),
bounds: schema.maybe(schema.arrayOf(schema.number({ min: 2 }))),
default: schema.maybe(schema.boolean()),
});

export const tilemapConfigSchema = schema.object({
url: schema.maybe(schema.string()),
options: tileMapConfigOptionsSchema,
});

const layerConfigSchema = schema.object({
url: schema.string(),
format: schema.object({
type: schema.string({ defaultValue: 'geojson' }),
}),
meta: schema.object({
feature_collection_path: schema.string({ defaultValue: 'data' }),
}),
attribution: schema.string(),
name: schema.string(),
fields: schema.arrayOf(
schema.object({
name: schema.string(),
description: schema.string(),
})
),
});

export type LayerConfig = TypeOf<typeof layerConfigSchema>;

const regionmapConfigSchema = schema.object({
includeElasticMapsService: schema.boolean({ defaultValue: true }),
layers: schema.arrayOf(layerConfigSchema, { defaultValue: [] }),
});

export const emsConfigSchema = schema.object({
regionmap: regionmapConfigSchema,
tilemap: tilemapConfigSchema,
includeElasticMapsService: schema.boolean({ defaultValue: true }),
proxyElasticMapsServiceInMaps: schema.boolean({ defaultValue: false }),
manifestServiceUrl: schema.string({ defaultValue: '' }),
emsUrl: schema.conditional(
schema.siblingRef('proxyElasticMapsServiceInMaps'),
true,
schema.never(),
schema.string({ defaultValue: '' })
),
emsFileApiUrl: schema.string({ defaultValue: DEFAULT_EMS_FILE_API_URL }),
emsTileApiUrl: schema.string({ defaultValue: DEFAULT_EMS_TILE_API_URL }),
emsLandingPageUrl: schema.string({ defaultValue: DEFAULT_EMS_LANDING_PAGE_URL }),
emsFontLibraryUrl: schema.string({
defaultValue: DEFAULT_EMS_FONT_LIBRARY_URL,
}),
emsTileLayerId: schema.object({
bright: schema.string({ defaultValue: 'road_map' }),
desaturated: schema.string({ defaultValue: 'road_map_desaturated' }),
dark: schema.string({ defaultValue: 'dark_map' }),
}),
});

export type MapsEmsConfig = TypeOf<typeof emsConfigSchema>;
export type TileMapConfig = TypeOf<typeof tilemapConfigSchema>;
13 changes: 13 additions & 0 deletions src/plugins/maps_ems/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

module.exports = {
preset: '@kbn/test',
rootDir: '../../..',
roots: ['<rootDir>/src/plugins/maps_ems'],
};
9 changes: 9 additions & 0 deletions src/plugins/maps_ems/kibana.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"id": "mapsEms",
"version": "8.0.0",
"kibanaVersion": "kibana",
"configPath": ["map"],
"ui": true,
"server": true,
"extraPublicDirs": ["common"]
}
35 changes: 35 additions & 0 deletions src/plugins/maps_ems/public/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { PluginInitializerContext } from 'kibana/public';
import { MapsEmsPlugin } from './plugin';
import { IServiceSettings } from './service_settings';
import type { MapsEmsConfig } from '../config';

/** @public */
export {
VectorLayer,
FileLayerField,
FileLayer,
TmsLayer,
IServiceSettings,
} from './service_settings';

export function plugin(initializerContext: PluginInitializerContext) {
return new MapsEmsPlugin(initializerContext);
}

export type { MapsEmsConfig, LayerConfig } from '../config';

export * from '../common';

export interface MapsEmsPluginSetup {
config: MapsEmsConfig;
getServiceSettings: () => Promise<IServiceSettings>;
}
export type MapsEmsPluginStart = ReturnType<MapsEmsPlugin['start']>;
17 changes: 17 additions & 0 deletions src/plugins/maps_ems/public/kibana_services.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import type { MapsEmsConfig } from '../config';

let kibanaVersion: string;
export const setKibanaVersion = (version: string) => (kibanaVersion = version);
export const getKibanaVersion = (): string => kibanaVersion;

let mapsEmsConfig: MapsEmsConfig;
export const setMapsEmsConfig = (config: MapsEmsConfig) => (mapsEmsConfig = config);
export const getMapsEmsConfig = () => mapsEmsConfig;
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
* Side Public License, v 1.
*/

import { lazyLoadMapsLegacyModules } from './lazy_load_bundle';
// @ts-expect-error
import { getMapsLegacyConfig } from './kibana_services';
import { IServiceSettings } from './map/service_settings_types';
import type { IServiceSettings } from '../service_settings/service_settings_types';
import { getMapsEmsConfig } from '../kibana_services';

let loadPromise: Promise<IServiceSettings>;

Expand All @@ -19,10 +17,9 @@ export async function getServiceSettings(): Promise<IServiceSettings> {
}

loadPromise = new Promise(async (resolve) => {
const modules = await lazyLoadMapsLegacyModules();
const config = getMapsLegacyConfig();
// @ts-expect-error
resolve(new modules.ServiceSettings(config, config.tilemap));
const { ServiceSettings } = await import('./lazy');
const config = getMapsEmsConfig();
resolve(new ServiceSettings(config, config.tilemap));
});
return loadPromise;
}
9 changes: 9 additions & 0 deletions src/plugins/maps_ems/public/lazy_load_bundle/lazy/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export { ServiceSettings } from '../../service_settings/service_settings';
50 changes: 50 additions & 0 deletions src/plugins/maps_ems/public/plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

// @ts-ignore
import { CoreSetup, CoreStart, Plugin, PluginInitializerContext } from 'kibana/public';
// @ts-ignore
import { setKibanaVersion, setMapsEmsConfig } from './kibana_services';
// @ts-ignore
import { MapsEmsPluginSetup, MapsEmsPluginStart } from './index';
import type { MapsEmsConfig } from '../config';
import { getServiceSettings } from './lazy_load_bundle/get_service_settings';

/**
* These are the interfaces with your public contracts. You should export these
* for other plugins to use in _their_ `SetupDeps`/`StartDeps` interfaces.
* @public
*/

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface MapsEmsStartDependencies {}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface MapsEmsSetupDependencies {}

export class MapsEmsPlugin implements Plugin<MapsEmsPluginSetup, MapsEmsPluginStart> {
readonly _initializerContext: PluginInitializerContext<MapsEmsConfig>;

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

public setup(core: CoreSetup, plugins: MapsEmsSetupDependencies) {
const config = this._initializerContext.config.get<MapsEmsConfig>();
const kibanaVersion = this._initializerContext.env.packageInfo.version;

setKibanaVersion(kibanaVersion);
setMapsEmsConfig(config);

return {
getServiceSettings,
config,
};
}

public start(core: CoreStart, plugins: MapsEmsStartDependencies) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
* Side Public License, v 1.
*/

export * from './ems_defaults';
export * from './service_settings_types';
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ jest.mock('../kibana_services', () => ({

import url from 'url';

import EMS_FILES from '../__tests__/map/ems_mocks/sample_files.json';
import EMS_TILES from '../__tests__/map/ems_mocks/sample_tiles.json';
import EMS_STYLE_ROAD_MAP_BRIGHT from '../__tests__/map/ems_mocks/sample_style_bright';
import EMS_STYLE_ROAD_MAP_DESATURATED from '../__tests__/map/ems_mocks/sample_style_desaturated';
import EMS_STYLE_DARK_MAP from '../__tests__/map/ems_mocks/sample_style_dark';
import { ORIGIN } from '../common/constants/origin';
import EMS_FILES from '../../__tests__/map/ems_mocks/sample_files.json';
import EMS_TILES from '../../__tests__/map/ems_mocks/sample_tiles.json';
import EMS_STYLE_ROAD_MAP_BRIGHT from '../../__tests__/map/ems_mocks/sample_style_bright';
import EMS_STYLE_ROAD_MAP_DESATURATED from '../../__tests__/map/ems_mocks/sample_style_desaturated';
import EMS_STYLE_DARK_MAP from '../../__tests__/map/ems_mocks/sample_style_dark';
import { ORIGIN } from '../../common';
import { ServiceSettings } from './service_settings';

describe('service_settings (FKA tile_map test)', function () {
Expand Down
Loading