Disable "copy to clipboard" and "go to definition" context menu options for Firefox addon (#17668)
Brian Vaughn committed
Dec 20, 2019 at 08:31 UTC
79734771cd78f0b0ee02abbbe386f4a40ccca1ab
5 files changed
+24
-8
packages/react-devtools-extensions/src/main.js
+4
-1
@@ -211,12 +211,15 @@ function createPanelIfReactLoaded() {
211
browserTheme: getBrowserTheme(),
212
componentsPortalContainer,
213
enabledInspectedElementContextMenu: true,
214
+ enabledInspectedElementContextMenuCopy: isChrome,
215
overrideTab,
216
profilerPortalContainer,
217
showTabBar: false,
218
store,
219
warnIfUnsupportedVersionDetected: true,
219
- viewAttributeSourceFunction,
220
+ viewAttributeSourceFunction: isChrome
221
+ ? viewAttributeSourceFunction
222
+ : null,
223
viewElementSourceFunction,
224
}),
225
);
packages/react-devtools-shared/src/devtools/views/Components/SelectedElement.js
+9
-6
@@ -303,6 +303,7 @@ function InspectedElementView({
303
304
const {
305
isEnabledForInspectedElement,
306
+ supportsCopyOperation,
307
viewAttributeSourceFunction,
308
} = useContext(ContextMenuContext);
309
@@ -444,12 +445,14 @@ function InspectedElementView({
445
<ContextMenu id="SelectedElement">
446
{data => (
447
<Fragment>
447
- <ContextMenuItem
448
- onClick={() => copyInspectedElementPath(id, data.path)}
449
- title="Copy value to clipboard">
450
- <Icon className={styles.ContextMenuIcon} type="copy" /> Copy
451
- value to clipboard
452
- </ContextMenuItem>
448
+ {supportsCopyOperation && (
449
+ <ContextMenuItem
450
+ onClick={() => copyInspectedElementPath(id, data.path)}
451
+ title="Copy value to clipboard">
452
+ <Icon className={styles.ContextMenuIcon} type="copy" /> Copy
453
+ value to clipboard
454
+ </ContextMenuItem>
455
+ )}
456
<ContextMenuItem
457
onClick={() => storeAsGlobal(id, data.path)}
458
title="Store as global variable">
packages/react-devtools-shared/src/devtools/views/DevTools.js
+8
-1
@@ -54,6 +54,7 @@ export type Props = {|
54
canViewElementSourceFunction?: ?CanViewElementSource,
55
defaultTab?: TabID,
56
enabledInspectedElementContextMenu?: boolean,
57
+ enabledInspectedElementContextMenuCopy?: boolean,
58
showTabBar?: boolean,
59
store: Store,
60
warnIfLegacyBackendDetected?: boolean,
@@ -96,6 +97,7 @@ export default function DevTools({
97
componentsPortalContainer,
98
defaultTab = 'components',
99
enabledInspectedElementContextMenu = false,
100
+ enabledInspectedElementContextMenuCopy = false,
101
overrideTab,
102
profilerPortalContainer,
103
showTabBar = false,
@@ -121,9 +123,14 @@ export default function DevTools({
123
const contextMenu = useMemo(
124
() => ({
125
isEnabledForInspectedElement: enabledInspectedElementContextMenu,
126
+ supportsCopyOperation: enabledInspectedElementContextMenuCopy,
127
viewAttributeSourceFunction: viewAttributeSourceFunction || null,
128
}),
126
- [enabledInspectedElementContextMenu, viewAttributeSourceFunction],
129
+ [
130
+ enabledInspectedElementContextMenu,
131
+ enabledInspectedElementContextMenuCopy,
132
+ viewAttributeSourceFunction,
133
+ ],
134
);
135
136
useEffect(
packages/react-devtools-shared/src/devtools/views/context.js
+2
@@ -23,11 +23,13 @@ StoreContext.displayName = 'StoreContext';
23
24
export type ContextMenuContextType = {|
25
isEnabledForInspectedElement: boolean,
26
+ supportsCopyOperation: boolean,
27
viewAttributeSourceFunction?: ?ViewAttributeSource,
28
|};
29
30
export const ContextMenuContext = createContext<ContextMenuContextType>({
31
isEnabledForInspectedElement: false,
32
+ supportsCopyOperation: false,
33
viewAttributeSourceFunction: null,
34
});
35
ContextMenuContext.displayName = 'ContextMenuContext';
packages/react-devtools-shell/src/devtools.js
+1
@@ -56,6 +56,7 @@ inject('dist/app.js', () => {
56
createElement(DevTools, {
57
browserTheme: 'light',
58
enabledInspectedElementContextMenu: true,
59
+ enabledInspectedElementContextMenuCopy: true,
60
showTabBar: true,
61
warnIfLegacyBackendDetected: true,
62
warnIfUnsupportedVersionDetected: true,