forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[maps] fix geo line source not loaded unless maps application is open…
…ed (elastic#159432) closes elastic#159408 PR consolidates source registry into a single file to ensure that all sources are registered when only map embeddable is loaded. To prevent regression, unit test added to ensure that all SOURCE_TYPES enum values are contained in registry. --------- Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
e03d901
commit cb7c5b3
Showing
25 changed files
with
217 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
x-pack/plugins/maps/public/classes/sources/create_source_instance.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { AbstractSourceDescriptor } from '../../../common/descriptor_types'; | ||
import { ISource } from './source'; | ||
import { getSourceByType } from './source_registry'; | ||
import { setupSources } from './setup_sources'; | ||
|
||
setupSources(); | ||
|
||
export function createSourceInstance(sourceDescriptor: AbstractSourceDescriptor | null): ISource { | ||
if (sourceDescriptor === null) { | ||
throw new Error('Source-descriptor should be initialized'); | ||
} | ||
const source = getSourceByType(sourceDescriptor.type); | ||
if (!source) { | ||
throw new Error(`Unrecognized sourceType ${sourceDescriptor.type}`); | ||
} | ||
return new source.ConstructorFunction(sourceDescriptor); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
x-pack/plugins/maps/public/classes/sources/setup_sources.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
jest.mock('../../kibana_services', () => { | ||
return { | ||
getEMSSettings() { | ||
return { | ||
isEMSUrlSet() { | ||
return false; | ||
}, | ||
}; | ||
}, | ||
}; | ||
}); | ||
|
||
import { setupSources } from './setup_sources'; | ||
import { SOURCE_TYPES } from '../../../common/constants'; | ||
import { getSourceByType } from './source_registry'; | ||
|
||
const EXPECTED_UNREGISTERED_SOURCE_TYPES = [ | ||
SOURCE_TYPES.ES_ML_ANOMALIES, // registered in ML plugin | ||
// join sources are not contained in source registry | ||
SOURCE_TYPES.ES_DISTANCE_SOURCE, | ||
SOURCE_TYPES.ES_TERM_SOURCE, | ||
SOURCE_TYPES.TABLE_SOURCE, | ||
]; | ||
|
||
test('should register all Elastic Maps sources', () => { | ||
setupSources(); | ||
|
||
Object.values(SOURCE_TYPES) | ||
.filter((sourceType) => { | ||
return !EXPECTED_UNREGISTERED_SOURCE_TYPES.includes(sourceType); | ||
}) | ||
.forEach((sourceType) => { | ||
const entry = getSourceByType(sourceType); | ||
if (!entry) { | ||
throw new Error(`Required source type "${sourceType}" not registered.`); | ||
} | ||
}); | ||
}); |
85 changes: 85 additions & 0 deletions
85
x-pack/plugins/maps/public/classes/sources/setup_sources.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { SOURCE_TYPES } from '../../../common/constants'; | ||
import { registerSource } from './source_registry'; | ||
import { EMSFileSource } from './ems_file_source'; | ||
import { EMSTMSSource } from './ems_tms_source'; | ||
import { ESGeoGridSource } from './es_geo_grid_source'; | ||
import { ESGeoLineSource } from './es_geo_line_source'; | ||
import { ESPewPewSource } from './es_pew_pew_source'; | ||
import { ESSearchSource } from './es_search_source'; | ||
import { GeoJsonFileSource } from './geojson_file_source'; | ||
import { KibanaTilemapSource } from './kibana_tilemap_source'; | ||
import { MVTSingleLayerVectorSource } from './mvt_single_layer_vector_source'; | ||
import { WMSSource } from './wms_source'; | ||
import { XYZTMSSource } from './xyz_tms_source'; | ||
|
||
let registered = false; | ||
|
||
export function setupSources() { | ||
if (registered) { | ||
return; | ||
} | ||
|
||
registerSource({ | ||
ConstructorFunction: EMSFileSource, | ||
type: SOURCE_TYPES.EMS_FILE, | ||
}); | ||
|
||
registerSource({ | ||
ConstructorFunction: EMSTMSSource, | ||
type: SOURCE_TYPES.EMS_TMS, | ||
}); | ||
|
||
registerSource({ | ||
ConstructorFunction: ESGeoGridSource, | ||
type: SOURCE_TYPES.ES_GEO_GRID, | ||
}); | ||
|
||
registerSource({ | ||
ConstructorFunction: ESGeoLineSource, | ||
type: SOURCE_TYPES.ES_GEO_LINE, | ||
}); | ||
|
||
registerSource({ | ||
ConstructorFunction: ESPewPewSource, | ||
type: SOURCE_TYPES.ES_PEW_PEW, | ||
}); | ||
|
||
registerSource({ | ||
ConstructorFunction: ESSearchSource, | ||
type: SOURCE_TYPES.ES_SEARCH, | ||
}); | ||
|
||
registerSource({ | ||
ConstructorFunction: GeoJsonFileSource, | ||
type: SOURCE_TYPES.GEOJSON_FILE, | ||
}); | ||
|
||
registerSource({ | ||
ConstructorFunction: KibanaTilemapSource, | ||
type: SOURCE_TYPES.KIBANA_TILEMAP, | ||
}); | ||
|
||
registerSource({ | ||
ConstructorFunction: MVTSingleLayerVectorSource, | ||
type: SOURCE_TYPES.MVT_SINGLE_LAYER, | ||
}); | ||
|
||
registerSource({ | ||
ConstructorFunction: WMSSource, | ||
type: SOURCE_TYPES.WMS, | ||
}); | ||
|
||
registerSource({ | ||
ConstructorFunction: XYZTMSSource, | ||
type: SOURCE_TYPES.EMS_XYZ, | ||
}); | ||
|
||
registered = true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.