From 264e570c1f3f274991ce8cfbc749fdec3f31c8a5 Mon Sep 17 00:00:00 2001 From: Peter Pisljar Date: Wed, 12 Sep 2018 18:49:37 +0200 Subject: [PATCH] fixed editor state updates for parent pipeline aggs (#22965) --- .../metrics/lib/parent_pipeline_agg_controller.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ui/public/agg_types/metrics/lib/parent_pipeline_agg_controller.js b/src/ui/public/agg_types/metrics/lib/parent_pipeline_agg_controller.js index a2df4ec6ac977..610dc59309243 100644 --- a/src/ui/public/agg_types/metrics/lib/parent_pipeline_agg_controller.js +++ b/src/ui/public/agg_types/metrics/lib/parent_pipeline_agg_controller.js @@ -28,7 +28,7 @@ const parentPipelineAggController = function ($scope) { $scope.$watch('agg.params.metricAgg', updateOrderAgg); $scope.$on('$destroy', function () { - const lastBucket = _.findLast($scope.vis.getAggConfig(), agg => agg.type.type === 'buckets'); + const lastBucket = _.findLast($scope.state.aggs, agg => agg.type.type === 'buckets'); if ($scope.aggForm && $scope.aggForm.agg) { $scope.aggForm.agg.$setValidity('bucket', true); } @@ -43,13 +43,13 @@ const parentPipelineAggController = function ($scope) { }; function checkBuckets() { - const lastBucket = _.findLast($scope.vis.getAggConfig(), agg => agg.type.type === 'buckets'); + const lastBucket = _.findLast($scope.state.aggs, agg => agg.type.type === 'buckets'); const bucketHasType = lastBucket && lastBucket.type; const bucketIsHistogram = bucketHasType && ['date_histogram', 'histogram'].includes(lastBucket.type.name); const canUseAggregation = lastBucket && bucketIsHistogram; // remove errors on all buckets - _.each($scope.vis.aggs, agg => { if (agg.error) delete agg.error; }); + _.each($scope.state.aggs, agg => { if (agg.error) delete agg.error; }); if ($scope.aggForm.agg) { $scope.aggForm.agg.$setValidity('bucket', canUseAggregation); @@ -75,7 +75,7 @@ const parentPipelineAggController = function ($scope) { // we aren't creating a custom aggConfig if (metricAgg !== 'custom') { - if (!$scope.vis.getAggConfig().find(agg => agg.id === metricAgg)) { + if (!$scope.state.aggs.find(agg => agg.id === metricAgg)) { params.metricAgg = null; } params.customMetric = null;