Skip to content

Commit 2d1ee17

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

File tree

2 files changed

+43
-16
lines changed

2 files changed

+43
-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: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -206,20 +206,49 @@ 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+
// 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+
// });
223+
if (typeof action?.getTooltip === 'function' && typeof action?.isDisabled === 'function') {
224+
panels[parentGroupId || 'mainMenu'].items!.push({
225+
name: action.MenuItem
226+
? React.createElement(uiToReactComponent(action.MenuItem), { context })
227+
: action.getDisplayName(context),
228+
icon: action.getIconType(context),
229+
'data-test-subj': `embeddablePanelAction-${action.id}`,
230+
onClick: onClick(action, context, closeMenu),
231+
toolTipContent: action?.getTooltip(context),
232+
disabled: action?.isDisabled(context),
233+
id: action?.id,
234+
href: action.getHref ? await action.getHref(context) : undefined,
235+
_order: action.order || 0,
236+
_title: action.getDisplayName(context),
237+
});
238+
} else {
239+
panels[parentGroupId || 'mainMenu'].items!.push({
240+
name: action.MenuItem
241+
? React.createElement(uiToReactComponent(action.MenuItem), { context })
242+
: action.getDisplayName(context),
243+
icon: action.getIconType(context),
244+
'data-test-subj': `embeddablePanelAction-${action.id}`,
245+
onClick: onClick(action, context, closeMenu),
246+
id: action?.id,
247+
href: action.getHref ? await action.getHref(context) : undefined,
248+
_order: action.order || 0,
249+
_title: action.getDisplayName(context),
250+
});
251+
}
223252
});
224253
await Promise.all(promises);
225254

0 commit comments

Comments
 (0)