Skip to content

Commit

Permalink
Discover and visualization set appStatus.dirty before saving new (#11156
Browse files Browse the repository at this point in the history
)

Sharing relies upon appStatus.dirty to determine whether changes
have been made that must be saved. This wasn't being set correctly in
Discover and Visualize when the user first creates a new object and
hasn't saved it yet.
  • Loading branch information
kobelb authored Apr 14, 2017
1 parent 945316c commit cb1aeaf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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());

Expand Down
7 changes: 5 additions & 2 deletions src/core_plugins/kibana/public/visualize/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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());

Expand Down

0 comments on commit cb1aeaf

Please sign in to comment.