1010import * as React from 'react' ;
1111import { useCallback , useContext } from 'react' ;
1212import { TreeDispatcherContext , TreeStateContext } from './TreeContext' ;
13- import { BridgeContext , StoreContext } from '../context' ;
13+ import { BridgeContext , StoreContext , OptionsContext } from '../context' ;
1414import Button from '../Button' ;
1515import ButtonIcon from '../ButtonIcon' ;
1616import { ModalDialogContext } from '../ModalDialog' ;
@@ -37,6 +37,12 @@ export default function InspectedElementWrapper(_: Props) {
3737 ) ;
3838 const bridge = useContext ( BridgeContext ) ;
3939 const store = useContext ( StoreContext ) ;
40+ const {
41+ hideToggleErrorAction,
42+ hideToggleSuspenseAction,
43+ hideLogAction,
44+ hideViewSourceAction,
45+ } = useContext ( OptionsContext ) ;
4046 const { dispatch : modalDialogDispatch } = useContext ( ModalDialogContext ) ;
4147
4248 const {
@@ -108,10 +114,14 @@ export default function InspectedElementWrapper(_: Props) {
108114 inspectedElement . state != null ;
109115
110116 const canToggleError =
111- inspectedElement != null && inspectedElement . canToggleError ;
117+ ! hideToggleErrorAction &&
118+ inspectedElement != null &&
119+ inspectedElement . canToggleError ;
112120
113121 const canToggleSuspense =
114- inspectedElement != null && inspectedElement . canToggleSuspense ;
122+ ! hideToggleSuspenseAction &&
123+ inspectedElement != null &&
124+ inspectedElement . canToggleSuspense ;
115125
116126 const toggleErrored = useCallback ( ( ) => {
117127 if ( inspectedElement == null || targetErrorBoundaryID == null ) {
@@ -248,19 +258,23 @@ export default function InspectedElementWrapper(_: Props) {
248258 < ButtonIcon type = "view-dom" />
249259 </ Button >
250260 ) }
251- < Button
252- className = { styles . IconButton }
253- onClick = { logElement }
254- title = "Log this component data to the console" >
255- < ButtonIcon type = "log-data" />
256- </ Button >
257- < Button
258- className = { styles . IconButton }
259- disabled = { ! canViewSource }
260- onClick = { viewSource }
261- title = "View source for this element" >
262- < ButtonIcon type = "view-source" />
263- </ Button >
261+ { ! hideLogAction && (
262+ < Button
263+ className = { styles . IconButton }
264+ onClick = { logElement }
265+ title = "Log this component data to the console" >
266+ < ButtonIcon type = "log-data" />
267+ </ Button >
268+ ) }
269+ { ! hideViewSourceAction && (
270+ < Button
271+ className = { styles . IconButton }
272+ disabled = { ! canViewSource }
273+ onClick = { viewSource }
274+ title = "View source for this element" >
275+ < ButtonIcon type = "view-source" />
276+ </ Button >
277+ ) }
264278 </ div >
265279
266280 { inspectedElement === null && (
0 commit comments