mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Maps] fix bug where toggling Scaling type does not re-fetch data (#63326)
* [Maps] fix bug where toggling Scaling type does not re-fetch data * reset to empty array instead of deleting * move setting of layer type to action creator instead of side effect of UPDATE_SOURCE_PROP * review feedback
This commit is contained in:
parent
500b069efd
commit
3623875175
2 changed files with 36 additions and 15 deletions
|
@ -125,9 +125,21 @@ async function syncDataForAllLayers(dispatch, getState, dataFilters) {
|
|||
export function cancelAllInFlightRequests() {
|
||||
return (dispatch, getState) => {
|
||||
getLayerList(getState()).forEach(layer => {
|
||||
layer.getInFlightRequestTokens().forEach(requestToken => {
|
||||
dispatch(cancelRequest(requestToken));
|
||||
});
|
||||
dispatch(clearDataRequests(layer));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function clearDataRequests(layer) {
|
||||
return dispatch => {
|
||||
layer.getInFlightRequestTokens().forEach(requestToken => {
|
||||
dispatch(cancelRequest(requestToken));
|
||||
});
|
||||
dispatch({
|
||||
type: UPDATE_LAYER_PROP,
|
||||
id: layer.getId(),
|
||||
propName: '__dataRequests',
|
||||
newValue: [],
|
||||
});
|
||||
};
|
||||
}
|
||||
|
@ -663,13 +675,31 @@ export function updateSourceProp(layerId, propName, value, newLayerType) {
|
|||
layerId,
|
||||
propName,
|
||||
value,
|
||||
newLayerType,
|
||||
});
|
||||
if (newLayerType) {
|
||||
dispatch(updateLayerType(layerId, newLayerType));
|
||||
}
|
||||
await dispatch(clearMissingStyleProperties(layerId));
|
||||
dispatch(syncDataForLayer(layerId));
|
||||
};
|
||||
}
|
||||
|
||||
function updateLayerType(layerId, newLayerType) {
|
||||
return (dispatch, getState) => {
|
||||
const layer = getLayerById(layerId, getState());
|
||||
if (!layer || layer.getType() === newLayerType) {
|
||||
return;
|
||||
}
|
||||
dispatch(clearDataRequests(layer));
|
||||
dispatch({
|
||||
type: UPDATE_LAYER_PROP,
|
||||
id: layerId,
|
||||
propName: 'type',
|
||||
newValue: newLayerType,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export function syncDataForLayer(layerId) {
|
||||
return async (dispatch, getState) => {
|
||||
const targetLayer = getLayerById(layerId, getState());
|
||||
|
|
|
@ -74,7 +74,7 @@ const updateLayerInList = (state, layerId, attribute, newValue) => {
|
|||
return { ...state, layerList: updatedList };
|
||||
};
|
||||
|
||||
const updateLayerSourceDescriptorProp = (state, layerId, propName, value, newLayerType) => {
|
||||
const updateLayerSourceDescriptorProp = (state, layerId, propName, value) => {
|
||||
const { layerList } = state;
|
||||
const layerIdx = getLayerIndex(layerList, layerId);
|
||||
const updatedLayer = {
|
||||
|
@ -84,9 +84,6 @@ const updateLayerSourceDescriptorProp = (state, layerId, propName, value, newLay
|
|||
[propName]: value,
|
||||
},
|
||||
};
|
||||
if (newLayerType) {
|
||||
updatedLayer.type = newLayerType;
|
||||
}
|
||||
const updatedList = [
|
||||
...layerList.slice(0, layerIdx),
|
||||
updatedLayer,
|
||||
|
@ -261,13 +258,7 @@ export function map(state = INITIAL_STATE, action) {
|
|||
case UPDATE_LAYER_PROP:
|
||||
return updateLayerInList(state, action.id, action.propName, action.newValue);
|
||||
case UPDATE_SOURCE_PROP:
|
||||
return updateLayerSourceDescriptorProp(
|
||||
state,
|
||||
action.layerId,
|
||||
action.propName,
|
||||
action.value,
|
||||
action.newLayerType
|
||||
);
|
||||
return updateLayerSourceDescriptorProp(state, action.layerId, action.propName, action.value);
|
||||
case SET_JOINS:
|
||||
const layerDescriptor = state.layerList.find(
|
||||
descriptor => descriptor.id === action.layer.getId()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue