Skip to content

Commit ab2bed3

Browse files
[Maps] update LayerWizard previewLayer to take layerDescriptor instead of ISource (#64461)
* more changes * remove unused state argument * revert change to make diff easier to follow * migrate pew pew source to new previewLayer * remove createDefaultLayer from ISource * migrate EMS boundaries layer wizard * convert ems tms layer wizard to previewLayer * convert kibana base map to preview layer * convert all other sources to previewLayer * tslint clean-up * remaining ts lint errors * i18n clean up * review feedback Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
1 parent 0e99bd6 commit ab2bed3

51 files changed

Lines changed: 727 additions & 910 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

x-pack/plugins/maps/public/angular/get_initial_layers.js

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,18 @@
55
*/
66
import _ from 'lodash';
77
// Import each layer type, even those not used, to init in registry
8-
98
import '../layers/sources/wms_source';
10-
119
import '../layers/sources/ems_file_source';
12-
1310
import '../layers/sources/es_search_source';
14-
15-
import '../layers/sources/es_pew_pew_source/es_pew_pew_source';
16-
11+
import '../layers/sources/es_pew_pew_source';
1712
import '../layers/sources/kibana_regionmap_source';
18-
1913
import '../layers/sources/es_geo_grid_source';
20-
2114
import '../layers/sources/xyz_tms_source';
22-
2315
import { KibanaTilemapSource } from '../layers/sources/kibana_tilemap_source';
24-
16+
import { TileLayer } from '../layers/tile_layer';
2517
import { EMSTMSSource } from '../layers/sources/ems_tms_source';
26-
18+
import { VectorTileLayer } from '../layers/vector_tile_layer';
2719
import { getInjectedVarFunc } from '../kibana_services';
28-
2920
import { getKibanaTileMap } from '../meta';
3021

3122
export function getInitialLayers(layerListJSON, initialLayers = []) {
@@ -35,18 +26,18 @@ export function getInitialLayers(layerListJSON, initialLayers = []) {
3526

3627
const tilemapSourceFromKibana = getKibanaTileMap();
3728
if (_.get(tilemapSourceFromKibana, 'url')) {
38-
const sourceDescriptor = KibanaTilemapSource.createDescriptor();
39-
const source = new KibanaTilemapSource(sourceDescriptor);
40-
const layer = source.createDefaultLayer();
41-
return [layer.toLayerDescriptor(), ...initialLayers];
29+
const layerDescriptor = TileLayer.createDescriptor({
30+
sourceDescriptor: KibanaTilemapSource.createDescriptor(),
31+
});
32+
return [layerDescriptor, ...initialLayers];
4233
}
4334

4435
const isEmsEnabled = getInjectedVarFunc()('isEmsEnabled', true);
4536
if (isEmsEnabled) {
46-
const descriptor = EMSTMSSource.createDescriptor({ isAutoSelect: true });
47-
const source = new EMSTMSSource(descriptor);
48-
const layer = source.createDefaultLayer();
49-
return [layer.toLayerDescriptor(), ...initialLayers];
37+
const layerDescriptor = VectorTileLayer.createDescriptor({
38+
sourceDescriptor: EMSTMSSource.createDescriptor({ isAutoSelect: true }),
39+
});
40+
return [layerDescriptor, ...initialLayers];
5041
}
5142

5243
return initialLayers;

x-pack/plugins/maps/public/connected_components/layer_addpanel/import_editor/view.js

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,51 +4,36 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
import React, { Fragment } from 'react';
8-
import { EuiSpacer, EuiPanel, EuiButtonEmpty } from '@elastic/eui';
9-
import { FormattedMessage } from '@kbn/i18n/react';
7+
import React from 'react';
8+
import { EuiPanel } from '@elastic/eui';
109

1110
import { uploadLayerWizardConfig } from '../../../layers/sources/client_file_source';
1211

13-
export const ImportEditor = ({ clearSource, isIndexingTriggered, ...props }) => {
14-
const editorProperties = getEditorProperties({ isIndexingTriggered, ...props });
12+
export const ImportEditor = props => {
13+
const editorProperties = getEditorProperties(props);
1514
return (
16-
<Fragment>
17-
{isIndexingTriggered ? null : (
18-
<Fragment>
19-
<EuiButtonEmpty size="xs" flush="left" onClick={clearSource} iconType="arrowLeft">
20-
<FormattedMessage
21-
id="xpack.maps.addLayerPanel.changeDataSourceButtonLabel"
22-
defaultMessage="Change data source"
23-
/>
24-
</EuiButtonEmpty>
25-
<EuiSpacer size="s" />
26-
</Fragment>
27-
)}
28-
<EuiPanel style={{ position: 'relative' }}>
29-
{uploadLayerWizardConfig.renderWizard(editorProperties)}
30-
</EuiPanel>
31-
</Fragment>
15+
<EuiPanel style={{ position: 'relative' }}>
16+
{uploadLayerWizardConfig.renderWizard(editorProperties)}
17+
</EuiPanel>
3218
);
3319
};
3420

3521
function getEditorProperties({
36-
inspectorAdapters,
22+
previewLayer,
23+
mapColors,
3724
onRemove,
38-
viewLayer,
3925
isIndexingTriggered,
4026
onIndexReady,
4127
importSuccessHandler,
4228
importErrorHandler,
4329
}) {
4430
return {
45-
onPreviewSource: viewLayer,
46-
inspectorAdapters,
31+
previewLayer,
32+
mapColors,
4733
onRemove,
4834
importSuccessHandler,
4935
importErrorHandler,
5036
isIndexingTriggered,
51-
addAndViewSource: viewLayer,
5237
onIndexReady,
5338
};
5439
}

x-pack/plugins/maps/public/connected_components/layer_addpanel/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ function mapStateToProps(state = {}) {
3434

3535
function mapDispatchToProps(dispatch) {
3636
return {
37-
viewLayer: async layer => {
37+
previewLayer: async layerDescriptor => {
3838
await dispatch(setSelectedLayer(null));
3939
await dispatch(removeTransientLayer());
40-
dispatch(addLayer(layer.toLayerDescriptor()));
41-
dispatch(setSelectedLayer(layer.getId()));
42-
dispatch(setTransientLayer(layer.getId()));
40+
dispatch(addLayer(layerDescriptor));
41+
dispatch(setSelectedLayer(layerDescriptor.id));
42+
dispatch(setTransientLayer(layerDescriptor.id));
4343
},
4444
removeTransientLayer: () => {
4545
dispatch(setSelectedLayer(null));

x-pack/plugins/maps/public/connected_components/layer_addpanel/source_editor/index.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

x-pack/plugins/maps/public/connected_components/layer_addpanel/source_editor/view.js

Lines changed: 0 additions & 40 deletions
This file was deleted.

x-pack/plugins/maps/public/connected_components/layer_addpanel/source_select/source_select.js

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
import React, { Fragment } from 'react';
88

99
import { getLayerWizards } from '../../../layers/layer_wizard_registry';
10-
import { EuiTitle, EuiSpacer, EuiCard, EuiIcon } from '@elastic/eui';
11-
import { FormattedMessage } from '@kbn/i18n/react';
10+
import { EuiSpacer, EuiCard, EuiIcon } from '@elastic/eui';
1211
import _ from 'lodash';
1312

1413
export function SourceSelect({ updateSourceSelection }) {
@@ -38,17 +37,5 @@ export function SourceSelect({ updateSourceSelection }) {
3837
);
3938
});
4039

41-
return (
42-
<Fragment>
43-
<EuiTitle size="xs">
44-
<h2>
45-
<FormattedMessage
46-
id="xpack.maps.addLayerPanel.chooseDataSourceTitle"
47-
defaultMessage="Choose data source"
48-
/>
49-
</h2>
50-
</EuiTitle>
51-
{sourceCards}
52-
</Fragment>
53-
);
40+
return <Fragment>{sourceCards}</Fragment>;
5441
}

0 commit comments

Comments
 (0)