From 8ba11e3382169a8c03de047241163c64e0f3081d Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Sat, 26 Feb 2022 12:34:19 -0800 Subject: [PATCH] [Tests] update disable bucket agg feature for tests (#1284) Test failure introduced: https://github.com/opensearch-project/OpenSearch-Dashboards/pull/1196 Updating to handle the if that configuration is not found or if it is not an array. Issue: n/a Signed-off-by: Kawika Avilla --- src/plugins/data/common/search/aggs/agg_types_registry.ts | 6 ++++-- src/plugins/data/server/search/aggs/aggs_service.ts | 7 +------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/plugins/data/common/search/aggs/agg_types_registry.ts b/src/plugins/data/common/search/aggs/agg_types_registry.ts index e9eb6be9f11d..1af73d21b36b 100644 --- a/src/plugins/data/common/search/aggs/agg_types_registry.ts +++ b/src/plugins/data/common/search/aggs/agg_types_registry.ts @@ -91,8 +91,10 @@ export class AggTypesRegistry { start = ({ uiSettings }: AggTypesRegistryStartDependencies) => { const disabledBucketAgg = uiSettings.get('visualize:disableBucketAgg'); - for (const k of this.bucketAggs.keys()) { - if (disabledBucketAgg.includes(k)) this.bucketAggs.delete(k); + if (disabledBucketAgg !== undefined && Array.isArray(disabledBucketAgg)) { + for (const k of this.bucketAggs.keys()) { + if (disabledBucketAgg.includes(k)) this.bucketAggs.delete(k); + } } return { diff --git a/src/plugins/data/server/search/aggs/aggs_service.ts b/src/plugins/data/server/search/aggs/aggs_service.ts index 7d2cc502f370..8213038484ac 100644 --- a/src/plugins/data/server/search/aggs/aggs_service.ts +++ b/src/plugins/data/server/search/aggs/aggs_service.ts @@ -32,11 +32,7 @@ import { pick } from 'lodash'; -import { - UiSettingsServiceSetup, - UiSettingsServiceStart, - SavedObjectsClientContract, -} from 'src/core/server'; +import { UiSettingsServiceStart, SavedObjectsClientContract } from 'src/core/server'; import { ExpressionsServiceSetup } from 'src/plugins/expressions/common'; import { AggsCommonService, @@ -52,7 +48,6 @@ import { AggsSetup, AggsStart } from './types'; /** @internal */ export interface AggsSetupDependencies { registerFunction: ExpressionsServiceSetup['registerFunction']; - uiSettings: UiSettingsServiceSetup; } /** @internal */