• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jumpinjackie / mapguide-react-layout / 15160437878

21 May 2025 11:00AM UTC coverage: 21.631% (-42.6%) from 64.24%
15160437878

Pull #1552

github

web-flow
Merge 8b7153d9e into 236e2ea07
Pull Request #1552: Feature/package updates 2505

839 of 1165 branches covered (72.02%)

11 of 151 new or added lines in 25 files covered. (7.28%)

1332 existing lines in 50 files now uncovered.

4794 of 22163 relevant lines covered (21.63%)

6.89 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

67.35
/src/components/menu.tsx
1
import * as React from "react";
1✔
2
import { isMenu } from "../utils/type-guards";
1✔
3
import { IItem, getIconStyle, getEnabled } from "./toolbar";
1✔
4
import { ImageIcon } from "./icon";
1✔
5
import { Menu, MenuDivider, MenuItem } from '@blueprintjs/core';
1✔
6

7
const MENU_ITEM_HEIGHT = 30;
1✔
8

9
/**
10
 * MenuComponent props
11
 *
12
 * @export
13
 * @interface IMenuComponentProps
14
 */
15
export interface IMenuComponentProps {
16
    items: IItem[];
17
    onInvoked?: () => void;
18
}
19

20
/**
21
 * A generic menu component
22
 * @param props 
23
 */
24
export const MenuComponent = (props: IMenuComponentProps) => {
1✔
25
    const onClick = (item: IItem) => {
3✔
26
        if (getEnabled(item)) {
2✔
27
            item?.invoke?.();
2✔
28
            props.onInvoked?.();
2✔
29
        }
2✔
30
    }
2✔
31
    return <Menu className="bp3-elevation-1">
3✔
32
        {props.items.map((item, index) => {
3✔
33
            if (item.isSeparator) {
4!
34
                return <MenuDivider key={index} />;
×
35
            } else if (isMenu(item)) {
4!
36
                let text = "";
×
37
                if (typeof (item.label) == 'function') {
×
38
                    text = item.label();
×
UNCOV
39
                } else {
×
40
                    text = item.label || "";
×
UNCOV
41
                }
×
42
                return <MenuItem key={index} text={text} icon="menu-open">
×
UNCOV
43
                    <MenuComponent items={item.childItems} onInvoked={props.onInvoked} />
×
UNCOV
44
                </MenuItem>;
×
45
            } else {
4✔
46
                const height = MENU_ITEM_HEIGHT;
4✔
47
                let enabled = true;
4✔
48
                if (item.enabled != null) {
4!
49
                    if (typeof (item.enabled) == 'function') {
×
50
                        enabled = item.enabled();
×
UNCOV
51
                    } else {
×
52
                        enabled = item.enabled;
×
UNCOV
53
                    }
×
UNCOV
54
                }
×
55
                const imgStyle = {
4✔
56
                    marginRight: 5,
4✔
57
                    ...getIconStyle(enabled, height)
4✔
58
                };
4✔
59
                const text = item.label || "";
4!
60
                //NOTE: Not using MenuItem here as we want fine control over the item content
61
                return <li key={index}>
4✔
62
                    <a className="bp3-menu-item" onClick={() => onClick(item)}><ImageIcon style={imgStyle} url={item.icon} spriteClass={item.iconClass} /> {text}</a>
4✔
63
                </li>;
4✔
64
            }
4✔
65
        })}
3✔
66
    </Menu>;
3✔
67
}
3✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc