[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:
Nathan Reese 2019-02-21 21:45:18 -07:00 committed by GitHub
parent 4c5d2818da
commit 0b14bb4952
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 17 deletions

View file

@ -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)
},

View file

@ -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 = () => {

View file

@ -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);

View file

@ -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 = () => {

View file

@ -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}/>);
}