From 7cf2284580091ab3ae99952622bb4f62b4ad7315 Mon Sep 17 00:00:00 2001 From: Devon Thomson Date: Wed, 3 Mar 2021 13:17:50 -0500 Subject: [PATCH] fixed getIsDirty, used function for disabling save button (#93328) --- src/plugins/dashboard/public/application/dashboard_app.tsx | 2 +- .../dashboard/public/application/dashboard_state_manager.ts | 5 ++++- .../public/application/top_nav/dashboard_top_nav.tsx | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/plugins/dashboard/public/application/dashboard_app.tsx b/src/plugins/dashboard/public/application/dashboard_app.tsx index fd73741cef8cb..3d6f08f321977 100644 --- a/src/plugins/dashboard/public/application/dashboard_app.tsx +++ b/src/plugins/dashboard/public/application/dashboard_app.tsx @@ -218,7 +218,7 @@ export function DashboardApp({ ); dashboardStateManager.registerChangeListener(() => { - setUnsavedChanges(dashboardStateManager?.hasUnsavedPanelState()); + setUnsavedChanges(dashboardStateManager.getIsDirty(data.query.timefilter.timefilter)); // we aren't checking dirty state because there are changes the container needs to know about // that won't make the dashboard "dirty" - like a view mode change. triggerRefresh$.next(); diff --git a/src/plugins/dashboard/public/application/dashboard_state_manager.ts b/src/plugins/dashboard/public/application/dashboard_state_manager.ts index d11bdd0399d41..58b413f4303e6 100644 --- a/src/plugins/dashboard/public/application/dashboard_state_manager.ts +++ b/src/plugins/dashboard/public/application/dashboard_state_manager.ts @@ -558,7 +558,10 @@ export class DashboardStateManager { // Filter bar comparison is done manually (see cleanFiltersForComparison for the reason) and time picker // changes are not tracked by the state monitor. const hasTimeFilterChanged = timeFilter ? this.getFiltersChanged(timeFilter) : false; - return this.getIsEditMode() && (this.isDirty || hasTimeFilterChanged); + return ( + this.hasUnsavedPanelState() || + (this.getIsEditMode() && (this.isDirty || hasTimeFilterChanged)) + ); } public getPanels(): SavedDashboardPanel[] { diff --git a/src/plugins/dashboard/public/application/top_nav/dashboard_top_nav.tsx b/src/plugins/dashboard/public/application/top_nav/dashboard_top_nav.tsx index 65cb4db5ad543..4c67acbfc79df 100644 --- a/src/plugins/dashboard/public/application/top_nav/dashboard_top_nav.tsx +++ b/src/plugins/dashboard/public/application/top_nav/dashboard_top_nav.tsx @@ -479,7 +479,7 @@ export function DashboardTopNav({ const topNav = getTopNavConfig(viewMode, dashboardTopNavActions, { hideWriteControls: dashboardCapabilities.hideWriteControls, isNewDashboard: !savedDashboard.id, - isDirty: dashboardStateManager.isDirty, + isDirty: dashboardStateManager.getIsDirty(timefilter), isSaveInProgress, });