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] Add layer edit controls #99812

Merged
merged 123 commits into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
5f8aa18
Placeholder feature edit control in place
Mar 26, 2021
2cbd6b0
Merge remote-tracking branch 'upstream/master' into shape-drawing-ui
Mar 31, 2021
a80038a
Placeholder menu added
Mar 31, 2021
26ec7bf
Redux integrated
Apr 1, 2021
8ca809a
Single shape drawing
Apr 1, 2021
f9eeb95
Merge remote-tracking branch 'upstream/master' into shape-drawing-ui
Apr 1, 2021
b8eea96
Keep draw mode active
Apr 2, 2021
b4f3af0
Trigger editing through add layer wizard
Apr 5, 2021
001c87f
Add index checking utils
Apr 5, 2021
95f8f14
Connect error checking
Apr 5, 2021
2de30ec
Conditionally show edit toolbar
Apr 5, 2021
92e17aa
Connect missing shapes. Some clean up
Apr 5, 2021
143b24a
Track features and index name in store
Apr 5, 2021
e129539
Connect add layer button enablement
Apr 6, 2021
9c5ca16
Connect persistence utils
Apr 6, 2021
423e3aa
Dispatch clearing action
Apr 6, 2021
f238ccb
Full roundtrip w/ settings showing. Moved async calls to component
Apr 6, 2021
d450fd1
Adjust addLayer call for async
Apr 7, 2021
3d7ad76
Merge remote-tracking branch 'upstream/master' into shape-drawing-ui
Apr 7, 2021
b12ad85
Add edit controls
Apr 7, 2021
576b3d3
Fix deleting functionality to update store
Apr 7, 2021
cd211f9
Add toggle color to buttons. Fall back to edit between drawings
Apr 8, 2021
4f79738
Deselect features still selected when entering trash mode
Apr 8, 2021
ceae6d2
Add geometry check to filter out invalid geometries
Apr 8, 2021
bee0fd5
Clear out old drawing data on cancel. Update action names
Apr 8, 2021
3725859
Add circle drawing button
Apr 8, 2021
5200165
Add tools show on map with cancel. Not completely connected to add la…
Apr 12, 2021
2087b70
Merge remote-tracking branch 'upstream/master' into shape-drawing-ui
Apr 12, 2021
33080d1
Merge remote-tracking branch 'upstream/master' into shape-drawing-ui
Apr 15, 2021
87cdb31
Pull out unneeded pieces. Add in common utils
Apr 15, 2021
5cf1aa9
Draw tool switch logic
Apr 20, 2021
81ba1e7
Set map draw control selectively when filters or drawing active
Apr 20, 2021
1f3a19b
Update draw tools appearance to be in line with other tools
Apr 21, 2021
216258e
Fix popover and cancel button appear/disappear behaviors
Apr 21, 2021
f1f25a9
Only allow adding points for geo_point indexes and shapes for geo_shape
Apr 21, 2021
dfd7728
Merge remote-tracking branch 'upstream/master' into draw-controls-ui
May 5, 2021
d683bd4
Init shape drawing from filter menu
May 5, 2021
f97e74f
Delete edit controls. Connect cancel button and remaining logic to ne…
May 5, 2021
8086701
Add back deactivation on popover close for filter layers
May 5, 2021
debdb62
Convert geom filter form to ts. Activate filter mode on filter forms …
May 6, 2021
3f44186
Combine handling of draw state and draw mode for filters and feature …
May 10, 2021
7fdd380
Add popover title placeholder
May 10, 2021
00ab783
Organize filter vs. feature modes. Replace old filter check logic
May 10, 2021
d79d4f6
Create selector for shape being drawn
May 10, 2021
9d85c81
Clean up
May 10, 2021
90c8d3d
Show index pattern id (for now) and geo field in tooltip. Fill in mis…
May 10, 2021
5a39c41
Add pieces for feature persistence w/ placeholder content
May 11, 2021
6508d71
Writing to index connected
May 11, 2021
aea42da
Delete shapes when done. Add sync layers call
May 11, 2021
c7acf67
Fix issue with point geometries. Add force refresh flag so features a…
May 11, 2021
d89c810
Check draw tool exists before delete
May 12, 2021
849ba8e
Add refresh to index call to prevent shapes from not getting drawn af…
May 12, 2021
4771f70
Merge remote-tracking branch 'upstream/master' into draw-controls-ui
May 12, 2021
ad72af1
Remove unused feature edit controls. Fix typing on geometry
May 12, 2021
f5c6555
Add route to find matching indexes for a pattern. Not connected and u…
May 12, 2021
05f40e3
Merge remote-tracking branch 'upstream/master' into draw-controls-ui
May 17, 2021
6ddef3a
Revise feature editing to be initiated from layer toc (index persiste…
May 17, 2021
0efb857
Indexing connected
May 17, 2021
a8b21d3
Detangle filters and feature drawing. Add drawing exit button
May 18, 2021
6c31b48
Show current layer in edit mode in TOC
May 18, 2021
ce1d62e
Edit styling adjustments. Add source editable check function. Misc.
May 18, 2021
4fe3b94
Add checks for editability
May 18, 2021
3346a2a
Adjust conditions for showing feature editing
May 20, 2021
70b2d97
Connect shape/point modes. Fix issue with on draw callback not gettin…
May 20, 2021
96b3c9d
Clean up
Jun 1, 2021
f4b8c43
Merge remote-tracking branch 'upstream/master' into draw-controls-ui
Jun 1, 2021
aa3edca
Add back logic to activate feature draw control. Update logic to be s…
Jun 1, 2021
a22f058
Editable check fixes and updates
Jun 1, 2021
dd6def5
Add forceRefresh flag to data request context
Jun 1, 2021
fd0a187
Review feedback. Add addFeature methods to vector layer and es search…
Jun 1, 2021
2e9a931
Differentiate between edit capability and enablement
Jun 2, 2021
8e78142
Allow edits on blended layers if clustering not enabled
Jun 2, 2021
7bb8f27
Type fixes
Jun 2, 2021
367480c
Merge remote-tracking branch 'upstream/master' into draw-controls-ui
Jun 3, 2021
69ffe2d
i18n fixes
Jun 3, 2021
1760b38
i18n translations
Jun 3, 2021
836ed62
Fix import path
Jun 3, 2021
33e8a13
eslint
Jun 3, 2021
d2e1c47
Type fixes
Jun 3, 2021
a57a65f
Update snapshot
Jun 3, 2021
44ac82b
Clean up snapshots
Jun 3, 2021
9176926
Lots of clean up
Jun 3, 2021
80554f5
Snapshot updates, eslint fix
Jun 4, 2021
af8c47a
Prevent tooltips from popping up while drawing over other layers
Jun 4, 2021
420f6b8
Use new svg icons for toolbar
Jun 4, 2021
6e36f3f
Put edit features behind feature flag
Jun 4, 2021
4b81f4d
Disable filters when feature editing active
Jun 4, 2021
4c1e1af
Disable draw mode on add layer flyout opened
Jun 4, 2021
fdc22e7
Do config check at the layer level instead of in TOC
Jun 4, 2021
3f8d181
Merge remote-tracking branch 'upstream/master' into draw-controls-ui
Jun 7, 2021
8c3a228
Review feedback
Jun 8, 2021
902fe04
Review feedback. Draw mode handling improvements
Jun 8, 2021
7e73334
Review feedback. Move editable checks down a level from top level lay…
Jun 8, 2021
5295881
Update editable flag to be DataRequest
Jun 8, 2021
97d07ab
Merge remote-tracking branch 'upstream/master' into draw-controls-ui
Jun 8, 2021
2080576
Merge remote-tracking branch 'upstream/master' into draw-controls-ui
Jun 8, 2021
cfec136
Review feedback. Clean up endpoint. Clean up & update editable checks
Jun 9, 2021
0bd9cfb
Type fixes
Jun 9, 2021
794ba6b
Merge remote-tracking branch 'upstream/master' into draw-controls-ui
Jun 9, 2021
a4fe347
Add functional tests for index pattern matching endpoint
Jun 9, 2021
bd6c2f9
Remove unneeded function
Jun 9, 2021
5c15ccf
Update functional test
Jun 9, 2021
a800062
Disable draw mode when adjusting layer settings
Jun 9, 2021
a198ecc
Prevent occasional error on startup where dataRequest > getData retur…
Jun 9, 2021
f1dabb0
Review feedback. Clean up, optimizations
Jun 10, 2021
db6c6fc
Merge remote-tracking branch 'upstream/master' into draw-controls-ui
Jun 10, 2021
8e54e39
Fix imports bungled during move
Jun 10, 2021
f79df81
Update jest test paths and snapshot locations
Jun 10, 2021
8c77c4e
Merge remote-tracking branch 'upstream/master' into draw-controls-ui
Jun 14, 2021
aba98cc
Review feedback. Update onDraw callback to be single function with 2 …
Jun 14, 2021
502be44
Merge remote-tracking branch 'upstream/master' into draw-controls-ui
Jun 15, 2021
b2569ee
Review feedback. Clean up draw control
Jun 15, 2021
c9a5ec1
Merge remote-tracking branch 'upstream/master' into draw-controls-ui
Jun 15, 2021
19e8186
Review feedback. Update edit state handling. Disable tools button on …
Jun 15, 2021
40d38ef
Add snapshot tests, test fixes, misc. updates
Jun 16, 2021
95e97c1
Updating icons and toolbar styles
miukimiu Jun 16, 2021
e177150
merging latest branch changes
miukimiu Jun 16, 2021
f1a87b1
Merge remote-tracking branch 'upstream/master' into draw-controls-ui
Jun 16, 2021
a9311dd
TOC Entry Actions popover clean up. Var naming updates
Jun 16, 2021
3be71a5
Remove unneeded test props, label wording update, test snapshot updates
Jun 16, 2021
7e78b38
Type fix. Cast getSyncMeta result to ESSearchSourceSyncMeta
Jun 16, 2021
9f365f7
Rename editModeEnabled -> canEditFeatures
Jun 16, 2021
81da28a
Update jest test snapshot
Jun 17, 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
16 changes: 14 additions & 2 deletions x-pack/plugins/maps/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ export const GIS_API_PATH = `api/${APP_ID}`;
export const INDEX_SETTINGS_API_PATH = `${GIS_API_PATH}/indexSettings`;
export const FONTS_API_PATH = `${GIS_API_PATH}/fonts`;
export const INDEX_SOURCE_API_PATH = `${GIS_API_PATH}/docSource`;
export const INDEX_FEATURE_PATH = `/${GIS_API_PATH}/feature`;
export const API_ROOT_PATH = `/${GIS_API_PATH}`;
export const INDEX_FEATURE_PATH = `/${GIS_API_PATH}/feature`;
export const GET_MATCHING_INDEXES_PATH = `/${GIS_API_PATH}/getMatchingIndexes`;

export const MVT_GETTILE_API_PATH = 'mvt/getTile';
export const MVT_GETGRIDTILE_API_PATH = 'mvt/getGridTile';
Expand Down Expand Up @@ -106,6 +107,7 @@ export const SOURCE_DATA_REQUEST_ID = 'source';
export const SOURCE_META_DATA_REQUEST_ID = `${SOURCE_DATA_REQUEST_ID}_${META_DATA_REQUEST_ID_SUFFIX}`;
export const SOURCE_FORMATTERS_DATA_REQUEST_ID = `${SOURCE_DATA_REQUEST_ID}_${FORMATTERS_DATA_REQUEST_ID_SUFFIX}`;
export const SOURCE_BOUNDS_DATA_REQUEST_ID = `${SOURCE_DATA_REQUEST_ID}_bounds`;
export const IS_EDITABLE_REQUEST_ID = 'isEditable';

export const MIN_ZOOM = 0;
export const MAX_ZOOM = 24;
Expand Down Expand Up @@ -154,10 +156,20 @@ export const EMPTY_FEATURE_COLLECTION: FeatureCollection = {
features: [],
};

export enum DRAW_TYPE {
export enum DRAW_MODE {
DRAW_SHAPES = 'DRAW_SHAPES',
DRAW_POINTS = 'DRAW_POINTS',
DRAW_FILTERS = 'DRAW_FILTERS',
NONE = 'NONE',
}

export enum DRAW_SHAPE {
BOUNDS = 'BOUNDS',
DISTANCE = 'DISTANCE',
POLYGON = 'POLYGON',
POINT = 'POINT',
LINE = 'LINE',
SIMPLE_SELECT = 'SIMPLE_SELECT',
}

export const AGG_DELIMITER = '_of_';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ export type MapFilters = {
timeFilters: TimeRange;
timeslice?: Timeslice;
zoom: number;
isReadOnly: boolean;
};

type ESSearchSourceSyncMeta = {
export type ESSearchSourceSyncMeta = {
filterByMapBounds: boolean;
sortField: string;
sortOrder: SortDirection;
Expand Down
9 changes: 7 additions & 2 deletions x-pack/plugins/maps/common/descriptor_types/map_descriptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ReactNode } from 'react';
import { GeoJsonProperties } from 'geojson';
import { Geometry } from 'geojson';
import { Query } from '../../../../../src/plugins/data/common';
import { DRAW_TYPE, ES_SPATIAL_RELATIONS } from '../constants';
import { DRAW_SHAPE, ES_SPATIAL_RELATIONS } from '../constants';

export type MapExtent = {
minLon: number;
Expand Down Expand Up @@ -63,8 +63,13 @@ export type TooltipState = {

export type DrawState = {
kindsun marked this conversation as resolved.
Show resolved Hide resolved
actionId: string;
drawType: DRAW_TYPE;
drawShape?: DRAW_SHAPE;
filterLabel?: string; // point radius filter alias
geometryLabel?: string;
relation?: ES_SPATIAL_RELATIONS;
};

export type EditState = {
layerId: string;
drawShape?: DRAW_SHAPE;
};
6 changes: 6 additions & 0 deletions x-pack/plugins/maps/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ export interface CreateDocSourceResp {
error?: Error;
}

export interface MatchingIndexesResp {
matchingIndexes?: string[];
success: boolean;
error?: Error;
}

export interface IndexSourceMappings {
_meta?: {
created_by: string;
Expand Down
16 changes: 12 additions & 4 deletions x-pack/plugins/maps/public/actions/data_request_actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,14 @@ import { IVectorStyle } from '../classes/styles/vector/vector_style';
const FIT_TO_BOUNDS_SCALE_FACTOR = 0.1;

export type DataRequestContext = {
startLoading(dataId: string, requestToken: symbol, requestMeta: DataMeta): void;
startLoading(dataId: string, requestToken: symbol, requestMeta?: DataMeta): void;
stopLoading(dataId: string, requestToken: symbol, data: object, resultsMeta?: DataMeta): void;
onLoadError(dataId: string, requestToken: symbol, errorMessage: string): void;
updateSourceData(newData: unknown): void;
isRequestStillActive(dataId: string, requestToken: symbol): boolean;
registerCancelCallback(requestToken: symbol, callback: () => void): void;
dataFilters: MapFilters;
forceRefresh: boolean;
};

export function clearDataRequests(layer: ILayer) {
Expand Down Expand Up @@ -113,7 +114,8 @@ export function updateStyleMeta(layerId: string | null) {
function getDataRequestContext(
dispatch: ThunkDispatch<MapStoreState, void, AnyAction>,
getState: () => MapStoreState,
layerId: string
layerId: string,
forceRefresh: boolean = false
): DataRequestContext {
return {
dataFilters: getDataFilters(getState()),
Expand All @@ -135,6 +137,7 @@ function getDataRequestContext(
},
registerCancelCallback: (requestToken: symbol, callback: () => void) =>
dispatch(registerCancelCallback(requestToken, callback)),
forceRefresh,
};
}

Expand Down Expand Up @@ -166,9 +169,14 @@ function syncDataForAllJoinLayers() {
};
}

export function syncDataForLayer(layer: ILayer) {
export function syncDataForLayer(layer: ILayer, forceRefresh: boolean = false) {
return async (dispatch: Dispatch, getState: () => MapStoreState) => {
const dataRequestContext = getDataRequestContext(dispatch, getState, layer.getId());
const dataRequestContext = getDataRequestContext(
dispatch,
getState,
layer.getId(),
forceRefresh
);
if (!layer.isVisible() || !layer.showAtZoomLevel(dataRequestContext.dataFilters.zoom)) {
return;
}
Expand Down
14 changes: 9 additions & 5 deletions x-pack/plugins/maps/public/actions/layer_actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ import { ThunkDispatch } from 'redux-thunk';
import { Query } from 'src/plugins/data/public';
import { MapStoreState } from '../reducers/store';
import {
createLayerInstance,
getLayerById,
getLayerList,
getLayerListRaw,
getSelectedLayerId,
getMapReady,
getMapColors,
createLayerInstance,
getMapReady,
getSelectedLayerId,
} from '../selectors/map_selectors';
import { FLYOUT_STATE } from '../reducers/ui';
import { cancelRequest } from '../reducers/non_serializable_instances';
import { updateFlyout } from './ui_actions';
import { setDrawMode, updateFlyout } from './ui_actions';
import {
ADD_LAYER,
ADD_WAITING_FOR_MAP_READY_LAYER,
Expand Down Expand Up @@ -49,11 +49,12 @@ import {
} from '../../common/descriptor_types';
import { ILayer } from '../classes/layers/layer';
import { IVectorLayer } from '../classes/layers/vector_layer';
import { LAYER_STYLE_TYPE, LAYER_TYPE } from '../../common/constants';
import { DRAW_MODE, LAYER_STYLE_TYPE, LAYER_TYPE } from '../../common/constants';
import { IVectorStyle } from '../classes/styles/vector/vector_style';
import { notifyLicensedFeatureUsage } from '../licensed_features';
import { IESAggField } from '../classes/fields/agg';
import { IField } from '../classes/fields/field';
import { getDrawMode } from '../selectors/ui_selectors';

export function trackCurrentLayerState(layerId: string) {
return {
Expand Down Expand Up @@ -255,6 +256,9 @@ export function setSelectedLayer(layerId: string | null) {
if (layerId) {
dispatch(trackCurrentLayerState(layerId));
}
if (getDrawMode(getState()) !== DRAW_MODE.NONE) {
dispatch(setDrawMode(DRAW_MODE.NONE));
}
dispatch({
type: SET_SELECTED_LAYER,
selectedLayerId: layerId,
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/maps/public/actions/map_action_constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ 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 UPDATE_EDIT_STATE = 'UPDATE_EDIT_STATE';
export const SET_SCROLL_ZOOM = 'SET_SCROLL_ZOOM';
export const SET_MAP_INIT_ERROR = 'SET_MAP_INIT_ERROR';
export const SET_WAITING_FOR_READY_HIDDEN_LAYERS = 'SET_WAITING_FOR_READY_HIDDEN_LAYERS';
Expand Down
60 changes: 59 additions & 1 deletion x-pack/plugins/maps/public/actions/map_actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { ThunkDispatch } from 'redux-thunk';
import turfBboxPolygon from '@turf/bbox-polygon';
import turfBooleanContains from '@turf/boolean-contains';
import { Filter, Query, TimeRange } from 'src/plugins/data/public';
import { Geometry, Position } from 'geojson';
import { DRAW_MODE, DRAW_SHAPE } from '../../common/constants';
import { MapStoreState } from '../reducers/store';
import {
getDataFilters,
Expand All @@ -23,6 +25,8 @@ import {
getLayerList,
getSearchSessionId,
getSearchSessionMapBuffer,
getLayerById,
getEditState,
} from '../selectors/map_selectors';
import {
CLEAR_GOTO,
Expand All @@ -42,8 +46,9 @@ import {
TRACK_MAP_SETTINGS,
UPDATE_DRAW_STATE,
UPDATE_MAP_SETTING,
UPDATE_EDIT_STATE,
} from './map_action_constants';
import { autoFitToBounds, syncDataForAllLayers } from './data_request_actions';
import { autoFitToBounds, syncDataForAllLayers, syncDataForLayer } from './data_request_actions';
import { addLayer, addLayerWithoutDataSync } from './layer_actions';
import { MapSettings } from '../reducers/map';
import {
Expand All @@ -56,6 +61,8 @@ import {
import { INITIAL_LOCATION } from '../../common/constants';
import { scaleBounds } from '../../common/elasticsearch_util';
import { cleanTooltipStateForLayer } from './tooltip_actions';
import { VectorLayer } from '../classes/layers/vector_layer';
import { SET_DRAW_MODE } from './ui_actions';
import { expandToTileBoundaries } from '../../common/geo_tile_utils';

export interface MapExtentState {
Expand Down Expand Up @@ -318,3 +325,54 @@ export function updateDrawState(drawState: DrawState | null) {
});
};
}

export function updateEditShape(shapeToDraw: DRAW_SHAPE | null) {
return (dispatch: Dispatch, getState: () => MapStoreState) => {
const editState = getEditState(getState());
if (!editState) {
return;
}
dispatch({
type: UPDATE_EDIT_STATE,
editState: {
...editState,
drawShape: shapeToDraw,
},
});
};
}

export function updateEditLayer(layerId: string | null) {
return (dispatch: Dispatch) => {
if (layerId !== null) {
dispatch({ type: SET_OPEN_TOOLTIPS, openTooltips: [] });
}
dispatch({
type: SET_DRAW_MODE,
drawMode: DRAW_MODE.NONE,
});
dispatch({
type: UPDATE_EDIT_STATE,
editState: layerId ? { layerId } : undefined,
});
};
}

export function addNewFeatureToIndex(geometry: Geometry | Position[]) {
return async (
dispatch: ThunkDispatch<MapStoreState, void, AnyAction>,
getState: () => MapStoreState
) => {
const editState = getEditState(getState());
const layerId = editState ? editState.layerId : undefined;
if (!layerId) {
return;
}
const layer = getLayerById(layerId, getState());
if (!layer || !(layer instanceof VectorLayer)) {
return;
}
await layer.addFeature(geometry);
await dispatch(syncDataForLayer(layer, true));
};
}
18 changes: 18 additions & 0 deletions x-pack/plugins/maps/public/actions/ui_actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { getFlyoutDisplay } from '../selectors/ui_selectors';
import { FLYOUT_STATE } from '../reducers/ui';
import { setQuery, trackMapSettings } from './map_actions';
import { setSelectedLayer } from './layer_actions';
import { DRAW_MODE } from '../../common';
import { UPDATE_EDIT_STATE } from './map_action_constants';

export const UPDATE_FLYOUT = 'UPDATE_FLYOUT';
export const SET_IS_LAYER_TOC_OPEN = 'SET_IS_LAYER_TOC_OPEN';
Expand All @@ -21,6 +23,7 @@ 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 SET_DRAW_MODE = 'SET_DRAW_MODE';

export function exitFullScreen() {
return {
Expand Down Expand Up @@ -89,6 +92,21 @@ export function hideTOCDetails(layerId: string) {
};
}

export function setDrawMode(drawMode: DRAW_MODE) {
return (dispatch: ThunkDispatch<MapStoreState, void, AnyAction>) => {
if (drawMode === DRAW_MODE.NONE) {
dispatch({
type: UPDATE_EDIT_STATE,
editState: undefined,
});
}
dispatch({
type: SET_DRAW_MODE,
drawMode,
});
};
}

export function openTimeslider() {
return {
type: SET_IS_TIME_SLIDER_OPEN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class MockSyncContext implements DataRequestContext {
startLoading: (dataId: string, requestToken: symbol, meta: DataMeta) => void;
stopLoading: (dataId: string, requestToken: symbol, data: object, meta: DataMeta) => void;
updateSourceData: (newData: unknown) => void;
forceRefresh: boolean;

constructor({ dataFilters }: { dataFilters: Partial<MapFilters> }) {
const mapFilters: MapFilters = {
Expand All @@ -27,6 +28,7 @@ export class MockSyncContext implements DataRequestContext {
mode: 'relative',
},
zoom: 0,
isReadOnly: false,
...dataFilters,
};

Expand All @@ -37,5 +39,6 @@ export class MockSyncContext implements DataRequestContext {
this.startLoading = sinon.spy();
this.stopLoading = sinon.spy();
this.updateSourceData = sinon.spy();
this.forceRefresh = false;
}
}
14 changes: 8 additions & 6 deletions x-pack/plugins/maps/public/classes/layers/vector_layer/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,14 @@ export async function syncVectorSource({
} = syncContext;
const dataRequestId = SOURCE_DATA_REQUEST_ID;
const requestToken = Symbol(`${layerId}-${dataRequestId}`);
const canSkipFetch = await canSkipSourceUpdate({
source,
prevDataRequest,
nextMeta: requestMeta,
extentAware: source.isFilterByMapBounds(),
});
const canSkipFetch = syncContext.forceRefresh
? false
: await canSkipSourceUpdate({
source,
prevDataRequest,
nextMeta: requestMeta,
extentAware: source.isFilterByMapBounds(),
});
if (canSkipFetch) {
return {
refreshed: false,
Expand Down
Loading