diff --git a/x-pack/legacy/plugins/file_upload/public/util/file_parser.js b/x-pack/legacy/plugins/file_upload/public/util/file_parser.js index bc336d07bde98..8af4150f503da 100644 --- a/x-pack/legacy/plugins/file_upload/public/util/file_parser.js +++ b/x-pack/legacy/plugins/file_upload/public/util/file_parser.js @@ -35,7 +35,7 @@ export function jsonPreview(json, previewFunction) { // Call preview (if any) if (json && previewFunction) { const defaultName = _.get(json, 'name', 'Import File'); - previewFunction(_.cloneDeep(json), defaultName); + previewFunction(json, defaultName); } } diff --git a/x-pack/legacy/plugins/file_upload/public/util/file_parser.test.js b/x-pack/legacy/plugins/file_upload/public/util/file_parser.test.js index 98f37894b7141..ecbc67f1999a9 100644 --- a/x-pack/legacy/plugins/file_upload/public/util/file_parser.test.js +++ b/x-pack/legacy/plugins/file_upload/public/util/file_parser.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { parseFile, jsonPreview } from './file_parser'; +import { parseFile } from './file_parser'; describe('parse file', () => { const cleanAndValidate = jest.fn(a => a); @@ -61,26 +61,4 @@ describe('parse file', () => { // Confirm preview function called expect(previewFunction.mock.calls.length).toEqual(1); }); - - it('should use object clone for preview function', () => { - const justFinalJson = { - 'type': 'Feature', - 'geometry': { - 'type': 'Polygon', - 'coordinates': [[ - [-104.05, 78.99], - [-87.22, 78.98], - [-86.58, 75.94], - [-104.03, 75.94], - [-104.05, 78.99] - ]] - }, - }; - - jsonPreview(justFinalJson, previewFunction); - // Confirm equal object passed - expect(previewFunction.mock.calls[0][0]).toEqual(justFinalJson); - // Confirm not the same object - expect(previewFunction.mock.calls[0][0]).not.toBe(justFinalJson); - }); }); diff --git a/x-pack/legacy/plugins/maps/public/layers/sources/client_file_source/geojson_file_source.js b/x-pack/legacy/plugins/maps/public/layers/sources/client_file_source/geojson_file_source.js index 34faf4b29d340..a95d587042254 100644 --- a/x-pack/legacy/plugins/maps/public/layers/sources/client_file_source/geojson_file_source.js +++ b/x-pack/legacy/plugins/maps/public/layers/sources/client_file_source/geojson_file_source.js @@ -107,8 +107,17 @@ export class GeojsonFileSource extends AbstractVectorSource { } async getGeoJsonWithMeta() { + const copiedPropsFeatures = this._descriptor.featureCollection.features + .map(feature => ({ + type: 'Feature', + geometry: feature.geometry, + properties: feature.properties ? { ...feature.properties } : {} + })); return { - data: this._descriptor.featureCollection, + data: { + type: 'FeatureCollection', + features: copiedPropsFeatures + }, meta: {} }; }