From 8878c48c5a750b99ad784a50b4bd76bb7eb2e0d0 Mon Sep 17 00:00:00 2001 From: Lukas Olson Date: Fri, 15 Mar 2019 11:22:25 -0700 Subject: [PATCH] Fix apps to always migrate legacy queries on state change (#33276) --- .../core_plugins/kibana/public/dashboard/dashboard_app.js | 5 +++-- .../kibana/public/discover/controllers/discover.js | 5 +++-- .../core_plugins/kibana/public/visualize/editor/editor.js | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app.js b/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app.js index a2f997205a398..640bc8611dcc6 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app.js +++ b/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app.js @@ -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(); @@ -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 }); }); diff --git a/src/legacy/core_plugins/kibana/public/discover/controllers/discover.js b/src/legacy/core_plugins/kibana/public/discover/controllers/discover.js index 4b14576036a88..3c8da5dd3ab8f 100644 --- a/src/legacy/core_plugins/kibana/public/discover/controllers/discover.js +++ b/src/legacy/core_plugins/kibana/public/discover/controllers/discover.js @@ -546,7 +546,8 @@ function discoverController( } }); - $scope.$watch('state.query', (query) => { + $scope.$watch('state.query', (newQuery) => { + const query = migrateLegacyQuery(newQuery); $scope.updateQueryAndFetch({ query }); }); @@ -668,7 +669,7 @@ function discoverController( $scope.updateQueryAndFetch = function ({ query, dateRange }) { timefilter.setTime(dateRange); - $state.query = migrateLegacyQuery(query); + $state.query = query; $scope.fetch(); }; diff --git a/src/legacy/core_plugins/kibana/public/visualize/editor/editor.js b/src/legacy/core_plugins/kibana/public/visualize/editor/editor.js index 74be0d613b8eb..62e764f60eae6 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/editor/editor.js +++ b/src/legacy/core_plugins/kibana/public/visualize/editor/editor.js @@ -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 }); }); @@ -443,7 +444,7 @@ function VisEditor( $scope.updateQueryAndFetch = function ({ query, dateRange }) { timefilter.setTime(dateRange); - $state.query = migrateLegacyQuery(query); + $state.query = query; $scope.fetch(); };