mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Maps] Cancel button when editing by value from dashboard (#137880)
This commit is contained in:
parent
2521d439e1
commit
e21f41390e
2 changed files with 28 additions and 2 deletions
|
@ -332,6 +332,14 @@ export class SavedMap {
|
|||
return this._originatingApp ? this.getAppNameFromId(this._originatingApp) : undefined;
|
||||
}
|
||||
|
||||
public hasOriginatingApp(): boolean {
|
||||
return !!this._originatingApp;
|
||||
}
|
||||
|
||||
public getOriginatingPath(): string | undefined {
|
||||
return this._originatingPath;
|
||||
}
|
||||
|
||||
public getAppNameFromId = (appId: string): string | undefined => {
|
||||
return this._getStateTransfer().getAppNameFromId(appId);
|
||||
};
|
||||
|
@ -341,7 +349,7 @@ export class SavedMap {
|
|||
}
|
||||
|
||||
public hasSaveAndReturnConfig() {
|
||||
const hasOriginatingApp = !!this._originatingApp;
|
||||
const hasOriginatingApp = this.hasOriginatingApp();
|
||||
const isNewMap = !this.getSavedObjectId();
|
||||
return getIsAllowByValueEmbeddables() ? hasOriginatingApp : !isNewMap && hasOriginatingApp;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import {
|
|||
withSuspense,
|
||||
} from '@kbn/presentation-util-plugin/public';
|
||||
import {
|
||||
getNavigateToApp,
|
||||
getMapsCapabilities,
|
||||
getIsAllowByValueEmbeddables,
|
||||
getInspector,
|
||||
|
@ -96,6 +97,23 @@ export function getTopNavConfig({
|
|||
}
|
||||
);
|
||||
|
||||
if (savedMap.hasOriginatingApp()) {
|
||||
topNavConfigs.push({
|
||||
label: i18n.translate('xpack.maps.topNav.cancel', {
|
||||
defaultMessage: 'Cancel',
|
||||
}),
|
||||
run: () => {
|
||||
getNavigateToApp()(savedMap.getOriginatingApp()!, {
|
||||
path: savedMap.getOriginatingPath(),
|
||||
});
|
||||
},
|
||||
testId: 'mapsCancelButton',
|
||||
description: i18n.translate('xpack.maps.topNav.cancelButtonAriaLabel', {
|
||||
defaultMessage: 'Return to the last app without saving changes',
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
if (getMapsCapabilities().save) {
|
||||
const hasSaveAndReturnConfig = savedMap.hasSaveAndReturnConfig();
|
||||
const mapDescription = savedMap.getAttributes().description
|
||||
|
@ -197,7 +215,7 @@ export function getTopNavConfig({
|
|||
|
||||
let saveModal;
|
||||
|
||||
if (savedMap.getOriginatingApp() || !getIsAllowByValueEmbeddables()) {
|
||||
if (savedMap.hasOriginatingApp() || !getIsAllowByValueEmbeddables()) {
|
||||
saveModal = (
|
||||
<SavedObjectSaveModalOrigin
|
||||
{...saveModalProps}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue