clone the aggConfigParams to avoid the Cannot assign to read only property schema of object

This commit is contained in:
Marta Bondyra 2022-07-05 10:45:45 +02:00
parent ee4a1c11b0
commit c4931aad06

View file

@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
import _ from 'lodash';
import { cloneDeep, uniqWith } from 'lodash';
import { Datatable } from '@kbn/expressions-plugin/public';
import { compareFilters, COMPARE_ALL_OPTIONS, Filter, toggleFilterNegated } from '@kbn/es-query';
import { getIndexPatterns, getSearchService } from '../../services';
@ -91,7 +91,7 @@ const createFilter = async (
.sourceParams as any;
const aggConfigsInstance = getSearchService().aggs.createAggConfigs(
await getIndexPatterns().get(indexPatternId),
[aggConfigParams as AggConfigSerialized]
[cloneDeep(aggConfigParams) as AggConfigSerialized]
);
const aggConfig = aggConfigsInstance.aggs[0];
let filter: Filter[] = [];
@ -144,7 +144,7 @@ export const createFiltersFromValueClickAction = async ({
})
);
return _.uniqWith(mapAndFlattenFilters(filters), (a, b) =>
return uniqWith(mapAndFlattenFilters(filters), (a, b) =>
compareFilters(a, b, COMPARE_ALL_OPTIONS)
);
};