From c822bcf029b7ba4c09905156c43e22e5924f6970 Mon Sep 17 00:00:00 2001 From: Rachel Shen Date: Wed, 6 Nov 2024 14:33:25 -0700 Subject: [PATCH] [Dashboard] Remove modal for inter app from dashboard (#198619) ## Summary Closes https://github.com/elastic/kibana/issues/184257 This PR removes the modal warning users that unsaved changes would be lost when navigating away from dashboard to other apps within Kibana. The modal is not necessary since unsaved changes are saved in session storage. The benefit is that this removes the unnecessary click for users. This does not impact the modal for switching to view mode from edit mode with unsaved changes as shown below. https://github.com/user-attachments/assets/c5bdb0ec-b040-40b0-a511-fd16ad084b90 ### Checklist - [x] Update tests --- .../dashboard_app/_dashboard_app_strings.ts | 15 --------------- .../internal_dashboard_top_nav.tsx | 12 ------------ .../apps/dashboard/group1/edit_visualizations.js | 4 +--- .../plugins/translations/translations/fr-FR.json | 3 --- .../plugins/translations/translations/ja-JP.json | 3 --- .../plugins/translations/translations/zh-CN.json | 3 --- 6 files changed, 1 insertion(+), 39 deletions(-) diff --git a/src/plugins/dashboard/public/dashboard_app/_dashboard_app_strings.ts b/src/plugins/dashboard/public/dashboard_app/_dashboard_app_strings.ts index 8a6e24a183f3a..9c6526ce3403e 100644 --- a/src/plugins/dashboard/public/dashboard_app/_dashboard_app_strings.ts +++ b/src/plugins/dashboard/public/dashboard_app/_dashboard_app_strings.ts @@ -78,21 +78,6 @@ export const unsavedChangesBadgeStrings = { }), }; -export const leaveConfirmStrings = { - getLeaveTitle: () => - i18n.translate('dashboard.appLeaveConfirmModal.unsavedChangesTitle', { - defaultMessage: 'Unsaved changes', - }), - getLeaveSubtitle: () => - i18n.translate('dashboard.appLeaveConfirmModal.unsavedChangesSubtitle', { - defaultMessage: 'Leave Dashboard with unsaved work?', - }), - getLeaveCancelButtonText: () => - i18n.translate('dashboard.appLeaveConfirmModal.cancelButtonLabel', { - defaultMessage: 'Cancel', - }), -}; - export const getCreateVisualizationButtonTitle = () => i18n.translate('dashboard.solutionToolbar.addPanelButtonLabel', { defaultMessage: 'Create visualization', diff --git a/src/plugins/dashboard/public/dashboard_top_nav/internal_dashboard_top_nav.tsx b/src/plugins/dashboard/public/dashboard_top_nav/internal_dashboard_top_nav.tsx index bf2be799dcc1f..47a84b620ede3 100644 --- a/src/plugins/dashboard/public/dashboard_top_nav/internal_dashboard_top_nav.tsx +++ b/src/plugins/dashboard/public/dashboard_top_nav/internal_dashboard_top_nav.tsx @@ -33,7 +33,6 @@ import { dashboardManagedBadge, getDashboardBreadcrumb, getDashboardTitle, - leaveConfirmStrings, unsavedChangesBadgeStrings, } from '../dashboard_app/_dashboard_app_strings'; import { useDashboardMountContext } from '../dashboard_app/hooks/dashboard_mount_context'; @@ -48,7 +47,6 @@ import { getDashboardRecentlyAccessedService } from '../services/dashboard_recen import { coreServices, dataService, - embeddableService, navigationService, serverlessService, } from '../services/kibana_services'; @@ -195,16 +193,6 @@ export function InternalDashboardTopNav({ */ useEffect(() => { onAppLeave((actions) => { - if ( - viewMode === 'edit' && - hasUnsavedChanges && - !embeddableService.getStateTransfer().isTransferInProgress - ) { - return actions.confirm( - leaveConfirmStrings.getLeaveSubtitle(), - leaveConfirmStrings.getLeaveTitle() - ); - } return actions.default(); }); return () => { diff --git a/test/functional/apps/dashboard/group1/edit_visualizations.js b/test/functional/apps/dashboard/group1/edit_visualizations.js index f065748f09b00..9e91ed1ea112f 100644 --- a/test/functional/apps/dashboard/group1/edit_visualizations.js +++ b/test/functional/apps/dashboard/group1/edit_visualizations.js @@ -10,7 +10,7 @@ import expect from '@kbn/expect'; export default function ({ getService, getPageObjects }) { - const { dashboard, header, visualize, common, visEditor } = getPageObjects([ + const { dashboard, header, visualize, visEditor } = getPageObjects([ 'dashboard', 'header', 'visualize', @@ -114,7 +114,6 @@ export default function ({ getService, getPageObjects }) { await header.waitUntilLoadingHasFinished(); await appsMenu.clickLink('Visualize Library'); - await common.clickConfirmOnModal(); expect(await testSubjects.exists('visualizationLandingPage')).to.be(true); }); @@ -132,7 +131,6 @@ export default function ({ getService, getPageObjects }) { await header.waitUntilLoadingHasFinished(); await appsMenu.clickLink('Visualize Library'); - await common.clickConfirmOnModal(); expect(await testSubjects.exists('visualizationLandingPage')).to.be(true); }); diff --git a/x-pack/plugins/translations/translations/fr-FR.json b/x-pack/plugins/translations/translations/fr-FR.json index 3ed262c0aa159..53ddb2e664587 100644 --- a/x-pack/plugins/translations/translations/fr-FR.json +++ b/x-pack/plugins/translations/translations/fr-FR.json @@ -1209,9 +1209,6 @@ "dashboard.actions.toggleExpandPanelMenuItem.notExpandedDisplayName": "Maximiser", "dashboard.addPanel.newEmbeddableAddedSuccessMessageTitle": "{savedObjectName} a été ajouté.", "dashboard.addPanel.newEmbeddableWithNoTitleAddedSuccessMessageTitle": "Un panneau a été ajouté", - "dashboard.appLeaveConfirmModal.cancelButtonLabel": "Annuler", - "dashboard.appLeaveConfirmModal.unsavedChangesSubtitle": "Quitter Dashboard sans enregistrer ?", - "dashboard.appLeaveConfirmModal.unsavedChangesTitle": "Modifications non enregistrées", "dashboard.badge.readOnly.text": "Lecture seule", "dashboard.badge.readOnly.tooltip": "Impossible d'enregistrer les tableaux de bord", "dashboard.createConfirmModal.cancelButtonLabel": "Annuler", diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 16b4b66d842c4..5b646ff86ce3f 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -1209,9 +1209,6 @@ "dashboard.actions.toggleExpandPanelMenuItem.notExpandedDisplayName": "最大化", "dashboard.addPanel.newEmbeddableAddedSuccessMessageTitle": "{savedObjectName} が追加されました", "dashboard.addPanel.newEmbeddableWithNoTitleAddedSuccessMessageTitle": "パネルが追加されました", - "dashboard.appLeaveConfirmModal.cancelButtonLabel": "キャンセル", - "dashboard.appLeaveConfirmModal.unsavedChangesSubtitle": "作業を保存せずにダッシュボードから移動しますか?", - "dashboard.appLeaveConfirmModal.unsavedChangesTitle": "保存されていない変更", "dashboard.badge.readOnly.text": "読み取り専用", "dashboard.badge.readOnly.tooltip": "ダッシュボードを保存できません", "dashboard.createConfirmModal.cancelButtonLabel": "キャンセル", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 2bf1c18e4f4f6..739a59ef97477 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -1209,9 +1209,6 @@ "dashboard.actions.toggleExpandPanelMenuItem.notExpandedDisplayName": "最大化", "dashboard.addPanel.newEmbeddableAddedSuccessMessageTitle": "{savedObjectName} 已添加", "dashboard.addPanel.newEmbeddableWithNoTitleAddedSuccessMessageTitle": "已添加一个面板", - "dashboard.appLeaveConfirmModal.cancelButtonLabel": "取消", - "dashboard.appLeaveConfirmModal.unsavedChangesSubtitle": "离开有未保存工作的仪表板?", - "dashboard.appLeaveConfirmModal.unsavedChangesTitle": "未保存的更改", "dashboard.badge.readOnly.text": "只读", "dashboard.badge.readOnly.tooltip": "无法保存仪表板", "dashboard.createConfirmModal.cancelButtonLabel": "取消",