From b85bf3ca676f53e3c2811d315c693aba0d099ef7 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 6 Jul 2021 13:45:24 -0400 Subject: [PATCH] [Transform] Fix aggregation name override for the `top_metrics` aggs (#104446) (#104488) * [Transform] Fix aggName for the top_metrics agg * [Transform] update comment Co-authored-by: Dima Arnautov --- .../step_define/common/get_default_aggregation_config.ts | 6 +++++- .../components/step_define/common/top_metrics_agg/config.ts | 3 --- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/get_default_aggregation_config.ts b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/get_default_aggregation_config.ts index 39594dcbff9ae..6667388fd3688 100644 --- a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/get_default_aggregation_config.ts +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/get_default_aggregation_config.ts @@ -43,7 +43,11 @@ export function getDefaultAggregationConfig( case PIVOT_SUPPORTED_AGGS.FILTER: return getFilterAggConfig(commonConfig); case PIVOT_SUPPORTED_AGGS.TOP_METRICS: - return getTopMetricsAggConfig(commonConfig); + return getTopMetricsAggConfig({ + ...commonConfig, + // top_metrics agg has different naming convention by default + aggName: PIVOT_SUPPORTED_AGGS.TOP_METRICS, + }); default: return commonConfig; } diff --git a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/top_metrics_agg/config.ts b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/top_metrics_agg/config.ts index 354a326f38659..56d17e7973e16 100644 --- a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/top_metrics_agg/config.ts +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/top_metrics_agg/config.ts @@ -17,7 +17,6 @@ import { import { PivotAggsConfigTopMetrics } from './types'; import { TopMetricsAggForm } from './components/top_metrics_agg_form'; import { isPopulatedObject } from '../../../../../../../../common/shared_imports'; -import { PIVOT_SUPPORTED_AGGS } from '../../../../../../../../common/types/pivot_aggs'; /** * Gets initial basic configuration of the top_metrics aggregation. @@ -31,8 +30,6 @@ export function getTopMetricsAggConfig( isMultiField: true, field: isPivotAggsConfigWithUiSupport(commonConfig) ? commonConfig.field : '', AggFormComponent: TopMetricsAggForm, - /** Default name */ - aggName: PIVOT_SUPPORTED_AGGS.TOP_METRICS, aggConfig: {}, getEsAggConfig() { // ensure the configuration has been completed