Skip to content

Commit beee03c

Browse files
committed
resolve comment
Signed-off-by: yyfamazon <yyf@amazon.com>
1 parent 513a3ef commit beee03c

File tree

2 files changed

+19
-29
lines changed

2 files changed

+19
-29
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
8989
- Move HITs counter to be closer to table & show results count ([#9498](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/9498))
9090
- Add the ability to export to CSV from the discover page ([#9530](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/9530))
9191
- Append prompt for query assistant in request payload ([#9532](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/9532))
92-
- Add action id to panel item ([#9696](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/9696))
92+
- Add action_id, tooltip and disabled to panel item ([#9696](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/9696))
9393

9494
### 🐛 Bug Fixes
9595

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

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -206,35 +206,25 @@ 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-
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-
});
209+
const contextItem = {
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+
id: action?.id,
217+
href: action.getHref ? await action.getHref(context) : undefined,
218+
_order: action.order || 0,
219+
_title: action.getDisplayName(context),
220+
};
221+
if (typeof action?.getTooltip === 'function') {
222+
contextItem.toolTipContent = action.getTooltip(context);
223+
}
224+
if (typeof action?.isDisabled === 'function') {
225+
contextItem.disabled = action?.isDisabled(context);
237226
}
227+
panels[parentGroupId || 'mainMenu'].items!.push(contextItem);
238228
});
239229
await Promise.all(promises);
240230

0 commit comments

Comments
 (0)