diff --git a/x-pack/plugins/maps/public/actions/layer_actions.ts b/x-pack/plugins/maps/public/actions/layer_actions.ts index 78e3b5483f3b7c..646197713432d3 100644 --- a/x-pack/plugins/maps/public/actions/layer_actions.ts +++ b/x-pack/plugins/maps/public/actions/layer_actions.ts @@ -37,7 +37,7 @@ import { UPDATE_LAYER_PROP, UPDATE_LAYER_STYLE, UPDATE_SOURCE_PROP, - INDEX_DRAWN_LAYERS, + CLEAR_DRAWING_DATA, } from './map_action_constants'; import { clearDataRequests, syncDataForLayerId, updateStyleMeta } from './data_request_actions'; import { cleanTooltipStateForLayer } from './tooltip_actions'; @@ -555,8 +555,8 @@ export function setAreTilesLoaded(layerId: string, areTilesLoaded: boolean) { }; } -export function indexDrawnLayers() { +export function clearDrawingData() { return { - type: INDEX_DRAWN_LAYERS, + type: CLEAR_DRAWING_DATA, }; } diff --git a/x-pack/plugins/maps/public/actions/map_action_constants.ts b/x-pack/plugins/maps/public/actions/map_action_constants.ts index dc8f0a18422880..e40ada35cd442a 100644 --- a/x-pack/plugins/maps/public/actions/map_action_constants.ts +++ b/x-pack/plugins/maps/public/actions/map_action_constants.ts @@ -49,4 +49,4 @@ export const UPDATE_MAP_SETTING = 'UPDATE_MAP_SETTING'; export const ADD_FEATURES_TO_INDEX_QUEUE = 'ADD_FEATURES_TO_INDEX_QUEUE'; export const REMOVE_FEATURES_FROM_INDEX_QUEUE = 'REMOVE_FEATURES_FROM_INDEX_QUEUE'; export const SET_VECTOR_LAYER_INDEX_NAME = 'SET_VECTOR_LAYER_INDEX_NAME'; -export const INDEX_DRAWN_LAYERS = 'INDEX_DRAWN_LAYERS'; +export const CLEAR_DRAWING_DATA = 'CLEAR_DRAWING_DATA'; diff --git a/x-pack/plugins/maps/public/classes/layers/new_vector_layer_wizard/index.ts b/x-pack/plugins/maps/public/classes/layers/new_vector_layer_wizard/index.ts index ec98f6bd2056f9..efe1686ad5a43b 100644 --- a/x-pack/plugins/maps/public/classes/layers/new_vector_layer_wizard/index.ts +++ b/x-pack/plugins/maps/public/classes/layers/new_vector_layer_wizard/index.ts @@ -12,7 +12,7 @@ import { MapStoreState } from '../../../reducers/store'; import { NewVectorLayerEditor } from './wizard'; import { addLayer, - indexDrawnLayers, + clearDrawingData, setSelectedLayer, setVectorLayerIndexName, updateEditMode, @@ -31,10 +31,13 @@ function mapStateToProps(state: MapStoreState) { function mapDispatchToProps(dispatch: ThunkDispatch) { return { setEditModeActive: () => dispatch(updateEditMode(true)), - setEditModeInActive: () => dispatch(updateEditMode(false)), + setEditModeInActive: () => { + dispatch(updateEditMode(false)) + dispatch(clearDrawingData()); + }, setIndexName: (indexName: string) => dispatch(setVectorLayerIndexName(indexName)), - indexDrawnLayers: () => { - dispatch(indexDrawnLayers()); + clearDrawingData: () => { + dispatch(clearDrawingData()); }, addNewLayer: async (layerDescriptor: LayerDescriptor) => { await dispatch(addLayer(layerDescriptor)); diff --git a/x-pack/plugins/maps/public/classes/layers/new_vector_layer_wizard/wizard.tsx b/x-pack/plugins/maps/public/classes/layers/new_vector_layer_wizard/wizard.tsx index 855a06f8a2fc7f..006c2fa2e14b57 100644 --- a/x-pack/plugins/maps/public/classes/layers/new_vector_layer_wizard/wizard.tsx +++ b/x-pack/plugins/maps/public/classes/layers/new_vector_layer_wizard/wizard.tsx @@ -38,7 +38,7 @@ interface NewVectorLayerProps extends RenderWizardArguments { setEditModeActive: () => void; setEditModeInActive: () => void; setIndexName: (indexName: string) => void; - indexDrawnLayers: () => void; + clearDrawingData: () => void; addNewLayer: (layerDescriptor: LayerDescriptor) => void; } @@ -76,7 +76,7 @@ export class NewVectorLayerEditor extends Component } if (!this.state.indexingTriggered && currentStepId === ADD_DRAWN_FEATURES_TO_INDEX_STEP_ID) { await this._addFeaturesToNewIndex(); - this.props.indexDrawnLayers(); + this.props.clearDrawingData(); } } diff --git a/x-pack/plugins/maps/public/connected_components/mb_map/draw_control/draw_feature_control/draw_feature_control.tsx b/x-pack/plugins/maps/public/connected_components/mb_map/draw_control/draw_feature_control/draw_feature_control.tsx index c04dec50e92048..84500e0e1e8148 100644 --- a/x-pack/plugins/maps/public/connected_components/mb_map/draw_control/draw_feature_control/draw_feature_control.tsx +++ b/x-pack/plugins/maps/public/connected_components/mb_map/draw_control/draw_feature_control/draw_feature_control.tsx @@ -47,7 +47,7 @@ export class DrawFeatureControl extends Component { this.props.addFeaturesToIndexQueue(e.features); } catch (error) { getToasts().addWarning( - i18n.translate('xpack.maps.drawFeatureControl.unableToCreatFilter', { + i18n.translate('xpack.maps.drawFeatureControl.unableToCreateFeature', { defaultMessage: `Unable to create feature, error: '{errorMsg}'.`, values: { errorMsg: error.message, diff --git a/x-pack/plugins/maps/public/reducers/map/map.ts b/x-pack/plugins/maps/public/reducers/map/map.ts index 1a95b637201e11..61ff56c8a6e89e 100644 --- a/x-pack/plugins/maps/public/reducers/map/map.ts +++ b/x-pack/plugins/maps/public/reducers/map/map.ts @@ -49,7 +49,7 @@ import { UPDATE_EDIT_MODE, ADD_FEATURES_TO_INDEX_QUEUE, SET_VECTOR_LAYER_INDEX_NAME, - INDEX_DRAWN_LAYERS, + CLEAR_DRAWING_DATA, REMOVE_FEATURES_FROM_INDEX_QUEUE, } from '../../actions'; @@ -84,7 +84,7 @@ export const DEFAULT_MAP_STATE: MapState = { vectorLayerIndexName: '', drawState: undefined, drawFeatureState: undefined, - editModeActive: undefined, + editModeActive: false, featuresToIndexQueue: [], }, selectedLayerId: null, @@ -145,11 +145,14 @@ export function map(state: MapState = DEFAULT_MAP_STATE, action: any) { vectorLayerIndexName: action.indexName, }, }; - case INDEX_DRAWN_LAYERS: + case CLEAR_DRAWING_DATA: return { ...state, mapState: { ...state.mapState, + drawState: undefined, + drawFeatureState: undefined, + editModeActive: false, featuresToIndexQueue: [], }, };