Skip to content

Commit

Permalink
[Maps] fix save to maps for by_value map embeddables (#102968)
Browse files Browse the repository at this point in the history
* [Maps] fix save to maps for by_value map embeddables

* show the save as dialog with the option to update Panel on dashboard

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
nreese and kibanamachine committed Jun 23, 2021
1 parent 136d361 commit 1e7ef98
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@ export class SavedMap {
return this._originatingApp;
}

public getOriginatingAppName(): string | undefined {
return this._originatingApp ? this.getAppNameFromId(this._originatingApp) : undefined;
}

public getAppNameFromId = (appId: string): string | undefined => {
return this._getStateTransfer().getAppNameFromId(appId);
};
Expand Down
16 changes: 13 additions & 3 deletions x-pack/plugins/maps/public/routes/map_page/top_nav_config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,8 @@ export function getTopNavConfig({
const saveModalProps = {
onSave: async (
props: OnSaveProps & {
returnToOrigin?: boolean;
dashboardId?: string | null;
addToLibrary?: boolean;
addToLibrary: boolean;
}
) => {
try {
Expand Down Expand Up @@ -181,7 +180,7 @@ export function getTopNavConfig({
await savedMap.save({
...props,
newTags: selectedTags,
saveByReference: Boolean(props.addToLibrary),
saveByReference: props.addToLibrary,
});
// showSaveModal wrapper requires onSave to return an object with an id to close the modal after successful save
return { id: 'id' };
Expand All @@ -204,8 +203,19 @@ export function getTopNavConfig({
saveModal = (
<SavedObjectSaveModalOrigin
{...saveModalProps}
onSave={async (props: OnSaveProps) => {
return saveModalProps.onSave({ ...props, addToLibrary: true });
}}
originatingApp={savedMap.getOriginatingApp()}
getAppNameFromId={savedMap.getAppNameFromId}
returnToOriginSwitchLabel={
savedMap.isByValue()
? i18n.translate('xpack.maps.topNav.updatePanel', {
defaultMessage: 'Update panel on {originatingAppName}',
values: { originatingAppName: savedMap.getOriginatingAppName() },
})
: undefined
}
options={tagSelector}
/>
);
Expand Down

0 comments on commit 1e7ef98

Please sign in to comment.