@@ -206,20 +206,35 @@ export async function buildContextMenuForActions({
206206
207207 // Add a context menu item for this action so it shows up on a context menu panel.
208208 // We add this within the parent group or default to the mainMenu panel.
209- panels [ parentGroupId || 'mainMenu' ] . items ! . push ( {
210- name : action . MenuItem
211- ? React . createElement ( uiToReactComponent ( action . MenuItem ) , { context } )
212- : action . getDisplayName ( context ) ,
213- icon : action . getIconType ( context ) ,
214- 'data-test-subj' : `embeddablePanelAction-${ action . id } ` ,
215- onClick : onClick ( action , context , closeMenu ) ,
216- toolTipContent : action ?. getTooltip ( context ) ,
217- disabled : action ?. isDisabled ( context ) ,
218- id : action ?. id ,
219- href : action . getHref ? await action . getHref ( context ) : undefined ,
220- _order : action . order || 0 ,
221- _title : action . getDisplayName ( context ) ,
222- } ) ;
209+ if ( typeof action ?. getTooltip === 'function' && typeof action ?. isDisabled === 'function' ) {
210+ panels [ parentGroupId || 'mainMenu' ] . items ! . push ( {
211+ name : action . MenuItem
212+ ? React . createElement ( uiToReactComponent ( action . MenuItem ) , { context } )
213+ : action . getDisplayName ( context ) ,
214+ icon : action . getIconType ( context ) ,
215+ 'data-test-subj' : `embeddablePanelAction-${ action . id } ` ,
216+ onClick : onClick ( action , context , closeMenu ) ,
217+ toolTipContent : action ?. getTooltip ( context ) ,
218+ disabled : action ?. isDisabled ( context ) ,
219+ id : action ?. id ,
220+ href : action . getHref ? await action . getHref ( context ) : undefined ,
221+ _order : action . order || 0 ,
222+ _title : action . getDisplayName ( context ) ,
223+ } ) ;
224+ } else {
225+ panels [ parentGroupId || 'mainMenu' ] . items ! . push ( {
226+ name : action . MenuItem
227+ ? React . createElement ( uiToReactComponent ( action . MenuItem ) , { context } )
228+ : action . getDisplayName ( context ) ,
229+ icon : action . getIconType ( context ) ,
230+ 'data-test-subj' : `embeddablePanelAction-${ action . id } ` ,
231+ onClick : onClick ( action , context , closeMenu ) ,
232+ id : action ?. id ,
233+ href : action . getHref ? await action . getHref ( context ) : undefined ,
234+ _order : action . order || 0 ,
235+ _title : action . getDisplayName ( context ) ,
236+ } ) ;
237+ }
223238 } ) ;
224239 await Promise . all ( promises ) ;
225240
0 commit comments