mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[maps] fix un-hiding layer not syncing data (#73039)
* [maps] fix un-hiding layer not syncing data * revert syncDataForLayer to syncDataForLayerId * remove unused method
This commit is contained in:
parent
4b7c16c2ba
commit
cb48e6e98e
4 changed files with 70 additions and 10 deletions
|
@ -35,12 +35,7 @@ import {
|
|||
UPDATE_LAYER_STYLE,
|
||||
UPDATE_SOURCE_PROP,
|
||||
} from './map_action_constants';
|
||||
import {
|
||||
clearDataRequests,
|
||||
syncDataForLayerId,
|
||||
syncDataForLayer,
|
||||
updateStyleMeta,
|
||||
} from './data_request_actions';
|
||||
import { clearDataRequests, syncDataForLayerId, updateStyleMeta } from './data_request_actions';
|
||||
import { cleanTooltipStateForLayer } from './tooltip_actions';
|
||||
import { JoinDescriptor, LayerDescriptor, StyleDescriptor } from '../../common/descriptor_types';
|
||||
import { ILayer } from '../classes/layers/layer';
|
||||
|
@ -175,7 +170,7 @@ export function promotePreviewLayers() {
|
|||
}
|
||||
|
||||
export function setLayerVisibility(layerId: string, makeVisible: boolean) {
|
||||
return async (dispatch: Dispatch, getState: () => MapStoreState) => {
|
||||
return (dispatch: Dispatch, getState: () => MapStoreState) => {
|
||||
// if the current-state is invisible, we also want to sync data
|
||||
// e.g. if a layer was invisible at start-up, it won't have any data loaded
|
||||
const layer = getLayerById(layerId, getState());
|
||||
|
@ -189,19 +184,19 @@ export function setLayerVisibility(layerId: string, makeVisible: boolean) {
|
|||
dispatch<any>(cleanTooltipStateForLayer(layerId));
|
||||
}
|
||||
|
||||
await dispatch({
|
||||
dispatch({
|
||||
type: SET_LAYER_VISIBILITY,
|
||||
layerId,
|
||||
visibility: makeVisible,
|
||||
});
|
||||
if (makeVisible) {
|
||||
dispatch<any>(syncDataForLayer(layer));
|
||||
dispatch<any>(syncDataForLayerId(layerId));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function toggleLayerVisible(layerId: string) {
|
||||
return async (dispatch: Dispatch, getState: () => MapStoreState) => {
|
||||
return (dispatch: Dispatch, getState: () => MapStoreState) => {
|
||||
const layer = getLayerById(layerId, getState());
|
||||
if (!layer) {
|
||||
return;
|
||||
|
|
|
@ -35,6 +35,7 @@ export default function ({ loadTestFile, getService }) {
|
|||
loadTestFile(require.resolve('./saved_object_management'));
|
||||
loadTestFile(require.resolve('./sample_data'));
|
||||
loadTestFile(require.resolve('./auto_fit_to_bounds'));
|
||||
loadTestFile(require.resolve('./layer_visibility'));
|
||||
loadTestFile(require.resolve('./feature_controls/maps_security'));
|
||||
loadTestFile(require.resolve('./feature_controls/maps_spaces'));
|
||||
loadTestFile(require.resolve('./full_screen_mode'));
|
||||
|
|
33
x-pack/test/functional/apps/maps/layer_visibility.js
Normal file
33
x-pack/test/functional/apps/maps/layer_visibility.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* 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 expect from '@kbn/expect';
|
||||
|
||||
export default function ({ getPageObjects, getService }) {
|
||||
const PageObjects = getPageObjects(['maps']);
|
||||
const inspector = getService('inspector');
|
||||
|
||||
describe('layer visibility', () => {
|
||||
before(async () => {
|
||||
await PageObjects.maps.loadSavedMap('document example hidden');
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await inspector.close();
|
||||
});
|
||||
|
||||
it('should not make any requests when layer is hidden', async () => {
|
||||
const noRequests = await PageObjects.maps.doesInspectorHaveRequests();
|
||||
expect(noRequests).to.equal(true);
|
||||
});
|
||||
|
||||
it('should fetch layer data when layer is made visible', async () => {
|
||||
await PageObjects.maps.toggleLayerVisibility('logstash');
|
||||
const hits = await PageObjects.maps.getHits();
|
||||
expect(hits).to.equal('6');
|
||||
});
|
||||
});
|
||||
}
|
|
@ -446,6 +446,37 @@
|
|||
}
|
||||
}
|
||||
|
||||
{
|
||||
"type": "doc",
|
||||
"value": {
|
||||
"id": "map:2de4de10-cc82-11ea-9b0a-eb2886fc84af",
|
||||
"index": ".kibana",
|
||||
"source": {
|
||||
"map": {
|
||||
"title" : "document example hidden",
|
||||
"description" : "",
|
||||
"mapStateJSON" : "{\"zoom\":4.1,\"center\":{\"lon\":-100.61091,\"lat\":33.23887},\"timeFilters\":{\"from\":\"2015-09-20T00:00:00.000Z\",\"to\":\"2015-09-20T01:00:00.000Z\"},\"refreshConfig\":{\"isPaused\":true,\"interval\":1000},\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filters\":[],\"settings\":{\"autoFitToDataBounds\":false,\"initialLocation\":\"LAST_SAVED_LOCATION\",\"fixedLocation\":{\"lat\":0,\"lon\":0,\"zoom\":2},\"browserLocation\":{\"zoom\":2},\"maxZoom\":24,\"minZoom\":0,\"showSpatialFilters\":true,\"spatialFiltersAlpa\":0.3,\"spatialFiltersFillColor\":\"#DA8B45\",\"spatialFiltersLineColor\":\"#DA8B45\"}}",
|
||||
"layerListJSON" : "[{\"id\":\"0hmz5\",\"sourceDescriptor\":{\"type\":\"EMS_TMS\",\"id\":\"road_map\"},\"visible\":true,\"temporary\":false,\"style\":{\"type\":\"TILE\",\"properties\":{}},\"type\":\"VECTOR_TILE\",\"minZoom\":0,\"maxZoom\":24},{\"id\":\"z52lq\",\"label\":\"logstash\",\"minZoom\":0,\"maxZoom\":24,\"sourceDescriptor\":{\"id\":\"e1a5e1a6-676c-4a89-8ea9-0d91d64b73c6\",\"type\":\"ES_SEARCH\",\"geoField\":\"geo.coordinates\",\"limit\":2048,\"filterByMapBounds\":true,\"showTooltip\":true,\"tooltipProperties\":[],\"applyGlobalQuery\":true,\"scalingType\":\"LIMIT\",\"indexPatternRefName\":\"layer_1_source_index_pattern\"},\"visible\":false,\"temporary\":false,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#e6194b\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"STATIC\",\"options\":{\"size\":10}},\"symbolizeAs\":{\"options\":{\"value\":\"circle\"}},\"icon\":{\"type\":\"STATIC\",\"options\":{\"value\":\"marker\"}}},\"previousStyle\":null},\"type\":\"VECTOR\"}]",
|
||||
"uiStateJSON" : "{\"isLayerTOCOpen\":true,\"openTOCDetails\":[]}"
|
||||
},
|
||||
"type" : "map",
|
||||
"references" : [
|
||||
{
|
||||
"name" : "layer_1_source_index_pattern",
|
||||
"type" : "index-pattern",
|
||||
"id" : "c698b940-e149-11e8-a35a-370a8516603a"
|
||||
}
|
||||
],
|
||||
"migrationVersion" : {
|
||||
"map" : "7.9.0"
|
||||
},
|
||||
"updated_at" : "2020-07-23T01:16:47.600Z"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
{
|
||||
"type": "doc",
|
||||
"value": {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue