Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] [Maps] fix save to maps for by_value map embeddables (#102968) #103176

Merged
merged 2 commits into from
Jun 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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