diff --git a/src/core_plugins/kibana/public/discover/controllers/discover.js b/src/core_plugins/kibana/public/discover/controllers/discover.js index 9405b3fe32f78..3ff8eb12630da 100644 --- a/src/core_plugins/kibana/public/discover/controllers/discover.js +++ b/src/core_plugins/kibana/public/discover/controllers/discover.js @@ -150,7 +150,9 @@ function discoverController($scope, config, courier, $route, $window, Notifier, } let stateMonitor; - const $appStatus = $scope.appStatus = this.appStatus = {}; + const $appStatus = $scope.appStatus = this.appStatus = { + dirty: !savedSearch.id + }; const $state = $scope.state = new AppState(getStateDefaults()); $scope.uiState = $state.makeStateful('uiState'); @@ -195,7 +197,7 @@ function discoverController($scope, config, courier, $route, $window, Notifier, stateMonitor = stateMonitorFactory.create($state, getStateDefaults()); stateMonitor.onChange((status) => { - $appStatus.dirty = status.dirty; + $appStatus.dirty = status.dirty || !savedSearch.id; }); $scope.$on('$destroy', () => stateMonitor.destroy()); diff --git a/src/core_plugins/kibana/public/visualize/editor/editor.js b/src/core_plugins/kibana/public/visualize/editor/editor.js index 8a5d762dd4b98..8f4771b559b4d 100644 --- a/src/core_plugins/kibana/public/visualize/editor/editor.js +++ b/src/core_plugins/kibana/public/visualize/editor/editor.js @@ -77,11 +77,14 @@ function VisEditor($rootScope, $scope, $route, timefilter, AppState, $window, kb }); let stateMonitor; - const $appStatus = this.appStatus = {}; // Retrieve the resolved SavedVis instance. const savedVis = $route.current.locals.savedVis; + const $appStatus = this.appStatus = { + dirty: !savedVis.id + }; + // Instance of src/ui/public/vis/vis.js. const vis = savedVis.vis; @@ -186,7 +189,7 @@ function VisEditor($rootScope, $scope, $route, timefilter, AppState, $window, kb stateMonitor = stateMonitorFactory.create($state, stateDefaults); stateMonitor.ignoreProps([ 'vis.listeners' ]).onChange((status) => { - $appStatus.dirty = status.dirty; + $appStatus.dirty = status.dirty || !savedVis.id; }); $scope.$on('$destroy', () => stateMonitor.destroy());