mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Maps] clear transient layer when required fields are cleared (#31726)
* [Maps] clear transient layer when required fields are cleared * review feedback
This commit is contained in:
parent
4c5d2818da
commit
0b14bb4952
5 changed files with 30 additions and 17 deletions
|
@ -31,6 +31,12 @@ export class AddLayerPanel extends Component {
|
|||
}
|
||||
|
||||
_previewLayer = (source) => {
|
||||
if (!source) {
|
||||
this.setState({ layer: null });
|
||||
this.props.removeTransientLayer();
|
||||
return;
|
||||
}
|
||||
|
||||
this.setState({
|
||||
layer: source.createDefaultLayer({}, this.props.mapColors)
|
||||
},
|
||||
|
|
|
@ -129,13 +129,11 @@ export class CreateSourceEditor extends Component {
|
|||
geoField,
|
||||
requestType
|
||||
} = this.state;
|
||||
if (indexPatternId && geoField) {
|
||||
this.props.onSelect({
|
||||
indexPatternId,
|
||||
geoField,
|
||||
requestType: requestType.value
|
||||
});
|
||||
}
|
||||
|
||||
const sourceConfig = (indexPatternId && geoField)
|
||||
? { indexPatternId, geoField, requestType: requestType.value }
|
||||
: null;
|
||||
this.props.onSelect(sourceConfig);
|
||||
};
|
||||
|
||||
_onNoIndexPatterns = () => {
|
||||
|
|
|
@ -66,6 +66,11 @@ export class ESGeoGridSource extends AbstractESSource {
|
|||
|
||||
static renderEditor({ onPreviewSource, inspectorAdapters }) {
|
||||
const onSelect = (sourceConfig) => {
|
||||
if (!sourceConfig) {
|
||||
onPreviewSource(null);
|
||||
return;
|
||||
}
|
||||
|
||||
const sourceDescriptor = ESGeoGridSource.createDescriptor(sourceConfig);
|
||||
const source = new ESGeoGridSource(sourceDescriptor, inspectorAdapters);
|
||||
onPreviewSource(source);
|
||||
|
|
|
@ -108,12 +108,11 @@ export class CreateSourceEditor extends Component {
|
|||
indexPatternId,
|
||||
geoField,
|
||||
} = this.state;
|
||||
if (indexPatternId && geoField) {
|
||||
this.props.onSelect({
|
||||
indexPatternId,
|
||||
geoField,
|
||||
});
|
||||
}
|
||||
|
||||
const sourceConfig = (indexPatternId && geoField)
|
||||
? { indexPatternId, geoField }
|
||||
: null;
|
||||
this.props.onSelect(sourceConfig);
|
||||
}
|
||||
|
||||
_onNoIndexPatterns = () => {
|
||||
|
|
|
@ -22,12 +22,17 @@ export class ESSearchSource extends AbstractESSource {
|
|||
static description = 'Geospatial data from a Kibana index pattern';
|
||||
|
||||
static renderEditor({ onPreviewSource, inspectorAdapters }) {
|
||||
const onSelect = (layerConfig) => {
|
||||
const layerSource = new ESSearchSource({
|
||||
const onSelect = (sourceConfig) => {
|
||||
if (!sourceConfig) {
|
||||
onPreviewSource(null);
|
||||
return;
|
||||
}
|
||||
|
||||
const source = new ESSearchSource({
|
||||
id: uuid(),
|
||||
...layerConfig
|
||||
...sourceConfig
|
||||
}, inspectorAdapters);
|
||||
onPreviewSource(layerSource);
|
||||
onPreviewSource(source);
|
||||
};
|
||||
return (<CreateSourceEditor onSelect={onSelect}/>);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue