diff --git a/packages/react-devtools-inline/src/frontend.js b/packages/react-devtools-inline/src/frontend.js index d9645999b3f0b..79bda7ecd8fb8 100644 --- a/packages/react-devtools-inline/src/frontend.js +++ b/packages/react-devtools-inline/src/frontend.js @@ -20,11 +20,16 @@ import type {Wall} from 'react-devtools-shared/src/types'; import type {FrontendBridge} from 'react-devtools-shared/src/bridge'; import type {Props} from 'react-devtools-shared/src/devtools/views/DevTools'; -export function createStore(bridge: FrontendBridge): Store { +type Config = {| + supportsNativeInspection?: boolean, +|}; + +export function createStore(bridge: FrontendBridge, config?: Config): Store { return new Store(bridge, { checkBridgeProtocolCompatibility: true, supportsTraceUpdates: true, supportsSchedulingProfiler: true, + supportsNativeInspection: config?.supportsNativeInspection !== false, }); } diff --git a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElement.js b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElement.js index d0774d95f9611..68fea871ef3ef 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElement.js +++ b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElement.js @@ -10,7 +10,7 @@ import * as React from 'react'; import {useCallback, useContext} from 'react'; import {TreeDispatcherContext, TreeStateContext} from './TreeContext'; -import {BridgeContext, StoreContext} from '../context'; +import {BridgeContext, StoreContext, OptionsContext} from '../context'; import Button from '../Button'; import ButtonIcon from '../ButtonIcon'; import {ModalDialogContext} from '../ModalDialog'; @@ -37,6 +37,12 @@ export default function InspectedElementWrapper(_: Props) { ); const bridge = useContext(BridgeContext); const store = useContext(StoreContext); + const { + hideToggleErrorAction, + hideToggleSuspenseAction, + hideLogAction, + hideViewSourceAction, + } = useContext(OptionsContext); const {dispatch: modalDialogDispatch} = useContext(ModalDialogContext); const { @@ -214,7 +220,7 @@ export default function InspectedElementWrapper(_: Props) { - {canToggleError && ( + {!hideToggleErrorAction && canToggleError && ( )} - {canToggleSuspense && ( + {!hideToggleSuspenseAction && canToggleSuspense && ( )} - - + {!hideLogAction && ( + + )} + {!hideViewSourceAction && ( + + )} {inspectedElement === null && ( diff --git a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementPropsTree.js b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementPropsTree.js index 7b6569cd32ce5..da11045a276fb 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementPropsTree.js +++ b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementPropsTree.js @@ -9,6 +9,7 @@ import {copy} from 'clipboard-js'; import * as React from 'react'; +import {OptionsContext} from '../context'; import Button from '../Button'; import ButtonIcon from '../ButtonIcon'; import KeyValue from './KeyValue'; @@ -35,6 +36,8 @@ export default function InspectedElementPropsTree({ inspectedElement, store, }: Props) { + const {readOnly} = React.useContext(OptionsContext); + const { canEditFunctionProps, canEditFunctionPropsDeletePaths, @@ -88,7 +91,7 @@ export default function InspectedElementPropsTree({ value={value} /> ))} - {canEditValues && ( + {!readOnly && canEditValues && (
Suspended - {canToggleSuspense ? ( + {!readOnly && canToggleSuspense ? ( // key is required to keep and header row toggle button in sync (false); @@ -264,7 +267,7 @@ export default function KeyValue({
{renderedName}
:
- {canEditValues ? ( + {!readOnly && canEditValues ? ( 0 || canEditValues; + const hasChildren = value.length > 0 || (!readOnly && canEditValues); const displayName = getMetaValueLabel(value); children = value.map((innerValue, index) => ( @@ -348,7 +351,7 @@ export default function KeyValue({ /> )); - if (canEditValues && !isReadOnly) { + if (!readOnly && canEditValues && !isReadOnly) { children.push( 0 || canEditValues; + const hasChildren = entries.length > 0 || (!readOnly && canEditValues); const displayName = getMetaValueLabel(value); children = entries.map>(([key, keyValue]) => ( @@ -421,7 +424,7 @@ export default function KeyValue({ /> )); - if (canEditValues && !isReadOnly) { + if (!readOnly && canEditValues && !isReadOnly) { children.push( }> {ownerID !== null ? : } -
{showInlineWarningsAndErrors && ownerID === null && (errors > 0 || warnings > 0) && ( +
{errors > 0 && (
@@ -376,10 +377,14 @@ export default function Tree(props: Props) { title="Clear all errors and warnings"> -
)} - + {!hideSettings && ( + +
+ + + )}