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 a9274ed41f0fb..41959c4874223 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)); - }, - }; + }; }