diff --git a/x-pack/.i18nrc.json b/x-pack/.i18nrc.json index 53628ea970fb6f4..60a8d1fcbf2295a 100644 --- a/x-pack/.i18nrc.json +++ b/x-pack/.i18nrc.json @@ -26,7 +26,7 @@ "xpack.licensing": "plugins/licensing", "xpack.logstash": "legacy/plugins/logstash", "xpack.main": "legacy/plugins/xpack_main", - "xpack.maps": "legacy/plugins/maps", + "xpack.maps": ["plugins/maps", "legacy/plugins/maps"], "xpack.ml": ["plugins/ml", "legacy/plugins/ml"], "xpack.monitoring": "legacy/plugins/monitoring", "xpack.remoteClusters": "plugins/remote_clusters", diff --git a/x-pack/legacy/plugins/maps/common/constants.ts b/x-pack/legacy/plugins/maps/common/constants.ts index a73e13cc948c841..98945653c25dc82 100644 --- a/x-pack/legacy/plugins/maps/common/constants.ts +++ b/x-pack/legacy/plugins/maps/common/constants.ts @@ -3,180 +3,6 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { i18n } from '@kbn/i18n'; -export const EMS_CATALOGUE_PATH = 'ems/catalogue'; -export const EMS_FILES_CATALOGUE_PATH = 'ems/files'; -export const EMS_FILES_API_PATH = 'ems/files'; -export const EMS_FILES_DEFAULT_JSON_PATH = 'file'; -export const EMS_GLYPHS_PATH = 'fonts'; -export const EMS_SPRITES_PATH = 'sprites'; - -export const EMS_TILES_CATALOGUE_PATH = 'ems/tiles'; -export const EMS_TILES_API_PATH = 'ems/tiles'; -export const EMS_TILES_RASTER_STYLE_PATH = 'raster/style'; -export const EMS_TILES_RASTER_TILE_PATH = 'raster/tile'; - -export const EMS_TILES_VECTOR_STYLE_PATH = 'vector/style'; -export const EMS_TILES_VECTOR_SOURCE_PATH = 'vector/source'; -export const EMS_TILES_VECTOR_TILE_PATH = 'vector/tile'; - -export const MAP_SAVED_OBJECT_TYPE = 'map'; -export const APP_ID = 'maps'; -export const APP_ICON = 'gisApp'; -export const TELEMETRY_TYPE = 'maps-telemetry'; - -export const MAP_APP_PATH = `app/${APP_ID}`; -export const GIS_API_PATH = `api/${APP_ID}`; -export const INDEX_SETTINGS_API_PATH = `${GIS_API_PATH}/indexSettings`; - -export const MAP_BASE_URL = `/${MAP_APP_PATH}#/${MAP_SAVED_OBJECT_TYPE}`; - -export function createMapPath(id: string) { - return `${MAP_BASE_URL}/${id}`; -} - -export const LAYER_TYPE = { - TILE: 'TILE', - VECTOR: 'VECTOR', - VECTOR_TILE: 'VECTOR_TILE', - HEATMAP: 'HEATMAP', -}; - -export enum SORT_ORDER { - ASC = 'asc', - DESC = 'desc', -} - -export const EMS_TMS = 'EMS_TMS'; -export const EMS_FILE = 'EMS_FILE'; -export const ES_GEO_GRID = 'ES_GEO_GRID'; -export const ES_SEARCH = 'ES_SEARCH'; -export const ES_PEW_PEW = 'ES_PEW_PEW'; -export const EMS_XYZ = 'EMS_XYZ'; // identifies a custom TMS source. Name is a little unfortunate. - -export enum FIELD_ORIGIN { - SOURCE = 'source', - JOIN = 'join', -} - -export const SOURCE_DATA_ID_ORIGIN = 'source'; -export const META_ID_ORIGIN_SUFFIX = 'meta'; -export const SOURCE_META_ID_ORIGIN = `${SOURCE_DATA_ID_ORIGIN}_${META_ID_ORIGIN_SUFFIX}`; -export const FORMATTERS_ID_ORIGIN_SUFFIX = 'formatters'; -export const SOURCE_FORMATTERS_ID_ORIGIN = `${SOURCE_DATA_ID_ORIGIN}_${FORMATTERS_ID_ORIGIN_SUFFIX}`; - -export const GEOJSON_FILE = 'GEOJSON_FILE'; - -export const MIN_ZOOM = 0; -export const MAX_ZOOM = 24; - -export const DECIMAL_DEGREES_PRECISION = 5; // meters precision -export const ZOOM_PRECISION = 2; -export const DEFAULT_MAX_RESULT_WINDOW = 10000; -export const DEFAULT_MAX_INNER_RESULT_WINDOW = 100; -export const DEFAULT_MAX_BUCKETS_LIMIT = 10000; - -export const FEATURE_ID_PROPERTY_NAME = '__kbn__feature_id__'; -export const FEATURE_VISIBLE_PROPERTY_NAME = '__kbn_isvisibleduetojoin__'; - -export const MB_SOURCE_ID_LAYER_ID_PREFIX_DELIMITER = '_'; - -export const ES_GEO_FIELD_TYPE = { - GEO_POINT: 'geo_point', - GEO_SHAPE: 'geo_shape', -}; - -export const ES_SPATIAL_RELATIONS = { - INTERSECTS: 'INTERSECTS', - DISJOINT: 'DISJOINT', - WITHIN: 'WITHIN', -}; - -export const GEO_JSON_TYPE = { - POINT: 'Point', - MULTI_POINT: 'MultiPoint', - LINE_STRING: 'LineString', - MULTI_LINE_STRING: 'MultiLineString', - POLYGON: 'Polygon', - MULTI_POLYGON: 'MultiPolygon', - GEOMETRY_COLLECTION: 'GeometryCollection', -}; - -export const POLYGON_COORDINATES_EXTERIOR_INDEX = 0; -export const LON_INDEX = 0; -export const LAT_INDEX = 1; - -export const EMPTY_FEATURE_COLLECTION = { - type: 'FeatureCollection', - features: [], -}; - -export const DRAW_TYPE = { - BOUNDS: 'BOUNDS', - POLYGON: 'POLYGON', -}; - -export enum AGG_TYPE { - AVG = 'avg', - COUNT = 'count', - MAX = 'max', - MIN = 'min', - SUM = 'sum', - TERMS = 'terms', - UNIQUE_COUNT = 'cardinality', -} - -export enum RENDER_AS { - HEATMAP = 'heatmap', - POINT = 'point', - GRID = 'grid', -} - -export enum GRID_RESOLUTION { - COARSE = 'COARSE', - FINE = 'FINE', - MOST_FINE = 'MOST_FINE', -} - -export const TOP_TERM_PERCENTAGE_SUFFIX = '__percentage'; - -export const COUNT_PROP_LABEL = i18n.translate('xpack.maps.aggs.defaultCountLabel', { - defaultMessage: 'count', -}); - -export const COUNT_PROP_NAME = 'doc_count'; - -export const STYLE_TYPE = { - STATIC: 'STATIC', - DYNAMIC: 'DYNAMIC', -}; - -export const LAYER_STYLE_TYPE = { - VECTOR: 'VECTOR', - HEATMAP: 'HEATMAP', -}; - -export const COLOR_MAP_TYPE = { - CATEGORICAL: 'CATEGORICAL', - ORDINAL: 'ORDINAL', -}; - -export const COLOR_PALETTE_MAX_SIZE = 10; - -export const CATEGORICAL_DATA_TYPES = ['string', 'ip', 'boolean']; -export const ORDINAL_DATA_TYPES = ['number', 'date']; - -export enum SYMBOLIZE_AS_TYPES { - CIRCLE = 'circle', - ICON = 'icon', -} - -export enum LABEL_BORDER_SIZES { - NONE = 'NONE', - SMALL = 'SMALL', - MEDIUM = 'MEDIUM', - LARGE = 'LARGE', -} - -export const DEFAULT_ICON = 'airfield'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +export * from '../../../../plugins/maps/common/constants'; diff --git a/x-pack/legacy/plugins/maps/common/i18n_getters.ts b/x-pack/legacy/plugins/maps/common/i18n_getters.ts index 0008a119f1c7cce..f9d186dea2e2b90 100644 --- a/x-pack/legacy/plugins/maps/common/i18n_getters.ts +++ b/x-pack/legacy/plugins/maps/common/i18n_getters.ts @@ -4,49 +4,5 @@ * you may not use this file except in compliance with the Elastic License. */ -import { i18n } from '@kbn/i18n'; - -import { $Values } from '@kbn/utility-types'; -import { ES_SPATIAL_RELATIONS } from './constants'; - -export function getAppTitle() { - return i18n.translate('xpack.maps.appTitle', { - defaultMessage: 'Maps', - }); -} - -export function getDataSourceLabel() { - return i18n.translate('xpack.maps.source.dataSourceLabel', { - defaultMessage: 'Data source', - }); -} - -export function getUrlLabel() { - return i18n.translate('xpack.maps.source.urlLabel', { - defaultMessage: 'Url', - }); -} - -export function getEsSpatialRelationLabel(spatialRelation: $Values) { - switch (spatialRelation) { - case ES_SPATIAL_RELATIONS.INTERSECTS: - return i18n.translate('xpack.maps.common.esSpatialRelation.intersectsLabel', { - defaultMessage: 'intersects', - }); - case ES_SPATIAL_RELATIONS.DISJOINT: - return i18n.translate('xpack.maps.common.esSpatialRelation.disjointLabel', { - defaultMessage: 'disjoint', - }); - case ES_SPATIAL_RELATIONS.WITHIN: - return i18n.translate('xpack.maps.common.esSpatialRelation.withinLabel', { - defaultMessage: 'within', - }); - // @ts-ignore - case ES_SPATIAL_RELATIONS.CONTAINS: - return i18n.translate('xpack.maps.common.esSpatialRelation.containsLabel', { - defaultMessage: 'contains', - }); - default: - return spatialRelation; - } -} +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +export * from '../../../../plugins/maps/common/i18n_getters'; diff --git a/x-pack/legacy/plugins/maps/common/parse_xml_string.js b/x-pack/legacy/plugins/maps/common/parse_xml_string.js index 9d95e0e78280d52..34ec14447282819 100644 --- a/x-pack/legacy/plugins/maps/common/parse_xml_string.js +++ b/x-pack/legacy/plugins/maps/common/parse_xml_string.js @@ -4,19 +4,5 @@ * you may not use this file except in compliance with the Elastic License. */ -import { parseString } from 'xml2js'; - -// promise based wrapper around parseString -export async function parseXmlString(xmlString) { - const parsePromise = new Promise((resolve, reject) => { - parseString(xmlString, (error, result) => { - if (error) { - reject(error); - } else { - resolve(result); - } - }); - }); - - return await parsePromise; -} +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +export * from '../../../../plugins/maps/common/parse_xml_string'; diff --git a/x-pack/legacy/plugins/maps/index.js b/x-pack/legacy/plugins/maps/index.js index 8048c21fe9333dc..1a7f478d3bbad42 100644 --- a/x-pack/legacy/plugins/maps/index.js +++ b/x-pack/legacy/plugins/maps/index.js @@ -52,7 +52,6 @@ export function maps(kibana) { }; }, embeddableFactories: ['plugins/maps/embeddable/map_embeddable_factory'], - inspectorViews: ['plugins/maps/inspector/views/register_views'], home: ['plugins/maps/legacy_register_feature'], styleSheetPaths: `${__dirname}/public/index.scss`, savedObjectSchemas: { diff --git a/x-pack/legacy/plugins/maps/public/actions/map_actions.js b/x-pack/legacy/plugins/maps/public/actions/map_actions.js index cfca044ea759a1d..7a1e5e5266246d3 100644 --- a/x-pack/legacy/plugins/maps/public/actions/map_actions.js +++ b/x-pack/legacy/plugins/maps/public/actions/map_actions.js @@ -20,13 +20,15 @@ import { getQuery, getDataRequestDescriptor, } from '../selectors/map_selectors'; -import { FLYOUT_STATE } from '../reducers/ui'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { FLYOUT_STATE } from '../../../../../plugins/maps/public/reducers/ui'; import { cancelRequest, registerCancelCallback, unregisterCancelCallback, getEventHandlers, -} from '../reducers/non_serializable_instances'; + // eslint-disable-next-line @kbn/eslint/no-restricted-paths +} from '../../../../../plugins/maps/public/reducers/non_serializable_instances'; import { updateFlyout } from '../actions/ui_actions'; import { FEATURE_ID_PROPERTY_NAME, @@ -34,48 +36,52 @@ import { SOURCE_DATA_ID_ORIGIN, } from '../../common/constants'; -export const SET_SELECTED_LAYER = 'SET_SELECTED_LAYER'; -export const SET_TRANSIENT_LAYER = 'SET_TRANSIENT_LAYER'; -export const UPDATE_LAYER_ORDER = 'UPDATE_LAYER_ORDER'; -export const ADD_LAYER = 'ADD_LAYER'; -export const SET_LAYER_ERROR_STATUS = 'SET_LAYER_ERROR_STATUS'; -export const ADD_WAITING_FOR_MAP_READY_LAYER = 'ADD_WAITING_FOR_MAP_READY_LAYER'; -export const CLEAR_WAITING_FOR_MAP_READY_LAYER_LIST = 'CLEAR_WAITING_FOR_MAP_READY_LAYER_LIST'; -export const REMOVE_LAYER = 'REMOVE_LAYER'; -export const SET_LAYER_VISIBILITY = 'SET_LAYER_VISIBILITY'; -export const MAP_EXTENT_CHANGED = 'MAP_EXTENT_CHANGED'; -export const MAP_READY = 'MAP_READY'; -export const MAP_DESTROYED = 'MAP_DESTROYED'; -export const LAYER_DATA_LOAD_STARTED = 'LAYER_DATA_LOAD_STARTED'; -export const LAYER_DATA_LOAD_ENDED = 'LAYER_DATA_LOAD_ENDED'; -export const LAYER_DATA_LOAD_ERROR = 'LAYER_DATA_LOAD_ERROR'; -export const UPDATE_SOURCE_DATA_REQUEST = 'UPDATE_SOURCE_DATA_REQUEST'; -export const SET_JOINS = 'SET_JOINS'; -export const SET_QUERY = 'SET_QUERY'; -export const TRIGGER_REFRESH_TIMER = 'TRIGGER_REFRESH_TIMER'; -export const UPDATE_LAYER_PROP = 'UPDATE_LAYER_PROP'; -export const UPDATE_LAYER_STYLE = 'UPDATE_LAYER_STYLE'; -export const SET_LAYER_STYLE_META = 'SET_LAYER_STYLE_META'; -export const TOUCH_LAYER = 'TOUCH_LAYER'; -export const UPDATE_SOURCE_PROP = 'UPDATE_SOURCE_PROP'; -export const SET_REFRESH_CONFIG = 'SET_REFRESH_CONFIG'; -export const SET_MOUSE_COORDINATES = 'SET_MOUSE_COORDINATES'; -export const CLEAR_MOUSE_COORDINATES = 'CLEAR_MOUSE_COORDINATES'; -export const SET_GOTO = 'SET_GOTO'; -export const CLEAR_GOTO = 'CLEAR_GOTO'; -export const TRACK_CURRENT_LAYER_STATE = 'TRACK_CURRENT_LAYER_STATE'; -export const ROLLBACK_TO_TRACKED_LAYER_STATE = 'ROLLBACK_TO_TRACKED_LAYER_STATE'; -export const REMOVE_TRACKED_LAYER_STATE = 'REMOVE_TRACKED_LAYER_STATE'; -export const SET_OPEN_TOOLTIPS = 'SET_OPEN_TOOLTIPS'; -export const UPDATE_DRAW_STATE = 'UPDATE_DRAW_STATE'; -export const SET_SCROLL_ZOOM = 'SET_SCROLL_ZOOM'; -export const SET_MAP_INIT_ERROR = 'SET_MAP_INIT_ERROR'; -export const SET_INTERACTIVE = 'SET_INTERACTIVE'; -export const DISABLE_TOOLTIP_CONTROL = 'DISABLE_TOOLTIP_CONTROL'; -export const HIDE_TOOLBAR_OVERLAY = 'HIDE_TOOLBAR_OVERLAY'; -export const HIDE_LAYER_CONTROL = 'HIDE_LAYER_CONTROL'; -export const HIDE_VIEW_CONTROL = 'HIDE_VIEW_CONTROL'; -export const SET_WAITING_FOR_READY_HIDDEN_LAYERS = 'SET_WAITING_FOR_READY_HIDDEN_LAYERS'; +import { + SET_SELECTED_LAYER, + SET_TRANSIENT_LAYER, + UPDATE_LAYER_ORDER, + ADD_LAYER, + SET_LAYER_ERROR_STATUS, + ADD_WAITING_FOR_MAP_READY_LAYER, + CLEAR_WAITING_FOR_MAP_READY_LAYER_LIST, + REMOVE_LAYER, + SET_LAYER_VISIBILITY, + MAP_EXTENT_CHANGED, + MAP_READY, + MAP_DESTROYED, + LAYER_DATA_LOAD_STARTED, + LAYER_DATA_LOAD_ENDED, + LAYER_DATA_LOAD_ERROR, + UPDATE_SOURCE_DATA_REQUEST, + SET_JOINS, + SET_QUERY, + TRIGGER_REFRESH_TIMER, + UPDATE_LAYER_PROP, + UPDATE_LAYER_STYLE, + SET_LAYER_STYLE_META, + UPDATE_SOURCE_PROP, + SET_REFRESH_CONFIG, + SET_MOUSE_COORDINATES, + CLEAR_MOUSE_COORDINATES, + SET_GOTO, + CLEAR_GOTO, + TRACK_CURRENT_LAYER_STATE, + ROLLBACK_TO_TRACKED_LAYER_STATE, + REMOVE_TRACKED_LAYER_STATE, + SET_OPEN_TOOLTIPS, + UPDATE_DRAW_STATE, + SET_SCROLL_ZOOM, + SET_MAP_INIT_ERROR, + SET_INTERACTIVE, + DISABLE_TOOLTIP_CONTROL, + HIDE_TOOLBAR_OVERLAY, + HIDE_LAYER_CONTROL, + HIDE_VIEW_CONTROL, + SET_WAITING_FOR_READY_HIDDEN_LAYERS, + // eslint-disable-next-line @kbn/eslint/no-restricted-paths +} from '../../../../../plugins/maps/public/actions/map_actions'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +export * from '../../../../../plugins/maps/public/actions/map_actions'; function getLayerLoadingCallbacks(dispatch, getState, layerId) { return { diff --git a/x-pack/legacy/plugins/maps/public/actions/ui_actions.js b/x-pack/legacy/plugins/maps/public/actions/ui_actions.js index 2b687516f3e5ac6..33ab2fd74122a6a 100644 --- a/x-pack/legacy/plugins/maps/public/actions/ui_actions.js +++ b/x-pack/legacy/plugins/maps/public/actions/ui_actions.js @@ -4,16 +4,28 @@ * you may not use this file except in compliance with the Elastic License. */ -export const UPDATE_FLYOUT = 'UPDATE_FLYOUT'; -export const CLOSE_SET_VIEW = 'CLOSE_SET_VIEW'; -export const OPEN_SET_VIEW = 'OPEN_SET_VIEW'; -export const SET_IS_LAYER_TOC_OPEN = 'SET_IS_LAYER_TOC_OPEN'; -export const SET_FULL_SCREEN = 'SET_FULL_SCREEN'; -export const SET_READ_ONLY = 'SET_READ_ONLY'; -export const SET_OPEN_TOC_DETAILS = 'SET_OPEN_TOC_DETAILS'; -export const SHOW_TOC_DETAILS = 'SHOW_TOC_DETAILS'; -export const HIDE_TOC_DETAILS = 'HIDE_TOC_DETAILS'; -export const UPDATE_INDEXING_STAGE = 'UPDATE_INDEXING_STAGE'; +import { + UPDATE_FLYOUT, + CLOSE_SET_VIEW, + OPEN_SET_VIEW, + SET_IS_LAYER_TOC_OPEN, + SET_FULL_SCREEN, + SET_READ_ONLY, + SET_OPEN_TOC_DETAILS, + SHOW_TOC_DETAILS, + HIDE_TOC_DETAILS, + UPDATE_INDEXING_STAGE, + // eslint-disable-next-line @kbn/eslint/no-restricted-paths +} from '../../../../../plugins/maps/public/actions/ui_actions'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +export * from '../../../../../plugins/maps/public/actions/ui_actions'; + +export function exitFullScreen() { + return { + type: SET_FULL_SCREEN, + isFullScreen: false, + }; +} export function updateFlyout(display) { return { @@ -37,12 +49,6 @@ export function setIsLayerTOCOpen(isLayerTOCOpen) { isLayerTOCOpen, }; } -export function exitFullScreen() { - return { - type: SET_FULL_SCREEN, - isFullScreen: false, - }; -} export function enableFullScreen() { return { type: SET_FULL_SCREEN, diff --git a/x-pack/legacy/plugins/maps/public/angular/map_controller.js b/x-pack/legacy/plugins/maps/public/angular/map_controller.js index 84ead42d3374e18..7b3dc74d777b2b0 100644 --- a/x-pack/legacy/plugins/maps/public/angular/map_controller.js +++ b/x-pack/legacy/plugins/maps/public/angular/map_controller.js @@ -17,7 +17,8 @@ import { render, unmountComponentAtNode } from 'react-dom'; import { uiModules } from 'ui/modules'; import { timefilter } from 'ui/timefilter'; import { Provider } from 'react-redux'; -import { createMapStore } from '../reducers/store'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { createMapStore } from '../../../../../plugins/maps/public/reducers/store'; import { GisMap } from '../connected_components/gis_map'; import { addHelpMenuToAppChrome } from '../help_menu_util'; import { @@ -28,7 +29,11 @@ import { setQuery, clearTransientLayerStateAndCloseFlyout, } from '../actions/map_actions'; -import { DEFAULT_IS_LAYER_TOC_OPEN, FLYOUT_STATE } from '../reducers/ui'; +import { + DEFAULT_IS_LAYER_TOC_OPEN, + FLYOUT_STATE, + // eslint-disable-next-line @kbn/eslint/no-restricted-paths +} from '../../../../../plugins/maps/public/reducers/ui'; import { enableFullScreen, updateFlyout, @@ -37,13 +42,15 @@ import { setOpenTOCDetails, } from '../actions/ui_actions'; import { getIsFullScreen } from '../selectors/ui_selectors'; -import { copyPersistentState } from '../reducers/util'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { copyPersistentState } from '../../../../../plugins/maps/public/reducers/util'; import { getQueryableUniqueIndexPatternIds, hasDirtyState, getLayerListRaw, } from '../selectors/map_selectors'; -import { getInspectorAdapters } from '../reducers/non_serializable_instances'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { getInspectorAdapters } from '../../../../../plugins/maps/public/reducers/non_serializable_instances'; import { docTitle } from 'ui/doc_title'; import { indexPatternService, getInspector } from '../kibana_services'; import { toastNotifications } from 'ui/notify'; diff --git a/x-pack/legacy/plugins/maps/public/angular/services/saved_gis_map.js b/x-pack/legacy/plugins/maps/public/angular/services/saved_gis_map.js index 490ab16a1799c0e..f846d3d4a617f0b 100644 --- a/x-pack/legacy/plugins/maps/public/angular/services/saved_gis_map.js +++ b/x-pack/legacy/plugins/maps/public/angular/services/saved_gis_map.js @@ -18,7 +18,8 @@ import { } from '../../selectors/map_selectors'; import { getIsLayerTOCOpen, getOpenTOCDetails } from '../../selectors/ui_selectors'; import { convertMapExtentToPolygon } from '../../elasticsearch_geo_utils'; -import { copyPersistentState } from '../../reducers/util'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { copyPersistentState } from '../../../../../../plugins/maps/public/reducers/util'; import { extractReferences, injectReferences } from '../../../common/migrations/references'; import { MAP_SAVED_OBJECT_TYPE } from '../../../common/constants'; diff --git a/x-pack/legacy/plugins/maps/public/connected_components/gis_map/index.js b/x-pack/legacy/plugins/maps/public/connected_components/gis_map/index.js index ceb0a6ea9f9225d..39cb2c469e0544e 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/gis_map/index.js +++ b/x-pack/legacy/plugins/maps/public/connected_components/gis_map/index.js @@ -6,7 +6,8 @@ import { connect } from 'react-redux'; import { GisMap } from './view'; -import { FLYOUT_STATE } from '../../reducers/ui'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { FLYOUT_STATE } from '../../../../../../plugins/maps/public/reducers/ui'; import { exitFullScreen } from '../../actions/ui_actions'; import { getFlyoutDisplay, getIsFullScreen } from '../../selectors/ui_selectors'; import { triggerRefreshTimer, cancelAllInFlightRequests } from '../../actions/map_actions'; diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/import_editor/index.js b/x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/import_editor/index.js index 8d0dd0c266f28e0..e8192795f98aefd 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/import_editor/index.js +++ b/x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/import_editor/index.js @@ -6,8 +6,10 @@ import { connect } from 'react-redux'; import { ImportEditor } from './view'; -import { getInspectorAdapters } from '../../../reducers/non_serializable_instances'; -import { INDEXING_STAGE } from '../../../reducers/ui'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { getInspectorAdapters } from '../../../../../../../plugins/maps/public/reducers/non_serializable_instances'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { INDEXING_STAGE } from '../../../../../../../plugins/maps/public/reducers/ui'; import { updateIndexingStage } from '../../../actions/ui_actions'; import { getIndexingStage } from '../../../selectors/ui_selectors'; diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/index.js b/x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/index.js index d2b43775c5a492c..c4e2fa5169b0faf 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/index.js +++ b/x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/index.js @@ -6,11 +6,13 @@ import { connect } from 'react-redux'; import { AddLayerPanel } from './view'; -import { FLYOUT_STATE, INDEXING_STAGE } from '../../reducers/ui'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { FLYOUT_STATE, INDEXING_STAGE } from '../../../../../../plugins/maps/public/reducers/ui'; import { updateFlyout, updateIndexingStage } from '../../actions/ui_actions'; import { getFlyoutDisplay, getIndexingStage } from '../../selectors/ui_selectors'; import { getMapColors } from '../../selectors/map_selectors'; -import { getInspectorAdapters } from '../../reducers/non_serializable_instances'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { getInspectorAdapters } from '../../../../../../plugins/maps/public/reducers/non_serializable_instances'; import { setTransientLayer, addLayer, diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/source_editor/index.js b/x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/source_editor/index.js index 51ed19d1c77d1f7..553e54ee897665b 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/source_editor/index.js +++ b/x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/source_editor/index.js @@ -6,7 +6,8 @@ import { connect } from 'react-redux'; import { SourceEditor } from './view'; -import { getInspectorAdapters } from '../../../reducers/non_serializable_instances'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { getInspectorAdapters } from '../../../../../../../plugins/maps/public/reducers/non_serializable_instances'; function mapStateToProps(state = {}) { return { diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/flyout_footer/index.js b/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/flyout_footer/index.js index 76e650cad97eb56..287f0019f18ecdf 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/flyout_footer/index.js +++ b/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/flyout_footer/index.js @@ -6,7 +6,8 @@ import { connect } from 'react-redux'; import { FlyoutFooter } from './view'; -import { FLYOUT_STATE } from '../../../reducers/ui'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { FLYOUT_STATE } from '../../../../../../../plugins/maps/public/reducers/ui'; import { updateFlyout } from '../../../actions/ui_actions'; import { hasDirtyState } from '../../../selectors/map_selectors'; import { diff --git a/x-pack/legacy/plugins/maps/public/connected_components/map/mb/index.js b/x-pack/legacy/plugins/maps/public/connected_components/map/mb/index.js index a2f121a9377fef2..350cb7028abee29 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/map/mb/index.js +++ b/x-pack/legacy/plugins/maps/public/connected_components/map/mb/index.js @@ -24,7 +24,8 @@ import { isTooltipControlDisabled, isViewControlHidden, } from '../../../selectors/map_selectors'; -import { getInspectorAdapters } from '../../../reducers/non_serializable_instances'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { getInspectorAdapters } from '../../../../../../../plugins/maps/public/reducers/non_serializable_instances'; function mapStateToProps(state = {}) { return { diff --git a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/index.js b/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/index.js index 0b090a639edb2bb..e51e59ec41e18e9 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/index.js +++ b/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/index.js @@ -6,7 +6,8 @@ import { connect } from 'react-redux'; import { LayerControl } from './view'; -import { FLYOUT_STATE } from '../../../reducers/ui'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { FLYOUT_STATE } from '../../../../../../../plugins/maps/public/reducers/ui.js'; import { updateFlyout, setIsLayerTOCOpen } from '../../../actions/ui_actions'; import { setSelectedLayer } from '../../../actions/map_actions'; import { diff --git a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/toc_entry/index.js b/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/toc_entry/index.js index e9debdba7b91483..ececc5a90ab89b6 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/toc_entry/index.js +++ b/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/toc_entry/index.js @@ -7,7 +7,8 @@ import _ from 'lodash'; import { connect } from 'react-redux'; import { TOCEntry } from './view'; -import { FLYOUT_STATE } from '../../../../../reducers/ui'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { FLYOUT_STATE } from '../../../../../../../../../plugins/maps/public/reducers/ui.js'; import { updateFlyout, hideTOCDetails, showTOCDetails } from '../../../../../actions/ui_actions'; import { getIsReadOnly, getOpenTOCDetails } from '../../../../../selectors/ui_selectors'; import { diff --git a/x-pack/legacy/plugins/maps/public/embeddable/map_embeddable.js b/x-pack/legacy/plugins/maps/public/embeddable/map_embeddable.js index 5988a128232d607..650e827cc165628 100644 --- a/x-pack/legacy/plugins/maps/public/embeddable/map_embeddable.js +++ b/x-pack/legacy/plugins/maps/public/embeddable/map_embeddable.js @@ -19,7 +19,8 @@ import { esFilters } from '../../../../../../src/plugins/data/public'; import { I18nContext } from 'ui/i18n'; import { GisMap } from '../connected_components/gis_map'; -import { createMapStore } from '../reducers/store'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { createMapStore } from '../../../../../plugins/maps/public/reducers/store'; import { npStart } from 'ui/new_platform'; import { setGotoWithCenter, @@ -36,7 +37,11 @@ import { } from '../actions/map_actions'; import { setReadOnly, setIsLayerTOCOpen, setOpenTOCDetails } from '../actions/ui_actions'; import { getIsLayerTOCOpen, getOpenTOCDetails } from '../selectors/ui_selectors'; -import { getInspectorAdapters, setEventHandlers } from '../reducers/non_serializable_instances'; +import { + getInspectorAdapters, + setEventHandlers, + // eslint-disable-next-line @kbn/eslint/no-restricted-paths +} from '../../../../../plugins/maps/public/reducers/non_serializable_instances'; import { getMapCenter, getMapZoom, getHiddenLayerIds } from '../selectors/map_selectors'; import { MAP_SAVED_OBJECT_TYPE } from '../../common/constants'; diff --git a/x-pack/legacy/plugins/maps/public/embeddable/map_embeddable_factory.js b/x-pack/legacy/plugins/maps/public/embeddable/map_embeddable_factory.js index 73f222615493bfc..710b7f737e8610a 100644 --- a/x-pack/legacy/plugins/maps/public/embeddable/map_embeddable_factory.js +++ b/x-pack/legacy/plugins/maps/public/embeddable/map_embeddable_factory.js @@ -17,7 +17,8 @@ import { MapEmbeddable } from './map_embeddable'; import { indexPatternService } from '../kibana_services'; import { createMapPath, MAP_SAVED_OBJECT_TYPE, APP_ICON } from '../../common/constants'; -import { createMapStore } from '../reducers/store'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { createMapStore } from '../../../../../plugins/maps/public/reducers/store'; import { addLayerWithoutDataSync } from '../actions/map_actions'; import { getQueryableUniqueIndexPatternIds } from '../selectors/map_selectors'; import { getInitialLayers } from '../angular/get_initial_layers'; diff --git a/x-pack/legacy/plugins/maps/public/embeddable/merge_input_with_saved_map.js b/x-pack/legacy/plugins/maps/public/embeddable/merge_input_with_saved_map.js index 935747da9368708..8e3e0a9168e30ec 100644 --- a/x-pack/legacy/plugins/maps/public/embeddable/merge_input_with_saved_map.js +++ b/x-pack/legacy/plugins/maps/public/embeddable/merge_input_with_saved_map.js @@ -5,7 +5,8 @@ */ import _ from 'lodash'; -import { DEFAULT_IS_LAYER_TOC_OPEN } from '../reducers/ui'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { DEFAULT_IS_LAYER_TOC_OPEN } from '../../../../../plugins/maps/public/reducers/ui'; const MAP_EMBEDDABLE_INPUT_KEYS = [ 'hideFilterActions', diff --git a/x-pack/legacy/plugins/maps/public/layers/layer.js b/x-pack/legacy/plugins/maps/public/layers/layer.js index 71e5d7b95e44fd1..5c9532a3841f366 100644 --- a/x-pack/legacy/plugins/maps/public/layers/layer.js +++ b/x-pack/legacy/plugins/maps/public/layers/layer.js @@ -14,7 +14,8 @@ import { SOURCE_DATA_ID_ORIGIN, } from '../../common/constants'; import uuid from 'uuid/v4'; -import { copyPersistentState } from '../reducers/util'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { copyPersistentState } from '../../../../../plugins/maps/public/reducers/util.js'; import { i18n } from '@kbn/i18n'; export class AbstractLayer { diff --git a/x-pack/legacy/plugins/maps/public/layers/sources/es_source.js b/x-pack/legacy/plugins/maps/public/layers/sources/es_source.js index f575fd05c80613c..1552db277e609ed 100644 --- a/x-pack/legacy/plugins/maps/public/layers/sources/es_source.js +++ b/x-pack/legacy/plugins/maps/public/layers/sources/es_source.js @@ -16,7 +16,8 @@ import { timefilter } from 'ui/timefilter'; import _ from 'lodash'; import { i18n } from '@kbn/i18n'; import uuid from 'uuid/v4'; -import { copyPersistentState } from '../../reducers/util'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { copyPersistentState } from '../../../../../../plugins/maps/public/reducers/util'; import { ES_GEO_FIELD_TYPE } from '../../../common/constants'; import { DataRequestAbortError } from '../util/data_request'; import { expandToTileBoundaries } from './es_geo_grid_source/geo_tile_utils'; diff --git a/x-pack/legacy/plugins/maps/public/layers/sources/source.js b/x-pack/legacy/plugins/maps/public/layers/sources/source.js index 4fef52e731f9b25..b6b6c10831bb5d0 100644 --- a/x-pack/legacy/plugins/maps/public/layers/sources/source.js +++ b/x-pack/legacy/plugins/maps/public/layers/sources/source.js @@ -4,7 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { copyPersistentState } from '../../reducers/util'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { copyPersistentState } from '../../../../../../plugins/maps/public/reducers/util'; export class AbstractSource { static isIndexingSource = false; diff --git a/x-pack/legacy/plugins/maps/public/plugin.ts b/x-pack/legacy/plugins/maps/public/plugin.ts index c3f90d815239c8b..e2d1d432956466a 100644 --- a/x-pack/legacy/plugins/maps/public/plugin.ts +++ b/x-pack/legacy/plugins/maps/public/plugin.ts @@ -10,6 +10,8 @@ import { wrapInI18nContext } from 'ui/i18n'; // @ts-ignore import { MapListing } from './components/map_listing'; // @ts-ignore +import { setInjectedVarFunc } from '../../../../plugins/maps/public/kibana_services'; // eslint-disable-line @kbn/eslint/no-restricted-paths +// @ts-ignore import { setLicenseId, setInspector, setFileUpload } from './kibana_services'; import { HomePublicPluginSetup } from '../../../../../src/plugins/home/public'; import { LicensingPluginSetup } from '../../../../plugins/licensing/public'; @@ -33,9 +35,11 @@ interface MapsPluginSetupDependencies { export const bindSetupCoreAndPlugins = (core: CoreSetup, plugins: any) => { const { licensing } = plugins; + const { injectedMetadata } = core; if (licensing) { licensing.license$.subscribe(({ uid }: { uid: string }) => setLicenseId(uid)); } + setInjectedVarFunc(injectedMetadata.getInjectedVar); }; /** @internal */ @@ -53,7 +57,8 @@ export class MapsPlugin implements Plugin { } public start(core: CoreStart, plugins: any) { - setInspector(plugins.np.inspector); - setFileUpload(plugins.np.file_upload); + const { inspector, file_upload } = plugins.np; + setInspector(inspector); + setFileUpload(file_upload); } } diff --git a/x-pack/legacy/plugins/maps/public/selectors/map_selectors.js b/x-pack/legacy/plugins/maps/public/selectors/map_selectors.js index ab0926ab40070b3..e5eaf8870aa77fe 100644 --- a/x-pack/legacy/plugins/maps/public/selectors/map_selectors.js +++ b/x-pack/legacy/plugins/maps/public/selectors/map_selectors.js @@ -12,8 +12,13 @@ import { VectorLayer } from '../layers/vector_layer'; import { HeatmapLayer } from '../layers/heatmap_layer'; import { ALL_SOURCES } from '../layers/sources/all_sources'; import { timefilter } from 'ui/timefilter'; -import { getInspectorAdapters } from '../reducers/non_serializable_instances'; -import { copyPersistentState, TRACKED_LAYER_DESCRIPTOR } from '../reducers/util'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { getInspectorAdapters } from '../../../../../plugins/maps/public/reducers/non_serializable_instances'; +import { + copyPersistentState, + TRACKED_LAYER_DESCRIPTOR, + // eslint-disable-next-line @kbn/eslint/no-restricted-paths +} from '../../../../../plugins/maps/public/reducers/util'; import { InnerJoin } from '../layers/joins/inner_join'; function createLayerInstance(layerDescriptor, inspectorAdapters) { diff --git a/x-pack/legacy/plugins/maps/public/selectors/map_selectors.test.js b/x-pack/legacy/plugins/maps/public/selectors/map_selectors.test.js index 995030d024ddf3f..5ec40a57ebc7f40 100644 --- a/x-pack/legacy/plugins/maps/public/selectors/map_selectors.test.js +++ b/x-pack/legacy/plugins/maps/public/selectors/map_selectors.test.js @@ -9,7 +9,7 @@ jest.mock('../layers/heatmap_layer', () => {}); jest.mock('../layers/vector_tile_layer', () => {}); jest.mock('../layers/sources/all_sources', () => {}); jest.mock('../layers/joins/inner_join', () => {}); -jest.mock('../reducers/non_serializable_instances', () => ({ +jest.mock('../../../../../plugins/maps/public/reducers/non_serializable_instances', () => ({ getInspectorAdapters: () => { return {}; }, diff --git a/x-pack/plugins/maps/common/constants.ts b/x-pack/plugins/maps/common/constants.ts new file mode 100644 index 000000000000000..ae3e164ffb2bc1b --- /dev/null +++ b/x-pack/plugins/maps/common/constants.ts @@ -0,0 +1,188 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { i18n } from '@kbn/i18n'; +export const EMS_CATALOGUE_PATH = 'ems/catalogue'; + +export const EMS_FILES_CATALOGUE_PATH = 'ems/files'; +export const EMS_FILES_API_PATH = 'ems/files'; +export const EMS_FILES_DEFAULT_JSON_PATH = 'file'; +export const EMS_GLYPHS_PATH = 'fonts'; +export const EMS_SPRITES_PATH = 'sprites'; + +export const EMS_TILES_CATALOGUE_PATH = 'ems/tiles'; +export const EMS_TILES_API_PATH = 'ems/tiles'; +export const EMS_TILES_RASTER_STYLE_PATH = 'raster/style'; +export const EMS_TILES_RASTER_TILE_PATH = 'raster/tile'; + +export const EMS_TILES_VECTOR_STYLE_PATH = 'vector/style'; +export const EMS_TILES_VECTOR_SOURCE_PATH = 'vector/source'; +export const EMS_TILES_VECTOR_TILE_PATH = 'vector/tile'; + +export const MAP_SAVED_OBJECT_TYPE = 'map'; +export const APP_ID = 'maps'; +export const APP_ICON = 'gisApp'; +export const TELEMETRY_TYPE = 'maps-telemetry'; + +export const MAP_APP_PATH = `app/${APP_ID}`; +export const GIS_API_PATH = `api/${APP_ID}`; +export const INDEX_SETTINGS_API_PATH = `${GIS_API_PATH}/indexSettings`; + +export const MAP_BASE_URL = `/${MAP_APP_PATH}#/${MAP_SAVED_OBJECT_TYPE}`; + +export function createMapPath(id: string) { + return `${MAP_BASE_URL}/${id}`; +} + +export const LAYER_TYPE = { + TILE: 'TILE', + VECTOR: 'VECTOR', + VECTOR_TILE: 'VECTOR_TILE', + HEATMAP: 'HEATMAP', +}; + +export enum SORT_ORDER { + ASC = 'asc', + DESC = 'desc', +} + +export const EMS_TMS = 'EMS_TMS'; +export const EMS_FILE = 'EMS_FILE'; +export const ES_GEO_GRID = 'ES_GEO_GRID'; +export const ES_SEARCH = 'ES_SEARCH'; +export const ES_PEW_PEW = 'ES_PEW_PEW'; +export const EMS_XYZ = 'EMS_XYZ'; // identifies a custom TMS source. Name is a little unfortunate. + +export enum FIELD_ORIGIN { + SOURCE = 'source', + JOIN = 'join', +} + +export const SOURCE_DATA_ID_ORIGIN = 'source'; +export const META_ID_ORIGIN_SUFFIX = 'meta'; +export const SOURCE_META_ID_ORIGIN = `${SOURCE_DATA_ID_ORIGIN}_${META_ID_ORIGIN_SUFFIX}`; +export const FORMATTERS_ID_ORIGIN_SUFFIX = 'formatters'; +export const SOURCE_FORMATTERS_ID_ORIGIN = `${SOURCE_DATA_ID_ORIGIN}_${FORMATTERS_ID_ORIGIN_SUFFIX}`; + +export const GEOJSON_FILE = 'GEOJSON_FILE'; + +export const MIN_ZOOM = 0; +export const MAX_ZOOM = 24; + +export const DECIMAL_DEGREES_PRECISION = 5; // meters precision +export const ZOOM_PRECISION = 2; +export const DEFAULT_MAX_RESULT_WINDOW = 10000; +export const DEFAULT_MAX_INNER_RESULT_WINDOW = 100; +export const DEFAULT_MAX_BUCKETS_LIMIT = 10000; + +export const FEATURE_ID_PROPERTY_NAME = '__kbn__feature_id__'; +export const FEATURE_VISIBLE_PROPERTY_NAME = '__kbn_isvisibleduetojoin__'; + +export const MB_SOURCE_ID_LAYER_ID_PREFIX_DELIMITER = '_'; + +export const ES_GEO_FIELD_TYPE = { + GEO_POINT: 'geo_point', + GEO_SHAPE: 'geo_shape', +}; + +export const ES_SPATIAL_RELATIONS = { + INTERSECTS: 'INTERSECTS', + DISJOINT: 'DISJOINT', + WITHIN: 'WITHIN', +}; + +export const GEO_JSON_TYPE = { + POINT: 'Point', + MULTI_POINT: 'MultiPoint', + LINE_STRING: 'LineString', + MULTI_LINE_STRING: 'MultiLineString', + POLYGON: 'Polygon', + MULTI_POLYGON: 'MultiPolygon', + GEOMETRY_COLLECTION: 'GeometryCollection', +}; + +export const POLYGON_COORDINATES_EXTERIOR_INDEX = 0; +export const LON_INDEX = 0; +export const LAT_INDEX = 1; + +export const EMPTY_FEATURE_COLLECTION = { + type: 'FeatureCollection', + features: [], +}; + +export const DRAW_TYPE = { + BOUNDS: 'BOUNDS', + POLYGON: 'POLYGON', +}; + +export enum AGG_TYPE { + AVG = 'avg', + COUNT = 'count', + MAX = 'max', + MIN = 'min', + SUM = 'sum', + TERMS = 'terms', + UNIQUE_COUNT = 'cardinality', +} + +export enum RENDER_AS { + HEATMAP = 'heatmap', + POINT = 'point', + GRID = 'grid', +} + +export enum GRID_RESOLUTION { + COARSE = 'COARSE', + FINE = 'FINE', + MOST_FINE = 'MOST_FINE', +} + +export const TOP_TERM_PERCENTAGE_SUFFIX = '__percentage'; + +export const COUNT_PROP_LABEL = i18n.translate('xpack.maps.aggs.defaultCountLabel', { + defaultMessage: 'count', +}); + +export const COUNT_PROP_NAME = 'doc_count'; + +export const STYLE_TYPE = { + STATIC: 'STATIC', + DYNAMIC: 'DYNAMIC', +}; + +export const LAYER_STYLE_TYPE = { + VECTOR: 'VECTOR', + HEATMAP: 'HEATMAP', +}; + +export const COLOR_MAP_TYPE = { + CATEGORICAL: 'CATEGORICAL', + ORDINAL: 'ORDINAL', +}; + +export const COLOR_PALETTE_MAX_SIZE = 10; + +export const CATEGORICAL_DATA_TYPES = ['string', 'ip', 'boolean']; +export const ORDINAL_DATA_TYPES = ['number', 'date']; + +export enum SYMBOLIZE_AS_TYPES { + CIRCLE = 'circle', + ICON = 'icon', +} + +export enum LABEL_BORDER_SIZES { + NONE = 'NONE', + SMALL = 'SMALL', + MEDIUM = 'MEDIUM', + LARGE = 'LARGE', +} + +export const DEFAULT_ICON = 'airfield'; diff --git a/x-pack/plugins/maps/common/i18n_getters.ts b/x-pack/plugins/maps/common/i18n_getters.ts new file mode 100644 index 000000000000000..0008a119f1c7cce --- /dev/null +++ b/x-pack/plugins/maps/common/i18n_getters.ts @@ -0,0 +1,52 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { i18n } from '@kbn/i18n'; + +import { $Values } from '@kbn/utility-types'; +import { ES_SPATIAL_RELATIONS } from './constants'; + +export function getAppTitle() { + return i18n.translate('xpack.maps.appTitle', { + defaultMessage: 'Maps', + }); +} + +export function getDataSourceLabel() { + return i18n.translate('xpack.maps.source.dataSourceLabel', { + defaultMessage: 'Data source', + }); +} + +export function getUrlLabel() { + return i18n.translate('xpack.maps.source.urlLabel', { + defaultMessage: 'Url', + }); +} + +export function getEsSpatialRelationLabel(spatialRelation: $Values) { + switch (spatialRelation) { + case ES_SPATIAL_RELATIONS.INTERSECTS: + return i18n.translate('xpack.maps.common.esSpatialRelation.intersectsLabel', { + defaultMessage: 'intersects', + }); + case ES_SPATIAL_RELATIONS.DISJOINT: + return i18n.translate('xpack.maps.common.esSpatialRelation.disjointLabel', { + defaultMessage: 'disjoint', + }); + case ES_SPATIAL_RELATIONS.WITHIN: + return i18n.translate('xpack.maps.common.esSpatialRelation.withinLabel', { + defaultMessage: 'within', + }); + // @ts-ignore + case ES_SPATIAL_RELATIONS.CONTAINS: + return i18n.translate('xpack.maps.common.esSpatialRelation.containsLabel', { + defaultMessage: 'contains', + }); + default: + return spatialRelation; + } +} diff --git a/x-pack/plugins/maps/common/parse_xml_string.js b/x-pack/plugins/maps/common/parse_xml_string.js new file mode 100644 index 000000000000000..9d95e0e78280d52 --- /dev/null +++ b/x-pack/plugins/maps/common/parse_xml_string.js @@ -0,0 +1,22 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { parseString } from 'xml2js'; + +// promise based wrapper around parseString +export async function parseXmlString(xmlString) { + const parsePromise = new Promise((resolve, reject) => { + parseString(xmlString, (error, result) => { + if (error) { + reject(error); + } else { + resolve(result); + } + }); + }); + + return await parsePromise; +} diff --git a/x-pack/legacy/plugins/maps/common/parse_xml_string.test.js b/x-pack/plugins/maps/common/parse_xml_string.test.js similarity index 100% rename from x-pack/legacy/plugins/maps/common/parse_xml_string.test.js rename to x-pack/plugins/maps/common/parse_xml_string.test.js diff --git a/x-pack/plugins/maps/kibana.json b/x-pack/plugins/maps/kibana.json new file mode 100644 index 000000000000000..b2aec30c113eb67 --- /dev/null +++ b/x-pack/plugins/maps/kibana.json @@ -0,0 +1,8 @@ +{ + "id": "maps", + "version": "8.0.0", + "kibanaVersion": "kibana", + "configPath": ["xpack", "maps"], + "requiredPlugins": ["inspector"], + "ui": true +} diff --git a/x-pack/plugins/maps/public/actions/map_actions.js b/x-pack/plugins/maps/public/actions/map_actions.js new file mode 100644 index 000000000000000..13cb3d5f898601a --- /dev/null +++ b/x-pack/plugins/maps/public/actions/map_actions.js @@ -0,0 +1,47 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const SET_SELECTED_LAYER = 'SET_SELECTED_LAYER'; +export const SET_TRANSIENT_LAYER = 'SET_TRANSIENT_LAYER'; +export const UPDATE_LAYER_ORDER = 'UPDATE_LAYER_ORDER'; +export const ADD_LAYER = 'ADD_LAYER'; +export const SET_LAYER_ERROR_STATUS = 'SET_LAYER_ERROR_STATUS'; +export const ADD_WAITING_FOR_MAP_READY_LAYER = 'ADD_WAITING_FOR_MAP_READY_LAYER'; +export const CLEAR_WAITING_FOR_MAP_READY_LAYER_LIST = 'CLEAR_WAITING_FOR_MAP_READY_LAYER_LIST'; +export const REMOVE_LAYER = 'REMOVE_LAYER'; +export const SET_LAYER_VISIBILITY = 'SET_LAYER_VISIBILITY'; +export const MAP_EXTENT_CHANGED = 'MAP_EXTENT_CHANGED'; +export const MAP_READY = 'MAP_READY'; +export const MAP_DESTROYED = 'MAP_DESTROYED'; +export const LAYER_DATA_LOAD_STARTED = 'LAYER_DATA_LOAD_STARTED'; +export const LAYER_DATA_LOAD_ENDED = 'LAYER_DATA_LOAD_ENDED'; +export const LAYER_DATA_LOAD_ERROR = 'LAYER_DATA_LOAD_ERROR'; +export const UPDATE_SOURCE_DATA_REQUEST = 'UPDATE_SOURCE_DATA_REQUEST'; +export const SET_JOINS = 'SET_JOINS'; +export const SET_QUERY = 'SET_QUERY'; +export const TRIGGER_REFRESH_TIMER = 'TRIGGER_REFRESH_TIMER'; +export const UPDATE_LAYER_PROP = 'UPDATE_LAYER_PROP'; +export const UPDATE_LAYER_STYLE = 'UPDATE_LAYER_STYLE'; +export const SET_LAYER_STYLE_META = 'SET_LAYER_STYLE_META'; +export const UPDATE_SOURCE_PROP = 'UPDATE_SOURCE_PROP'; +export const SET_REFRESH_CONFIG = 'SET_REFRESH_CONFIG'; +export const SET_MOUSE_COORDINATES = 'SET_MOUSE_COORDINATES'; +export const CLEAR_MOUSE_COORDINATES = 'CLEAR_MOUSE_COORDINATES'; +export const SET_GOTO = 'SET_GOTO'; +export const CLEAR_GOTO = 'CLEAR_GOTO'; +export const TRACK_CURRENT_LAYER_STATE = 'TRACK_CURRENT_LAYER_STATE'; +export const ROLLBACK_TO_TRACKED_LAYER_STATE = 'ROLLBACK_TO_TRACKED_LAYER_STATE'; +export const REMOVE_TRACKED_LAYER_STATE = 'REMOVE_TRACKED_LAYER_STATE'; +export const SET_OPEN_TOOLTIPS = 'SET_OPEN_TOOLTIPS'; +export const UPDATE_DRAW_STATE = 'UPDATE_DRAW_STATE'; +export const SET_SCROLL_ZOOM = 'SET_SCROLL_ZOOM'; +export const SET_MAP_INIT_ERROR = 'SET_MAP_INIT_ERROR'; +export const SET_INTERACTIVE = 'SET_INTERACTIVE'; +export const DISABLE_TOOLTIP_CONTROL = 'DISABLE_TOOLTIP_CONTROL'; +export const HIDE_TOOLBAR_OVERLAY = 'HIDE_TOOLBAR_OVERLAY'; +export const HIDE_LAYER_CONTROL = 'HIDE_LAYER_CONTROL'; +export const HIDE_VIEW_CONTROL = 'HIDE_VIEW_CONTROL'; +export const SET_WAITING_FOR_READY_HIDDEN_LAYERS = 'SET_WAITING_FOR_READY_HIDDEN_LAYERS'; diff --git a/x-pack/plugins/maps/public/actions/ui_actions.js b/x-pack/plugins/maps/public/actions/ui_actions.js new file mode 100644 index 000000000000000..59ae56c15056a0e --- /dev/null +++ b/x-pack/plugins/maps/public/actions/ui_actions.js @@ -0,0 +1,16 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const UPDATE_FLYOUT = 'UPDATE_FLYOUT'; +export const CLOSE_SET_VIEW = 'CLOSE_SET_VIEW'; +export const OPEN_SET_VIEW = 'OPEN_SET_VIEW'; +export const SET_IS_LAYER_TOC_OPEN = 'SET_IS_LAYER_TOC_OPEN'; +export const SET_FULL_SCREEN = 'SET_FULL_SCREEN'; +export const SET_READ_ONLY = 'SET_READ_ONLY'; +export const SET_OPEN_TOC_DETAILS = 'SET_OPEN_TOC_DETAILS'; +export const SHOW_TOC_DETAILS = 'SHOW_TOC_DETAILS'; +export const HIDE_TOC_DETAILS = 'HIDE_TOC_DETAILS'; +export const UPDATE_INDEXING_STAGE = 'UPDATE_INDEXING_STAGE'; diff --git a/x-pack/plugins/maps/public/index.ts b/x-pack/plugins/maps/public/index.ts new file mode 100644 index 000000000000000..c465700a4f9c563 --- /dev/null +++ b/x-pack/plugins/maps/public/index.ts @@ -0,0 +1,12 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { PluginInitializer } from 'kibana/public'; +import { MapsPlugin, MapsPluginSetup, MapsPluginStart } from './plugin'; + +export const plugin: PluginInitializer = () => { + return new MapsPlugin(); +}; diff --git a/x-pack/legacy/plugins/maps/public/inspector/adapters/map_adapter.js b/x-pack/plugins/maps/public/inspector/adapters/map_adapter.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/inspector/adapters/map_adapter.js rename to x-pack/plugins/maps/public/inspector/adapters/map_adapter.js diff --git a/x-pack/legacy/plugins/maps/public/inspector/views/map_details.js b/x-pack/plugins/maps/public/inspector/views/map_details.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/inspector/views/map_details.js rename to x-pack/plugins/maps/public/inspector/views/map_details.js diff --git a/x-pack/legacy/plugins/maps/public/inspector/views/map_view.js b/x-pack/plugins/maps/public/inspector/views/map_view.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/inspector/views/map_view.js rename to x-pack/plugins/maps/public/inspector/views/map_view.js diff --git a/x-pack/legacy/plugins/maps/public/inspector/views/register_views.ts b/x-pack/plugins/maps/public/kibana_services.js similarity index 58% rename from x-pack/legacy/plugins/maps/public/inspector/views/register_views.ts rename to x-pack/plugins/maps/public/kibana_services.js index 59c059566830070..1073e44fa711e74 100644 --- a/x-pack/legacy/plugins/maps/public/inspector/views/register_views.ts +++ b/x-pack/plugins/maps/public/kibana_services.js @@ -4,9 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ -import { npSetup } from 'ui/new_platform'; - -// @ts-ignore -import { MapView } from './map_view'; - -npSetup.plugins.inspector.registerView(MapView); +let getInjectedVar; +export const setInjectedVarFunc = getInjectedVarFunc => (getInjectedVar = getInjectedVarFunc); +export const getInjectedVarFunc = () => getInjectedVar; diff --git a/x-pack/plugins/maps/public/plugin.ts b/x-pack/plugins/maps/public/plugin.ts new file mode 100644 index 000000000000000..506b0c426f0fae8 --- /dev/null +++ b/x-pack/plugins/maps/public/plugin.ts @@ -0,0 +1,40 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { Plugin, CoreSetup, CoreStart } from 'src/core/public'; +import { Setup as InspectorSetupContract } from 'src/plugins/inspector/public'; +// @ts-ignore +import { MapView } from './inspector/views/map_view'; + +export interface MapsPluginSetupDependencies { + inspector: InspectorSetupContract; +} +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface MapsPluginStartDependencies {} + +/** + * These are the interfaces with your public contracts. You should export these + * for other plugins to use in _their_ `SetupDeps`/`StartDeps` interfaces. + * @public + */ +export type MapsPluginSetup = ReturnType; +export type MapsPluginStart = ReturnType; + +/** @internal */ +export class MapsPlugin + implements + Plugin< + MapsPluginSetup, + MapsPluginStart, + MapsPluginSetupDependencies, + MapsPluginStartDependencies + > { + public setup(core: CoreSetup, plugins: MapsPluginSetupDependencies) { + plugins.inspector.registerView(MapView); + } + + public start(core: CoreStart, plugins: any) {} +} diff --git a/x-pack/legacy/plugins/maps/public/reducers/map.js b/x-pack/plugins/maps/public/reducers/map.js similarity index 97% rename from x-pack/legacy/plugins/maps/public/reducers/map.js rename to x-pack/plugins/maps/public/reducers/map.js index 7e81fb03dd85be6..7e07569b44b830a 100644 --- a/x-pack/legacy/plugins/maps/public/reducers/map.js +++ b/x-pack/plugins/maps/public/reducers/map.js @@ -25,7 +25,6 @@ import { UPDATE_LAYER_STYLE, SET_LAYER_STYLE_META, SET_JOINS, - TOUCH_LAYER, UPDATE_SOURCE_PROP, SET_REFRESH_CONFIG, TRIGGER_REFRESH_TIMER, @@ -202,17 +201,6 @@ export function map(state = INITIAL_STATE, action) { return updateWithDataResponse(state, action); case LAYER_DATA_LOAD_ENDED: return updateWithDataResponse(state, action); - case TOUCH_LAYER: - //action to enforce a reflow of the styles - const layer = state.layerList.find(layer => layer.id === action.layerId); - if (!layer) { - return state; - } - const indexOfLayer = state.layerList.indexOf(layer); - const newLayer = { ...layer }; - const newLayerList = [...state.layerList]; - newLayerList[indexOfLayer] = newLayer; - return { ...state, layerList: newLayerList }; case MAP_READY: return { ...state, ready: true }; case MAP_DESTROYED: diff --git a/x-pack/legacy/plugins/maps/public/reducers/map.test.js b/x-pack/plugins/maps/public/reducers/map.test.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/reducers/map.test.js rename to x-pack/plugins/maps/public/reducers/map.test.js diff --git a/x-pack/legacy/plugins/maps/public/reducers/non_serializable_instances.js b/x-pack/plugins/maps/public/reducers/non_serializable_instances.js similarity index 90% rename from x-pack/legacy/plugins/maps/public/reducers/non_serializable_instances.js rename to x-pack/plugins/maps/public/reducers/non_serializable_instances.js index c7de2beff0cf6a0..8265c70ae180011 100644 --- a/x-pack/legacy/plugins/maps/public/reducers/non_serializable_instances.js +++ b/x-pack/plugins/maps/public/reducers/non_serializable_instances.js @@ -4,9 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import chrome from 'ui/chrome'; -import { RequestAdapter } from '../../../../../../src/plugins/inspector/public'; +import { RequestAdapter } from '../../../../../src/plugins/inspector/common/adapters/request'; import { MapAdapter } from '../inspector/adapters/map_adapter'; +import { getInjectedVarFunc } from '../kibana_services'; const REGISTER_CANCEL_CALLBACK = 'REGISTER_CANCEL_CALLBACK'; const UNREGISTER_CANCEL_CALLBACK = 'UNREGISTER_CANCEL_CALLBACK'; @@ -16,7 +16,8 @@ function createInspectorAdapters() { const inspectorAdapters = { requests: new RequestAdapter(), }; - if (chrome.getInjected('showMapsInspectorAdapter', false)) { + const getInjectedVar = getInjectedVarFunc(); + if (getInjectedVar && getInjectedVar('showMapsInspectorAdapter', false)) { inspectorAdapters.map = new MapAdapter(); } return inspectorAdapters; diff --git a/x-pack/legacy/plugins/maps/public/reducers/store.js b/x-pack/plugins/maps/public/reducers/store.js similarity index 81% rename from x-pack/legacy/plugins/maps/public/reducers/store.js rename to x-pack/plugins/maps/public/reducers/store.js index 40b769f11b52922..b5c4bb435e7256d 100644 --- a/x-pack/legacy/plugins/maps/public/reducers/store.js +++ b/x-pack/plugins/maps/public/reducers/store.js @@ -10,15 +10,13 @@ import { ui } from './ui'; import { map } from './map'; import { nonSerializableInstances } from './non_serializable_instances'; -const rootReducer = combineReducers({ - map, - ui, - nonSerializableInstances, -}); - -const enhancers = [applyMiddleware(thunk)]; - export function createMapStore() { + const enhancers = [applyMiddleware(thunk)]; + const rootReducer = combineReducers({ + map, + ui, + nonSerializableInstances, + }); const storeConfig = {}; return createStore(rootReducer, storeConfig, compose(...enhancers)); } diff --git a/x-pack/legacy/plugins/maps/public/reducers/ui.js b/x-pack/plugins/maps/public/reducers/ui.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/reducers/ui.js rename to x-pack/plugins/maps/public/reducers/ui.js diff --git a/x-pack/legacy/plugins/maps/public/reducers/util.js b/x-pack/plugins/maps/public/reducers/util.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/reducers/util.js rename to x-pack/plugins/maps/public/reducers/util.js diff --git a/x-pack/legacy/plugins/maps/public/reducers/util.test.js b/x-pack/plugins/maps/public/reducers/util.test.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/reducers/util.test.js rename to x-pack/plugins/maps/public/reducers/util.test.js