Skip to content

Commit 056dbee

Browse files
committed
migrate EMS boundaries layer wizard
1 parent ab795fd commit 056dbee

3 files changed

Lines changed: 31 additions & 19 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
import React from 'react';
8+
import { i18n } from '@kbn/i18n';
9+
import { VectorLayer } from '../../vector_layer';
10+
import { LayerWizard, RenderWizardArguments } from '../../layer_wizard_registry';
11+
import { EMSFileCreateSourceEditor } from './create_source_editor';
12+
import { EMSFileSource, sourceTitle } from './ems_file_source';
13+
14+
export const emsBoundariesLayerWizardConfig: LayerWizard = {
15+
description: i18n.translate('xpack.maps.source.emsFileDescription', {
16+
defaultMessage: 'Administrative boundaries from Elastic Maps Service',
17+
}),
18+
icon: 'emsApp',
19+
renderWizard: ({ previewLayer, mapColors }: RenderWizardArguments) => {
20+
const onSourceConfigChange = sourceConfig => {
21+
const sourceDescriptor = EMSFileSource.createDescriptor(sourceConfig);
22+
const layerDescriptor = VectorLayer.createDescriptor({ sourceDescriptor }, mapColors);
23+
previewLayer(layerDescriptor);
24+
};
25+
return <EMSFileCreateSourceEditor onSourceConfigChange={onSourceConfigChange} />;
26+
},
27+
title: sourceTitle,
28+
};

x-pack/plugins/maps/public/layers/sources/ems_file_source/ems_file_source.js

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@ import { VECTOR_SHAPE_TYPES } from '../vector_feature_types';
99
import React from 'react';
1010
import { SOURCE_TYPES, FIELD_ORIGIN } from '../../../../common/constants';
1111
import { getEMSClient } from '../../../meta';
12-
import { EMSFileCreateSourceEditor } from './create_source_editor';
1312
import { i18n } from '@kbn/i18n';
1413
import { getDataSourceLabel } from '../../../../common/i18n_getters';
1514
import { UpdateSourceEditor } from './update_source_editor';
1615
import { EMSFileField } from '../../fields/ems_file_field';
1716
import { registerSource } from '../source_registry';
1817

19-
const sourceTitle = i18n.translate('xpack.maps.source.emsFileTitle', {
18+
export const sourceTitle = i18n.translate('xpack.maps.source.emsFileTitle', {
2019
defaultMessage: 'EMS Boundaries',
2120
});
2221

@@ -161,19 +160,3 @@ registerSource({
161160
ConstructorFunction: EMSFileSource,
162161
type: SOURCE_TYPES.EMS_FILE,
163162
});
164-
165-
export const emsBoundariesLayerWizardConfig = {
166-
description: i18n.translate('xpack.maps.source.emsFileDescription', {
167-
defaultMessage: 'Administrative boundaries from Elastic Maps Service',
168-
}),
169-
icon: 'emsApp',
170-
renderWizard: ({ onPreviewSource, inspectorAdapters }) => {
171-
const onSourceConfigChange = sourceConfig => {
172-
const sourceDescriptor = EMSFileSource.createDescriptor(sourceConfig);
173-
const source = new EMSFileSource(sourceDescriptor, inspectorAdapters);
174-
onPreviewSource(source);
175-
};
176-
return <EMSFileCreateSourceEditor onSourceConfigChange={onSourceConfigChange} />;
177-
},
178-
title: sourceTitle,
179-
};

x-pack/plugins/maps/public/layers/sources/ems_file_source/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
export { EMSFileSource, emsBoundariesLayerWizardConfig } from './ems_file_source';
7+
export { emsBoundariesLayerWizardConfig } from './ems_boundaries_layer_wizard';
8+
export { EMSFileSource } from './ems_file_source';

0 commit comments

Comments
 (0)