From d8d59b914fe3ee45b8d5655afaffc1edeee49f3b Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Fri, 22 Nov 2024 21:34:46 +0000 Subject: [PATCH] add async cc joshuali Signed-off-by: Kawika Avilla --- src/plugins/vis_augmenter/public/plugin.ts | 2 ++ src/plugins/vis_augmenter/public/utils/utils.ts | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/plugins/vis_augmenter/public/plugin.ts b/src/plugins/vis_augmenter/public/plugin.ts index 9760bfd75b2d..bd6e45a3967b 100644 --- a/src/plugins/vis_augmenter/public/plugin.ts +++ b/src/plugins/vis_augmenter/public/plugin.ts @@ -13,6 +13,7 @@ import { setUiActions, setEmbeddable, setQueryService, + setIndexPatterns, setVisualizations, setCore, } from './services'; @@ -62,6 +63,7 @@ export class VisAugmenterPlugin setUiActions(uiActions); setEmbeddable(embeddable); setQueryService(data.query); + setIndexPatterns(data.indexPatterns); setVisualizations(visualizations); setCore(core); setFlyoutState(VIEW_EVENTS_FLYOUT_STATE.CLOSED); diff --git a/src/plugins/vis_augmenter/public/utils/utils.ts b/src/plugins/vis_augmenter/public/utils/utils.ts index 707c2f8c4f0d..0ae3c9ec93aa 100644 --- a/src/plugins/vis_augmenter/public/utils/utils.ts +++ b/src/plugins/vis_augmenter/public/utils/utils.ts @@ -24,7 +24,10 @@ import { PLUGIN_AUGMENTATION_ENABLE_SETTING } from '../../common/constants'; import { getUISettings, getIndexPatterns } from '../services'; import { IUiSettingsClient } from '../../../../core/public'; -export const isEligibleForVisLayers = (vis: Vis, uiSettingsClient?: IUiSettingsClient): boolean => { +export const isEligibleForVisLayers = async ( + vis: Vis, + uiSettingsClient?: IUiSettingsClient +): Promise => { // Only support a date histogram const dateHistograms = vis.data?.aggs?.byTypeName?.('date_histogram'); if (!Array.isArray(dateHistograms) || dateHistograms.length !== 1) return false; @@ -55,7 +58,7 @@ export const isEligibleForVisLayers = (vis: Vis, uiSettingsClient?: IUiSettingsC return false; // Check if the vis datasource is eligible for the augmentation - if (!isEligibleForDataSource(vis)) return false; + if (!(await isEligibleForDataSource(vis))) return false; // Checks if the augmentation setting is enabled const config = uiSettingsClient ?? getUISettings();