Disable "copy to clipboard" and "go to definition" context menu options for Firefox addon (#17668)

This commit is contained in:
Brian Vaughn
2019-12-20 08:31:38 -08:00
committed by GitHub
parent dbc46ac63e
commit 79734771cd
5 changed files with 24 additions and 8 deletions
+4 -1
View File
@@ -211,12 +211,15 @@ function createPanelIfReactLoaded() {
browserTheme: getBrowserTheme(),
componentsPortalContainer,
enabledInspectedElementContextMenu: true,
enabledInspectedElementContextMenuCopy: isChrome,
overrideTab,
profilerPortalContainer,
showTabBar: false,
store,
warnIfUnsupportedVersionDetected: true,
viewAttributeSourceFunction,
viewAttributeSourceFunction: isChrome
? viewAttributeSourceFunction
: null,
viewElementSourceFunction,
}),
);
@@ -303,6 +303,7 @@ function InspectedElementView({
const {
isEnabledForInspectedElement,
supportsCopyOperation,
viewAttributeSourceFunction,
} = useContext(ContextMenuContext);
@@ -444,12 +445,14 @@ function InspectedElementView({
<ContextMenu id="SelectedElement">
{data => (
<Fragment>
<ContextMenuItem
onClick={() => copyInspectedElementPath(id, data.path)}
title="Copy value to clipboard">
<Icon className={styles.ContextMenuIcon} type="copy" /> Copy
value to clipboard
</ContextMenuItem>
{supportsCopyOperation && (
<ContextMenuItem
onClick={() => copyInspectedElementPath(id, data.path)}
title="Copy value to clipboard">
<Icon className={styles.ContextMenuIcon} type="copy" /> Copy
value to clipboard
</ContextMenuItem>
)}
<ContextMenuItem
onClick={() => storeAsGlobal(id, data.path)}
title="Store as global variable">
@@ -54,6 +54,7 @@ export type Props = {|
canViewElementSourceFunction?: ?CanViewElementSource,
defaultTab?: TabID,
enabledInspectedElementContextMenu?: boolean,
enabledInspectedElementContextMenuCopy?: boolean,
showTabBar?: boolean,
store: Store,
warnIfLegacyBackendDetected?: boolean,
@@ -96,6 +97,7 @@ export default function DevTools({
componentsPortalContainer,
defaultTab = 'components',
enabledInspectedElementContextMenu = false,
enabledInspectedElementContextMenuCopy = false,
overrideTab,
profilerPortalContainer,
showTabBar = false,
@@ -121,9 +123,14 @@ export default function DevTools({
const contextMenu = useMemo(
() => ({
isEnabledForInspectedElement: enabledInspectedElementContextMenu,
supportsCopyOperation: enabledInspectedElementContextMenuCopy,
viewAttributeSourceFunction: viewAttributeSourceFunction || null,
}),
[enabledInspectedElementContextMenu, viewAttributeSourceFunction],
[
enabledInspectedElementContextMenu,
enabledInspectedElementContextMenuCopy,
viewAttributeSourceFunction,
],
);
useEffect(
@@ -23,11 +23,13 @@ StoreContext.displayName = 'StoreContext';
export type ContextMenuContextType = {|
isEnabledForInspectedElement: boolean,
supportsCopyOperation: boolean,
viewAttributeSourceFunction?: ?ViewAttributeSource,
|};
export const ContextMenuContext = createContext<ContextMenuContextType>({
isEnabledForInspectedElement: false,
supportsCopyOperation: false,
viewAttributeSourceFunction: null,
});
ContextMenuContext.displayName = 'ContextMenuContext';
+1
View File
@@ -56,6 +56,7 @@ inject('dist/app.js', () => {
createElement(DevTools, {
browserTheme: 'light',
enabledInspectedElementContextMenu: true,
enabledInspectedElementContextMenuCopy: true,
showTabBar: true,
warnIfLegacyBackendDetected: true,
warnIfUnsupportedVersionDetected: true,