MCPcopy Index your code
hub / github.com/alibaba/lowcode-engine / parseContextMenuAsReactNode

Function parseContextMenuAsReactNode

packages/utils/src/context-menu.tsx:66–122  ·  view source on GitHub ↗
(menus: IPublicTypeContextMenuItem[], options: IOptions)

Source from the content-addressed store, hash-verified

64let destroyFn: Function | undefined;
65
66export function parseContextMenuAsReactNode(menus: IPublicTypeContextMenuItem[], options: IOptions): React.ReactNode[] {
67 const { common, commonUI } = options.pluginContext || {};
68 const { intl = (title: any) => title } = common?.utils || {};
69 const { HelpTip } = commonUI || {};
70
71 const children: React.ReactNode[] = [];
72 menus.forEach((menu, index) => {
73 if (menu.type === IPublicEnumContextMenuType.SEPARATOR) {
74 children.push(<Divider key={menu.name || index} />);
75 return;
76 }
77
78 if (menu.type === IPublicEnumContextMenuType.MENU_ITEM) {
79 if (menu.items && menu.items.length) {
80 children.push((
81 <PopupItem
82 className={classNames('engine-context-menu-item', {
83 disabled: menu.disabled,
84 })}
85 key={menu.name}
86 label={<div className="engine-context-menu-text">{intl(menu.title)}</div>}
87 >
88 <Menu className="next-context engine-context-menu">
89 { parseContextMenuAsReactNode(menu.items, options) }
90 </Menu>
91 </PopupItem>
92 ));
93 } else {
94 children.push((
95 <Item
96 className={classNames('engine-context-menu-item', {
97 disabled: menu.disabled,
98 })}
99 disabled={menu.disabled}
100 onClick={() => {
101 menu.action?.();
102 }}
103 key={menu.name}
104 >
105 <div className="engine-context-menu-text">
106 { menu.title ? intl(menu.title) : null }
107 { menu.help ? <HelpTip size="xs" help={menu.help} direction="right" /> : null }
108 </div>
109 </Item>
110 ));
111 }
112 }
113
114 if (menu.type === IPublicEnumContextMenuType.NODE_TREE) {
115 children.push((
116 <Tree node={options.nodes?.[0]} options={options} />
117 ));
118 }
119 });
120
121 return children;
122}
123

Callers 4

ContextMenuFunction · 0.85
context-menu.tsxFile · 0.85
ContextMenuActionsClass · 0.85

Calls 4

pushMethod · 0.80
forEachMethod · 0.65
intlFunction · 0.50
actionMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…