Skip to content

Commit

Permalink
remove order parameter and move all layer registies into single file
Browse files Browse the repository at this point in the history
  • Loading branch information
nreese committed Mar 30, 2020
1 parent 36b256d commit 6106868
Show file tree
Hide file tree
Showing 21 changed files with 68 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ type LayerWizard = {
icon: string;
id: string;
isIndexingSource?: boolean;
order: number; // number to control display order in UI. Lower numbers display first
renderWizard({
onPreviewSource,
inspectorAdapters,
Expand All @@ -29,9 +28,7 @@ export function registerLayerWizard(layerWizard: LayerWizard) {
}

export function getLayerWizards(): LayerWizard[] {
return registry.sort(function(a: LayerWizard, b: LayerWizard) {
return a.order - b.order;
});
return [...registry];
}

export function getLayerWizard(id: string): LayerWizard | undefined {
Expand Down
30 changes: 30 additions & 0 deletions x-pack/legacy/plugins/maps/public/layers/load_layer_wizards.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* 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 { registerLayerWizard } from './layer_wizard_registry';
import { uploadLayerWizardConfig } from './sources/client_file_source';
import { esDocumentsLayerWizardConfig } from './sources/es_search_source';
import { clustersLayerWizardConfig, heatmapLayerWizardConfig } from './sources/es_geo_grid_source';
import { point2PointLayerWizardConfig } from './sources/es_pew_pew_source/es_pew_pew_source';
import { emsBoundariesLayerWizardConfig } from './sources/ems_file_source';
import { emsBaseMapLayerWizardConfig } from './sources/ems_tms_source';
import { kibanaRegionMapLayerWizardConfig } from './sources/kibana_regionmap_source';
import { kibanaBasemapLayerWizardConfig } from './sources/kibana_tilemap_source';
import { tmsLayerWizardConfig } from './sources/xyz_tms_source';
import { wmsLayerWizardConfig } from './sources/wms_source';

// Registration order determines display order
registerLayerWizard(uploadLayerWizardConfig);
registerLayerWizard(esDocumentsLayerWizardConfig);
registerLayerWizard(clustersLayerWizardConfig);
registerLayerWizard(heatmapLayerWizardConfig);
registerLayerWizard(point2PointLayerWizardConfig);
registerLayerWizard(emsBoundariesLayerWizardConfig);
registerLayerWizard(emsBaseMapLayerWizardConfig);
registerLayerWizard(kibanaRegionMapLayerWizardConfig);
registerLayerWizard(kibanaBasemapLayerWizardConfig);
registerLayerWizard(tmsLayerWizardConfig);
registerLayerWizard(wmsLayerWizardConfig);
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import uuid from 'uuid/v4';
import _ from 'lodash';
import { i18n } from '@kbn/i18n';
import { registerSource } from '../source_registry';
import { registerLayerWizard } from '../../layer_wizard_registry';

export class GeojsonFileSource extends AbstractVectorSource {
static type = GEOJSON_FILE;
Expand Down Expand Up @@ -137,11 +136,10 @@ registerSource({
type: GEOJSON_FILE,
});

registerLayerWizard({
export const uploadLayerWizardConfig = {
id: GEOJSON_FILE,
order: 0,
description: i18n.translate('xpack.maps.source.geojsonFileDescription', {
defaultMessage: 'Upload and index GeoJSON data in Elasticsearch',
defaultMessage: 'Index GeoJSON data in Elasticsearch',
}),
icon: 'importAction',
isIndexingSource: true,
Expand Down Expand Up @@ -171,6 +169,6 @@ registerLayerWizard({
);
},
title: i18n.translate('xpack.maps.source.geojsonFileTitle', {
defaultMessage: 'Uploaded GeoJSON',
defaultMessage: 'Upload GeoJSON',
}),
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
* you may not use this file except in compliance with the Elastic License.
*/

export { GeojsonFileSource } from './geojson_file_source';
export { GeojsonFileSource, uploadLayerWizardConfig } from './geojson_file_source';
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { getDataSourceLabel } from '../../../../common/i18n_getters';
import { UpdateSourceEditor } from './update_source_editor';
import { EMSFileField } from '../../fields/ems_file_field';
import { registerSource } from '../source_registry';
import { registerLayerWizard } from '../../layer_wizard_registry';

const sourceTitle = i18n.translate('xpack.maps.source.emsFileTitle', {
defaultMessage: 'EMS Boundaries',
Expand Down Expand Up @@ -165,9 +164,8 @@ registerSource({
type: EMS_FILE,
});

registerLayerWizard({
export const emsBoundariesLayerWizardConfig = {
id: EMS_FILE,
order: 20,
description: i18n.translate('xpack.maps.source.emsFileDescription', {
defaultMessage: 'Administrative boundaries from Elastic Maps Service',
}),
Expand All @@ -181,4 +179,4 @@ registerLayerWizard({
return <EMSFileCreateSourceEditor onSourceConfigChange={onSourceConfigChange} />;
},
title: sourceTitle,
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
* you may not use this file except in compliance with the Elastic License.
*/

export { EMSFileSource } from './ems_file_source';
export { EMSFileSource, emsBoundariesLayerWizardConfig } from './ems_file_source';
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { getDataSourceLabel } from '../../../../common/i18n_getters';
import { EMS_TMS } from '../../../../common/constants';
import { getInjectedVarFunc, getUiSettings } from '../../../kibana_services';
import { registerSource } from '../source_registry';
import { registerLayerWizard } from '../../layer_wizard_registry';

const sourceTitle = i18n.translate('xpack.maps.source.emsTileTitle', {
defaultMessage: 'EMS Basemaps',
Expand Down Expand Up @@ -154,9 +153,8 @@ registerSource({
type: EMS_TMS,
});

registerLayerWizard({
export const emsBaseMapLayerWizardConfig = {
id: EMS_TMS,
order: 21,
description: i18n.translate('xpack.maps.source.emsTileDescription', {
defaultMessage: 'Tile map service from Elastic Maps Service',
}),
Expand All @@ -171,4 +169,4 @@ registerLayerWizard({
return <TileServiceSelect onTileSelect={onSourceConfigChange} />;
},
title: sourceTitle,
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
* you may not use this file except in compliance with the Elastic License.
*/

export { EMSTMSSource } from './ems_tms_source';
export { EMSTMSSource, emsBaseMapLayerWizardConfig } from './ems_tms_source';
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import { DynamicStyleProperty } from '../../styles/vector/properties/dynamic_sty
import { StaticStyleProperty } from '../../styles/vector/properties/static_style_property';
import { DataRequestAbortError } from '../../util/data_request';
import { registerSource } from '../source_registry';
import { registerLayerWizard } from '../../layer_wizard_registry';

export const MAX_GEOTILE_LEVEL = 29;

Expand Down Expand Up @@ -420,9 +419,8 @@ registerSource({
type: ES_GEO_GRID,
});

registerLayerWizard({
export const clustersLayerWizardConfig = {
id: `${ES_GEO_GRID}_clusters`,
order: 11,
description: i18n.translate('xpack.maps.source.esGridClustersDescription', {
defaultMessage: 'Geospatial data grouped in grids with metrics for each gridded cell',
}),
Expand All @@ -447,11 +445,10 @@ registerLayerWizard({
);
},
title: clustersTitle,
});
};

registerLayerWizard({
export const heatmapLayerWizardConfig = {
id: `${ES_GEO_GRID}_heatmap`,
order: 12,
description: i18n.translate('xpack.maps.source.esGridHeatmapDescription', {
defaultMessage: 'Geospatial data grouped in grids to show density',
}),
Expand All @@ -476,4 +473,4 @@ registerLayerWizard({
);
},
title: heatmapTitle,
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

export { ESGeoGridSource } from './es_geo_grid_source';
export {
ESGeoGridSource,
clustersLayerWizardConfig,
heatmapLayerWizardConfig,
} from './es_geo_grid_source';
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { DynamicStyleProperty } from '../../styles/vector/properties/dynamic_sty
import { COLOR_GRADIENTS } from '../../styles/color_utils';
import { indexPatterns } from '../../../../../../../../src/plugins/data/public';
import { registerSource } from '../source_registry';
import { registerLayerWizard } from '../../layer_wizard_registry';

const MAX_GEOTILE_LEVEL = 29;

Expand Down Expand Up @@ -238,9 +237,8 @@ registerSource({
type: ES_PEW_PEW,
});

registerLayerWizard({
export const point2PointLayerWizardConfig = {
id: ES_PEW_PEW,
order: 13,
description: i18n.translate('xpack.maps.source.pewPewDescription', {
defaultMessage: 'Aggregated data paths between the source and destination',
}),
Expand All @@ -260,4 +258,4 @@ registerLayerWizard({
return <CreateSourceEditor onSourceConfigChange={onSourceConfigChange} />;
},
title: sourceTitle,
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import { DEFAULT_FILTER_BY_MAP_BOUNDS } from './constants';
import { ESDocField } from '../../fields/es_doc_field';
import { getField, addFieldToDSL } from '../../util/es_agg_utils';
import { registerSource } from '../source_registry';
import { registerLayerWizard } from '../../layer_wizard_registry';

const sourceTitle = i18n.translate('xpack.maps.source.esSearchTitle', {
defaultMessage: 'Documents',
Expand Down Expand Up @@ -576,9 +575,8 @@ registerSource({
type: ES_SEARCH,
});

registerLayerWizard({
export const esDocumentsLayerWizardConfig = {
id: ES_SEARCH,
order: 10,
description: i18n.translate('xpack.maps.source.esSearchDescription', {
defaultMessage: 'Vector data from a Kibana index pattern',
}),
Expand All @@ -602,4 +600,4 @@ registerLayerWizard({
return <CreateSourceEditor onSourceConfigChange={onSourceConfigChange} />;
},
title: sourceTitle,
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
* you may not use this file except in compliance with the Elastic License.
*/

export { ESSearchSource } from './es_search_source';
export { ESSearchSource, esDocumentsLayerWizardConfig } from './es_search_source';
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
* you may not use this file except in compliance with the Elastic License.
*/

export { KibanaRegionmapSource } from './kibana_regionmap_source';
export { KibanaRegionmapSource, kibanaRegionMapLayerWizardConfig } from './kibana_regionmap_source';
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { getDataSourceLabel } from '../../../../common/i18n_getters';
import { FIELD_ORIGIN, REGIONMAP_FILE } from '../../../../common/constants';
import { KibanaRegionField } from '../../fields/kibana_region_field';
import { registerSource } from '../source_registry';
import { registerLayerWizard } from '../../layer_wizard_registry';

const sourceTitle = i18n.translate('xpack.maps.source.kbnRegionMapTitle', {
defaultMessage: 'Configured GeoJSON',
Expand Down Expand Up @@ -105,9 +104,8 @@ registerSource({
type: REGIONMAP_FILE,
});

registerLayerWizard({
export const kibanaRegionMapLayerWizardConfig = {
id: REGIONMAP_FILE,
order: 30,
description: i18n.translate('xpack.maps.source.kbnRegionMapDescription', {
defaultMessage: 'Vector data from hosted GeoJSON configured in kibana.yml',
}),
Expand All @@ -122,4 +120,4 @@ registerLayerWizard({
return <CreateSourceEditor onSourceConfigChange={onSourceConfigChange} />;
},
title: sourceTitle,
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
* you may not use this file except in compliance with the Elastic License.
*/

export { KibanaTilemapSource } from './kibana_tilemap_source';
export { KibanaTilemapSource, kibanaBasemapLayerWizardConfig } from './kibana_tilemap_source';
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { getDataSourceLabel } from '../../../../common/i18n_getters';
import _ from 'lodash';
import { KIBANA_TILEMAP } from '../../../../common/constants';
import { registerSource } from '../source_registry';
import { registerLayerWizard } from '../../layer_wizard_registry';

const sourceTitle = i18n.translate('xpack.maps.source.kbnTMSTitle', {
defaultMessage: 'Configured Tile Map Service',
Expand Down Expand Up @@ -92,9 +91,8 @@ registerSource({
type: KIBANA_TILEMAP,
});

registerLayerWizard({
export const kibanaBasemapLayerWizardConfig = {
id: KIBANA_TILEMAP,
order: 31,
description: i18n.translate('xpack.maps.source.kbnTMSDescription', {
defaultMessage: 'Tile map service configured in kibana.yml',
}),
Expand All @@ -108,4 +106,4 @@ registerLayerWizard({
return <CreateSourceEditor onSourceConfigChange={onSourceConfigChange} />;
},
title: sourceTitle,
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
* you may not use this file except in compliance with the Elastic License.
*/

export { WMSSource } from './wms_source';
export { WMSSource, wmsLayerWizardConfig } from './wms_source';
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { getDataSourceLabel, getUrlLabel } from '../../../../common/i18n_getters
import { WmsClient } from './wms_client';
import { WMS } from '../../../../common/constants';
import { registerSource } from '../source_registry';
import { registerLayerWizard } from '../../layer_wizard_registry';

const sourceTitle = i18n.translate('xpack.maps.source.wmsTitle', {
defaultMessage: 'Web Map Service',
Expand Down Expand Up @@ -98,9 +97,8 @@ registerSource({
type: WMS,
});

registerLayerWizard({
export const wmsLayerWizardConfig = {
id: WMS,
order: 41,
description: i18n.translate('xpack.maps.source.wmsDescription', {
defaultMessage: 'Maps from OGC Standard WMS',
}),
Expand All @@ -119,4 +117,4 @@ registerLayerWizard({
return <WMSCreateSourceEditor onSourceConfigChange={onSourceConfigChange} />;
},
title: sourceTitle,
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { getDataSourceLabel, getUrlLabel } from '../../../common/i18n_getters';
import _ from 'lodash';
import { EMS_XYZ } from '../../../common/constants';
import { registerSource } from './source_registry';
import { registerLayerWizard } from '../layer_wizard_registry';

const sourceTitle = i18n.translate('xpack.maps.source.ems_xyzTitle', {
defaultMessage: 'Tile Map Service',
Expand Down Expand Up @@ -173,9 +172,8 @@ registerSource({
type: EMS_XYZ,
});

registerLayerWizard({
export const tmsLayerWizardConfig = {
id: EMS_XYZ,
order: 40,
description: i18n.translate('xpack.maps.source.ems_xyzDescription', {
defaultMessage: 'Tile map service configured in interface',
}),
Expand All @@ -189,4 +187,4 @@ registerLayerWizard({
return <XYZTMSEditor onSourceConfigChange={onSourceConfigChange} />;
},
title: sourceTitle,
});
};
11 changes: 1 addition & 10 deletions x-pack/legacy/plugins/maps/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,7 @@

import './layers/layer_wizard_registry';
import './layers/sources/source_registry';
import './layers/sources/ems_file_source';
import './layers/sources/ems_tms_source';
import './layers/sources/client_file_source';
import './layers/sources/xyz_tms_source';
import './layers/sources/wms_source';
import './layers/sources/kibana_tilemap_source';
import './layers/sources/kibana_regionmap_source';
import './layers/sources/es_geo_grid_source';
import './layers/sources/es_search_source';
import './layers/sources/es_pew_pew_source/es_pew_pew_source';
import './layers/load_layer_wizards';

import { Plugin, CoreStart, CoreSetup } from 'src/core/public';
// @ts-ignore
Expand Down

0 comments on commit 6106868

Please sign in to comment.