Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 11 additions & 20 deletions x-pack/plugins/maps/public/angular/get_initial_layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,18 @@
*/
import _ from 'lodash';
// Import each layer type, even those not used, to init in registry

import '../layers/sources/wms_source';

import '../layers/sources/ems_file_source';

import '../layers/sources/es_search_source';

import '../layers/sources/es_pew_pew_source/es_pew_pew_source';

import '../layers/sources/es_pew_pew_source';
import '../layers/sources/kibana_regionmap_source';

import '../layers/sources/es_geo_grid_source';

import '../layers/sources/xyz_tms_source';

import { KibanaTilemapSource } from '../layers/sources/kibana_tilemap_source';

import { TileLayer } from '../layers/tile_layer';
import { EMSTMSSource } from '../layers/sources/ems_tms_source';

import { VectorTileLayer } from '../layers/vector_tile_layer';
import { getInjectedVarFunc } from '../kibana_services';

import { getKibanaTileMap } from '../meta';

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

const tilemapSourceFromKibana = getKibanaTileMap();
if (_.get(tilemapSourceFromKibana, 'url')) {
const sourceDescriptor = KibanaTilemapSource.createDescriptor();
const source = new KibanaTilemapSource(sourceDescriptor);
const layer = source.createDefaultLayer();
return [layer.toLayerDescriptor(), ...initialLayers];
const layerDescriptor = TileLayer.createDescriptor({
sourceDescriptor: KibanaTilemapSource.createDescriptor(),
});
return [layerDescriptor, ...initialLayers];
}

const isEmsEnabled = getInjectedVarFunc()('isEmsEnabled', true);
if (isEmsEnabled) {
const descriptor = EMSTMSSource.createDescriptor({ isAutoSelect: true });
const source = new EMSTMSSource(descriptor);
const layer = source.createDefaultLayer();
return [layer.toLayerDescriptor(), ...initialLayers];
const layerDescriptor = VectorTileLayer.createDescriptor({
sourceDescriptor: EMSTMSSource.createDescriptor({ isAutoSelect: true }),
});
return [layerDescriptor, ...initialLayers];
}

return initialLayers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,36 @@
* you may not use this file except in compliance with the Elastic License.
*/

import React, { Fragment } from 'react';
import { EuiSpacer, EuiPanel, EuiButtonEmpty } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import React from 'react';
import { EuiPanel } from '@elastic/eui';

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

export const ImportEditor = ({ clearSource, isIndexingTriggered, ...props }) => {
const editorProperties = getEditorProperties({ isIndexingTriggered, ...props });
export const ImportEditor = props => {
const editorProperties = getEditorProperties(props);
return (
<Fragment>
{isIndexingTriggered ? null : (
<Fragment>
<EuiButtonEmpty size="xs" flush="left" onClick={clearSource} iconType="arrowLeft">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This button was duplicated in two places. Moved to single location.

<FormattedMessage
id="xpack.maps.addLayerPanel.changeDataSourceButtonLabel"
defaultMessage="Change data source"
/>
</EuiButtonEmpty>
<EuiSpacer size="s" />
</Fragment>
)}
<EuiPanel style={{ position: 'relative' }}>
{uploadLayerWizardConfig.renderWizard(editorProperties)}
</EuiPanel>
</Fragment>
<EuiPanel style={{ position: 'relative' }}>
{uploadLayerWizardConfig.renderWizard(editorProperties)}
</EuiPanel>
);
};

function getEditorProperties({
inspectorAdapters,
previewLayer,
mapColors,
onRemove,
viewLayer,
isIndexingTriggered,
onIndexReady,
importSuccessHandler,
importErrorHandler,
}) {
return {
onPreviewSource: viewLayer,
inspectorAdapters,
previewLayer,
mapColors,
onRemove,
importSuccessHandler,
importErrorHandler,
isIndexingTriggered,
addAndViewSource: viewLayer,
onIndexReady,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ function mapStateToProps(state = {}) {

function mapDispatchToProps(dispatch) {
return {
viewLayer: async layer => {
previewLayer: async layerDescriptor => {
await dispatch(setSelectedLayer(null));
await dispatch(removeTransientLayer());
dispatch(addLayer(layer.toLayerDescriptor()));
dispatch(setSelectedLayer(layer.getId()));
dispatch(setTransientLayer(layer.getId()));
dispatch(addLayer(layerDescriptor));
dispatch(setSelectedLayer(layerDescriptor.id));
dispatch(setTransientLayer(layerDescriptor.id));
},
removeTransientLayer: () => {
dispatch(setSelectedLayer(null));
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
import React, { Fragment } from 'react';

import { getLayerWizards } from '../../../layers/layer_wizard_registry';
import { EuiTitle, EuiSpacer, EuiCard, EuiIcon } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiSpacer, EuiCard, EuiIcon } from '@elastic/eui';
import _ from 'lodash';

export function SourceSelect({ updateSourceSelection }) {
Expand Down Expand Up @@ -38,17 +37,5 @@ export function SourceSelect({ updateSourceSelection }) {
);
});

return (
<Fragment>
<EuiTitle size="xs">
<h2>
<FormattedMessage
id="xpack.maps.addLayerPanel.chooseDataSourceTitle"
defaultMessage="Choose data source"
/>
</h2>
</EuiTitle>
{sourceCards}
</Fragment>
);
return <Fragment>{sourceCards}</Fragment>;
}
Loading