-
Notifications
You must be signed in to change notification settings - Fork 46.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat:-Added open in editor to appear by default #26949
Changes from 4 commits
81ecab9
a883d43
f9c745b
cf2b03e
fbf83da
58e2099
023c766
7c361a4
34114ca
de9e2c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -16,7 +16,10 @@ import { | |||||||||
useRef, | ||||||||||
useState, | ||||||||||
} from 'react'; | ||||||||||
import {LOCAL_STORAGE_OPEN_IN_EDITOR_URL} from '../../../constants'; | ||||||||||
import { | ||||||||||
LOCAL_STORAGE_OPEN_IN_EDITOR_URL, | ||||||||||
LOCAL_STORAGE_OPEN_IN_EDITOR_URL_PRESET, | ||||||||||
} from '../../../constants'; | ||||||||||
import {useLocalStorage, useSubscription} from '../hooks'; | ||||||||||
import {StoreContext} from '../context'; | ||||||||||
import Button from '../Button'; | ||||||||||
|
@@ -83,6 +86,10 @@ export default function ComponentsSettings(_: {}): React.Node { | |||||||||
[setParseHookNames], | ||||||||||
); | ||||||||||
|
||||||||||
const [openInEditorURLPreset, setOpenInEditorURLPreset] = useLocalStorage< | ||||||||||
'vscode' | 'custom', | ||||||||||
>(LOCAL_STORAGE_OPEN_IN_EDITOR_URL_PRESET, 'custom'); | ||||||||||
|
||||||||||
const [openInEditorURL, setOpenInEditorURL] = useLocalStorage<string>( | ||||||||||
LOCAL_STORAGE_OPEN_IN_EDITOR_URL, | ||||||||||
getDefaultOpenInEditorURL(), | ||||||||||
|
@@ -280,15 +287,34 @@ export default function ComponentsSettings(_: {}): React.Node { | |||||||||
|
||||||||||
<label className={styles.OpenInURLSetting}> | ||||||||||
Open in Editor URL:{' '} | ||||||||||
<input | ||||||||||
className={styles.Input} | ||||||||||
type="text" | ||||||||||
placeholder={process.env.EDITOR_URL ?? 'vscode://file/{path}:{line}'} | ||||||||||
value={openInEditorURL} | ||||||||||
onChange={event => { | ||||||||||
setOpenInEditorURL(event.target.value); | ||||||||||
}} | ||||||||||
/> | ||||||||||
<select | ||||||||||
className={styles.Select} | ||||||||||
value={openInEditorURLPreset} | ||||||||||
onChange={({currentTarget}) => { | ||||||||||
const selectedValue = currentTarget.value; | ||||||||||
setOpenInEditorURLPreset(selectedValue); | ||||||||||
if (selectedValue === 'vscode') { | ||||||||||
setOpenInEditorURL('vscode://file/{path}:{line}'); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please move 'vscode://file/{path}:{line}' to a constant somewhere at the top? |
||||||||||
} else if (selectedValue === 'custom') { | ||||||||||
setOpenInEditorURL(''); | ||||||||||
} | ||||||||||
}}> | ||||||||||
<option value="vscode">VS Code</option> | ||||||||||
<option value="custom">Custom</option> | ||||||||||
</select> | ||||||||||
{openInEditorURLPreset === 'custom' && ( | ||||||||||
<input | ||||||||||
className={styles.Input} | ||||||||||
type="text" | ||||||||||
placeholder={ | ||||||||||
process.env.EDITOR_URL ? 'vscode://file/{path}:{line}' : '' | ||||||||||
} | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or |
||||||||||
value={openInEditorURL} | ||||||||||
onChange={event => { | ||||||||||
setOpenInEditorURL(event.target.value); | ||||||||||
}} | ||||||||||
/> | ||||||||||
)} | ||||||||||
</label> | ||||||||||
|
||||||||||
<div className={styles.Header}>Hide components where...</div> | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest removing this new config, then if the
React::DevTools::openInEditorUrl
equals to'vscode://file/{path}:{line}'
, you select theVSCode
option. That will be simpler.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @Biki-das will you consider this? also cc @hoxyq
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this adds kinda wrong dependency, you should select the preset first and then based on its value, you either do nothing or update the link template.
For example, if I select
"custom"
and then put"vscode://file/{path}:{line}"
, should we automatically switch toVSCode
option and hide input?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup current implementation looks right i think @hoxyq
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I think this is good, but plz continue this PR if you don't agree with me!