Skip to content

Commit dbe60f6

Browse files
committed
Add info box mentioning how to configure devtools for link handling
1 parent 3245e4d commit dbe60f6

2 files changed

Lines changed: 43 additions & 5 deletions

File tree

packages/react-devtools-shared/src/devtools/views/Editor/EditorPane.js

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export type Props = {selectedSource: ?SourceSelection};
3737

3838
function EditorPane({selectedSource}: Props) {
3939
const [showSettings, setShowSettings] = useState(false);
40+
const [showLinkInfo, setShowLinkInfo] = useState(false);
4041

4142
const editorURL = useSyncExternalStore(
4243
function subscribe(callback) {
@@ -50,6 +51,30 @@ function EditorPane({selectedSource}: Props) {
5051
},
5152
);
5253

54+
if (showLinkInfo) {
55+
return (
56+
<div className={styles.EditorPane}>
57+
<div className={styles.EditorToolbar}>
58+
<div style={{display: 'flex', flex: '1 1 auto'}}>
59+
To enable link handling in your browser's DevTools settings, look
60+
for the option Extension -> Link Handling. Select "React Developer
61+
Tools".
62+
</div>
63+
<div className={styles.VRule} />
64+
<Button
65+
onClick={() =>
66+
startTransition(() => {
67+
setShowLinkInfo(false);
68+
setShowSettings(false);
69+
})
70+
}>
71+
<ButtonIcon type="close" />
72+
</Button>
73+
</div>
74+
</div>
75+
);
76+
}
77+
5378
let editorToolbar;
5479
if (showSettings) {
5580
editorToolbar = (
@@ -87,7 +112,13 @@ function EditorPane({selectedSource}: Props) {
87112
{editorToolbar}
88113
<div className={styles.EditorInfo}>
89114
{editorURL ? (
90-
<CodeEditorByDefault />
115+
<CodeEditorByDefault
116+
onChange={alwaysOpenInEditor => {
117+
if (alwaysOpenInEditor) {
118+
startTransition(() => setShowLinkInfo(true));
119+
}
120+
}}
121+
/>
91122
) : (
92123
'Configure an external editor to open local files.'
93124
)}

packages/react-devtools-shared/src/devtools/views/Settings/CodeEditorByDefault.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ import {useLocalStorage} from '../hooks';
1313

1414
import styles from './SettingsShared.css';
1515

16-
export default function CodeEditorByDefault(_: {}): React.Node {
16+
export default function CodeEditorByDefault({
17+
onChange,
18+
}: {
19+
onChange?: boolean => void,
20+
}): React.Node {
1721
const [alwaysOpenInEditor, setAlwaysOpenInEditor] = useLocalStorage<boolean>(
1822
LOCAL_STORAGE_ALWAYS_OPEN_IN_EDITOR,
1923
false,
@@ -24,9 +28,12 @@ export default function CodeEditorByDefault(_: {}): React.Node {
2428
<input
2529
type="checkbox"
2630
checked={alwaysOpenInEditor}
27-
onChange={({currentTarget}) =>
28-
setAlwaysOpenInEditor(currentTarget.checked)
29-
}
31+
onChange={({currentTarget}) => {
32+
setAlwaysOpenInEditor(currentTarget.checked);
33+
if (onChange) {
34+
onChange(currentTarget.checked);
35+
}
36+
}}
3037
className={styles.SettingRowCheckbox}
3138
/>
3239
Open local files directly in your code editor

0 commit comments

Comments
 (0)