import { APPLY_FILTER_TRIGGER } from '../../../../../../../src/plugins/data/public' ; import { SELECT_RANGE_TRIGGER , VALUE_CLICK_TRIGGER , IEmbeddable , Container as EmbeddableContainer , } from '../../../../../../../src/plugins/embeddable/public' ; import { isEnhancedEmbeddable } from '../../../../../embeddable_enhanced/public' ; import { UiActionsEnhancedDrilldownTemplate as DrilldownTemplate } from '../../../../../ui_actions_enhanced/public' ; param triggers export function ensureNestedTriggers ( triggers ) { if ( ! triggers . includes ( APPLY_FILTER_TRIGGER ) && ( triggers . includes ( VALUE_CLICK_TRIGGER ) || triggers . includes ( SELECT_RANGE_TRIGGER ) ) ) { return [ ... triggers , APPLY_FILTER_TRIGGER ] ; } return triggers ; } const isEmbeddableContainer = ( x ) : x is EmbeddableContainer => x instanceof EmbeddableContainer ; /**
 * Given a dashboard panel embeddable, it will find the parent (dashboard
 * container embeddable), then iterate through all the dashboard panels and
 * generate DrilldownTemplate for each existing drilldown.
 */ export const createDrilldownTemplatesFromSiblings = ( embeddable ) : DrilldownTemplate [ ] => { const templates = [ ] ; const embeddableId = embeddable . id ; const container = embeddable . getRoot ( ) ; if ( ! container ) return templates ; if ( ! isEmbeddableContainer ( container ) ) return templates ; const childrenIds = ( container as EmbeddableContainer ) . getChildIds ( ) ; for ( const childId of childrenIds ) { const child = ( container as EmbeddableContainer ) . getChild ( childId ) ; if ( child . id === embeddableId ) continue ; if ( ! isEnhancedEmbeddable ( child ) ) continue ; const events = child . enhancements . dynamicActions . state . get ( ) . events ; for ( const event of events ) { const template = { id : event . eventId , name : event . action . name , icon : 'dashboardApp' , description : child . getTitle ( ) || child . id , config : event . action . config , factoryId : event . action . factoryId , triggers : event . triggers , } ; templates . push ( template ) ; } } return templates ; } ;