From 7aefead54ad6fd49585005b2623058bd57119afc Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Wed, 25 Sep 2024 09:45:29 +1000 Subject: [PATCH] [8.x] [map embeddable] fix panel disappears from dashboard when canceling edit after dashboard save (#193911) (#193929) # Backport This will backport the following commits from `main` to `8.x`: - [[map embeddable] fix panel disappears from dashboard when canceling edit after dashboard save (#193911)](https://github.com/elastic/kibana/pull/193911) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Nathan Reese --- .../react_embeddable/initialize_edit_api.ts | 53 +++++++++---------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/x-pack/plugins/maps/public/react_embeddable/initialize_edit_api.ts b/x-pack/plugins/maps/public/react_embeddable/initialize_edit_api.ts index a9274ed41f0fbbf..41959c4874223b7 100644 --- a/x-pack/plugins/maps/public/react_embeddable/initialize_edit_api.ts +++ b/x-pack/plugins/maps/public/react_embeddable/initialize_edit_api.ts @@ -16,33 +16,30 @@ export function initializeEditApi( parentApi?: unknown, savedObjectId?: string ) { - if (!parentApi || !apiHasAppContext(parentApi)) { - return {}; - } - - const parentApiContext = parentApi.getAppContext(); - - return { - getTypeDisplayName: () => { - return MAP_EMBEDDABLE_NAME; - }, - onEdit: async () => { - const stateTransfer = getEmbeddableService().getStateTransfer(); - await stateTransfer.navigateToEditor(APP_ID, { - path: getEditPath(savedObjectId), - state: { - embeddableId: uuid, - valueInput: getState(), - originatingApp: parentApiContext.currentAppId, - originatingPath: parentApiContext.getCurrentPath?.(), + return !parentApi || !apiHasAppContext(parentApi) + ? {} + : { + getTypeDisplayName: () => { + return MAP_EMBEDDABLE_NAME; + }, + onEdit: async () => { + const parentApiContext = parentApi.getAppContext(); + const stateTransfer = getEmbeddableService().getStateTransfer(); + await stateTransfer.navigateToEditor(APP_ID, { + path: getEditPath(savedObjectId), + state: { + embeddableId: uuid, + valueInput: getState(), + originatingApp: parentApiContext.currentAppId, + originatingPath: parentApiContext.getCurrentPath?.(), + }, + }); + }, + isEditingEnabled: () => { + return getMapsCapabilities().save as boolean; + }, + getEditHref: async () => { + return getHttp().basePath.prepend(getFullPath(savedObjectId)); }, - }); - }, - isEditingEnabled: () => { - return getMapsCapabilities().save as boolean; - }, - getEditHref: async () => { - return getHttp().basePath.prepend(getFullPath(savedObjectId)); - }, - }; + }; }