1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
import { buildMenu, showMenu } from "../../../context-menu/menu";
export default function showContextMenu(props) {
const {
cx,
source,
breakpointsForSource,
disableBreakpointsInSource,
enableBreakpointsInSource,
removeBreakpointsInSource,
contextMenuEvent,
} = props;
contextMenuEvent.preventDefault();
const enableInSourceLabel = L10N.getStr(
"breakpointHeadingsMenuItem.enableInSource.label"
);
const disableInSourceLabel = L10N.getStr(
"breakpointHeadingsMenuItem.disableInSource.label"
);
const removeInSourceLabel = L10N.getStr(
"breakpointHeadingsMenuItem.removeInSource.label"
);
const enableInSourceKey = L10N.getStr(
"breakpointHeadingsMenuItem.enableInSource.accesskey"
);
const disableInSourceKey = L10N.getStr(
"breakpointHeadingsMenuItem.disableInSource.accesskey"
);
const removeInSourceKey = L10N.getStr(
"breakpointHeadingsMenuItem.removeInSource.accesskey"
);
const disableInSourceItem = {
id: "node-menu-disable-in-source",
label: disableInSourceLabel,
accesskey: disableInSourceKey,
disabled: false,
click: () => disableBreakpointsInSource(cx, source),
};
const enableInSourceItem = {
id: "node-menu-enable-in-source",
label: enableInSourceLabel,
accesskey: enableInSourceKey,
disabled: false,
click: () => enableBreakpointsInSource(cx, source),
};
const removeInSourceItem = {
id: "node-menu-enable-in-source",
label: removeInSourceLabel,
accesskey: removeInSourceKey,
disabled: false,
click: () => removeBreakpointsInSource(cx, source),
};
const hideDisableInSourceItem = breakpointsForSource.every(
breakpoint => breakpoint.disabled
);
const hideEnableInSourceItem = breakpointsForSource.every(
breakpoint => !breakpoint.disabled
);
const items = [
{ item: disableInSourceItem, hidden: () => hideDisableInSourceItem },
{ item: enableInSourceItem, hidden: () => hideEnableInSourceItem },
{ item: removeInSourceItem, hidden: () => false },
];
showMenu(contextMenuEvent, buildMenu(items));
}
|