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] Move redux reducers and store logic to NP #58294

Merged
merged 33 commits into from
Mar 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
06dec30
Plugin file and services in place. Some redux logic ported
Feb 12, 2020
a84f38a
Port and update index pattern util
Feb 12, 2020
86e499f
Move reducers over to NP. Update refs in legacy
Feb 14, 2020
bbcf6b6
Port inspector to NP
Feb 14, 2020
2fd29f3
Move some kibana services init to NP. Some cleaning
Feb 14, 2020
aa1a8a0
Clean up work not related to reducers/store
Feb 21, 2020
d36c67f
Merge remote-tracking branch 'upstream/master' into np-port-reducers-…
Feb 24, 2020
e127a90
Ignore temp imports from NP. Clean up of changes unrelated to this PR
Feb 24, 2020
6942fc2
More cleanup. Check injected vars avab. before calling to handle dash…
Feb 24, 2020
526d8f2
Merge remote-tracking branch 'upstream/master' into np-port-reducers-…
Feb 26, 2020
9c2e748
Bind embeddables services the same way Maps app services bound. Creat…
Mar 2, 2020
171fe6c
Merge remote-tracking branch 'upstream/master' into np-port-reducers-…
Mar 2, 2020
fd96c70
Call binding from constructor. Fix npStart plugins arg
Mar 3, 2020
36e1d31
Merge remote-tracking branch 'upstream/master' into np-port-reducers-…
Mar 3, 2020
eec53c5
Adapt changes from master
Mar 4, 2020
21973cd
Merge remote-tracking branch 'upstream/master' into np-port-reducers-…
Mar 4, 2020
b2ad8a2
Register inspector views for embeddable. Add NP folder to i18n
Mar 4, 2020
fd4f9ee
Merge remote-tracking branch 'upstream/master' into np-port-reducers-…
Mar 4, 2020
a4b34d3
Clean up. Add comments. Move inspector map view registration to NP
Mar 4, 2020
2151af4
Remove unused inspector files in legacy
Mar 4, 2020
6f0953c
Merge remote-tracking branch 'upstream/master' into np-port-reducers-…
Mar 5, 2020
0db88ee
Move full screen action to legacy
Mar 5, 2020
801c694
Merge remote-tracking branch 'upstream/master' into np-port-reducers-…
Mar 5, 2020
bd06f66
Add in missing tooltip updates
Mar 5, 2020
6c815d9
Review feedback. Update constants and i18n_getters to latest in NP
Mar 6, 2020
a148b8e
Merge remote-tracking branch 'upstream/master' into np-port-reducers-…
Mar 6, 2020
13d78b7
Review feedback. Add redundancy comments to common files redundant in…
Mar 6, 2020
bd502fc
Merge remote-tracking branch 'upstream/master' into np-port-reducers-…
Mar 10, 2020
2f0c550
Merge remote-tracking branch 'upstream/master' into np-port-reducers-…
Mar 11, 2020
02f396a
Remove unneeded copy of parse xml string test in legacy
Mar 11, 2020
ab35a74
Merge remote-tracking branch 'upstream/master' into np-port-reducers-…
Mar 11, 2020
25ec8f1
Review feedback. Remove redundant portions. Export from NP where poss…
Mar 11, 2020
86d9b41
Remove remaining refernce and case for 'TOUCH_LAYER'. It's never used
Mar 11, 2020
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 x-pack/.i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
178 changes: 2 additions & 176 deletions x-pack/legacy/plugins/maps/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
48 changes: 2 additions & 46 deletions x-pack/legacy/plugins/maps/common/i18n_getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof ES_SPATIAL_RELATIONS>) {
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';
18 changes: 2 additions & 16 deletions x-pack/legacy/plugins/maps/common/parse_xml_string.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
1 change: 0 additions & 1 deletion x-pack/legacy/plugins/maps/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
94 changes: 50 additions & 44 deletions x-pack/legacy/plugins/maps/public/actions/map_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,62 +20,68 @@ 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,
LAYER_TYPE,
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 {
Expand Down
Loading