Skip to content

Commit 513a3ef

Browse files
committed
fix test
Signed-off-by: yyfamazon <yyf@amazon.com>
1 parent 1199ada commit 513a3ef

File tree

2 files changed

+29
-16
lines changed

2 files changed

+29
-16
lines changed

src/plugins/ui_actions/public/actions/create_action.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ export function createAction<T extends ActionType>(
4343
): ActionByType<T> {
4444
return {
4545
getIconType: () => undefined,
46-
getTooltip: () => '',
47-
isDisabled: () => false,
4846
order: 0,
4947
id: action.type,
5048
isCompatible: () => Promise.resolve(true),

src/plugins/ui_actions/public/context_menu/build_eui_context_menu_panels.tsx

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)