[Lens] fix merging the existing saved object with the new one instead of replacing (#160260)

Fixes https://github.com/elastic/kibana/issues/160116
This commit is contained in:
Marta Bondyra 2023-06-22 15:01:04 +02:00 committed by GitHub
parent 7b5b61a2ad
commit 3fc1e68146
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -217,19 +217,19 @@ export class LensStorage implements ContentStorage<LensSavedObject, PartialLensS
// Save data in DB
const soClient = await savedObjectClientFromRequest(ctx);
const partialSavedObject = await soClient.update<LensSavedObjectAttributes>(
SO_TYPE,
const savedObject = await soClient.create<LensSavedObjectAttributes>(SO_TYPE, dataToLatest, {
id,
dataToLatest,
optionsToLatest
);
overwrite: true,
...optionsToLatest,
});
// Validate DB response and DOWN transform to the request version
const { value, error: resultError } = transforms.update.out.result.down<
LensUpdateOut,
LensUpdateOut
>({
item: savedObjectToLensSavedObject(partialSavedObject, true),
item: savedObjectToLensSavedObject(savedObject, true),
});
if (resultError) {