[Maps] fix Unable to apply styles to vector tiles (#124289)

* [Maps] fix Unable to apply styles to vector tiles

* eslint and tslint

* fix jest test
This commit is contained in:
Nathan Reese 2022-02-02 12:50:01 -07:00 committed by GitHub
parent 9397661d05
commit 221a9915b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View file

@ -50,6 +50,9 @@ describe('renderLegendDetailRow', () => {
supportsFieldMetaFromEs: () => {
return true;
},
supportsFieldMetaFromLocalData: () => {
return true;
},
} as unknown as IField;
const sizeProp = new DynamicSizeProperty(
{ minSize: 0, maxSize: 10, fieldMetaOptions: { isEnabled: true } },

View file

@ -295,7 +295,20 @@ export class DynamicStyleProperty<T>
}
getFieldMetaOptions() {
return _.get(this.getOptions(), 'fieldMetaOptions', { isEnabled: true });
const fieldMetaOptions = _.get(this.getOptions(), 'fieldMetaOptions', { isEnabled: true });
// In 8.0, UI changed to not allow setting isEnabled to false when fieldMeta from local not supported
// Saved objects created prior to 8.0 may have a configuration where
// fieldMetaOptions.isEnabled is false and the field does not support fieldMeta from local.
// In these cases, force isEnabled to true
// The exact case that spawned this fix is with ES_SEARCH sources and 8.0 where vector tiles switched
// from vector tiles generated via Kibana server to vector tiles generated via Elasticsearch.
// Kibana vector tiles supported fieldMeta from local while Elasticsearch vector tiles do not support fieldMeta from local.
if (this._field && !this._field.supportsFieldMetaFromLocalData()) {
fieldMetaOptions.isEnabled = true;
}
return fieldMetaOptions;
}
getDataMappingFunction() {