Skip to content

Commit

Permalink
Fix apps to always migrate legacy queries on state change (elastic#33276
Browse files Browse the repository at this point in the history
)
  • Loading branch information
lukasolson committed Mar 15, 2019
1 parent 70cf158 commit 8878c48
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Expand Up @@ -241,7 +241,7 @@ app.directive('dashboardApp', function ($injector) {
// a reload, since no state changes will cause it.
dashboardStateManager.requestReload();
} else {
$scope.model.query = migrateLegacyQuery(query);
$scope.model.query = query;
dashboardStateManager.applyFilters($scope.model.query, $scope.model.filters);
}
$scope.refresh();
Expand Down Expand Up @@ -281,7 +281,8 @@ app.directive('dashboardApp', function ($injector) {
$scope.indexPatterns = dashboardStateManager.getPanelIndexPatterns();
};

$scope.$watch('model.query', (query) => {
$scope.$watch('model.query', (newQuery) => {
const query = migrateLegacyQuery(newQuery);
$scope.updateQueryAndFetch({ query });
});

Expand Down
Expand Up @@ -546,7 +546,8 @@ function discoverController(
}
});

$scope.$watch('state.query', (query) => {
$scope.$watch('state.query', (newQuery) => {
const query = migrateLegacyQuery(newQuery);
$scope.updateQueryAndFetch({ query });
});

Expand Down Expand Up @@ -668,7 +669,7 @@ function discoverController(

$scope.updateQueryAndFetch = function ({ query, dateRange }) {
timefilter.setTime(dateRange);
$state.query = migrateLegacyQuery(query);
$state.query = query;
$scope.fetch();
};

Expand Down
Expand Up @@ -355,7 +355,8 @@ function VisEditor(
$appStatus.dirty = status.dirty || !savedVis.id;
});

$scope.$watch('state.query', (query) => {
$scope.$watch('state.query', (newQuery) => {
const query = migrateLegacyQuery(newQuery);
$scope.updateQueryAndFetch({ query });
});

Expand Down Expand Up @@ -443,7 +444,7 @@ function VisEditor(

$scope.updateQueryAndFetch = function ({ query, dateRange }) {
timefilter.setTime(dateRange);
$state.query = migrateLegacyQuery(query);
$state.query = query;
$scope.fetch();
};

Expand Down

0 comments on commit 8878c48

Please sign in to comment.