From 3ea717a7b32b38f10e8a701d99100e1e3a7bbf26 Mon Sep 17 00:00:00 2001 From: Vadim Dalecky Date: Wed, 17 Jun 2020 14:44:46 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20don't=20show=20drilldown?= =?UTF-8?q?=20action=20in=20"edit"=20mode=20(#69371)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../embeddable_enhanced/public/plugin.ts | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/x-pack/plugins/embeddable_enhanced/public/plugin.ts b/x-pack/plugins/embeddable_enhanced/public/plugin.ts index a14cdfd035d2e..fd0bcc2023269 100644 --- a/x-pack/plugins/embeddable_enhanced/public/plugin.ts +++ b/x-pack/plugins/embeddable_enhanced/public/plugin.ts @@ -17,6 +17,7 @@ import { defaultEmbeddableFactoryProvider, EmbeddableContext, PANEL_NOTIFICATION_TRIGGER, + ViewMode, } from '../../../../src/plugins/embeddable/public'; import { EnhancedEmbeddable, EnhancedEmbeddableContext } from './types'; import { @@ -106,6 +107,15 @@ export class EmbeddableEnhancedPlugin ); } + private readonly isEmbeddableContext = (context: unknown): context is EmbeddableContext => { + if (!(context as EmbeddableContext)?.embeddable) { + // eslint-disable-next-line no-console + console.warn('For drilldowns to work action context should contain .embeddable field.'); + return false; + } + return true; + }; + private enhanceEmbeddableWithDynamicActions( embeddable: E ): EnhancedEmbeddable { @@ -114,13 +124,9 @@ export class EmbeddableEnhancedPlugin const storage = new EmbeddableActionStorage(embeddable as EmbeddableWithDynamicActions); const dynamicActions = new DynamicActionManager({ isCompatible: async (context: unknown) => { - if (!(context as EmbeddableContext)?.embeddable) { - // eslint-disable-next-line no-console - console.warn('For drilldowns to work action context should contain .embeddable field.'); - return false; - } - - return (context as EmbeddableContext).embeddable.runtimeId === embeddable.runtimeId; + if (!this.isEmbeddableContext(context)) return false; + if (context.embeddable.getInput().viewMode !== ViewMode.VIEW) return false; + return context.embeddable.runtimeId === embeddable.runtimeId; }, storage, uiActions: this.uiActions!,