Skip to content
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

Merged
merged 10 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Removed useEffect and UI changes
  • Loading branch information
Biki-das committed Jun 15, 2023
commit cf2b03e32f7e7f4ed8fff94eddbc5ec7bea4f33e
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,10 @@ export default function InspectedElementWrapper(_: Props): React.Node {

const url = new URL(editorURL);
url.href = url.href
.replace('{path}', source.fileName)
.replace('{line}', String(source.lineNumber))
.replace('%7Bpath%7D', source.fileName)
.replace('%7Bline%7D', String(source.lineNumber));
.replace('{path}', source.fileName)
.replace('{line}', String(source.lineNumber))
.replace('%7Bpath%7D', source.fileName)
.replace('%7Bline%7D', String(source.lineNumber));
window.open(url);
}, [inspectedElement, editorURL]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,13 @@ export default function ComponentsSettings(_: {}): React.Node {

const [openInEditorURLPreset, setOpenInEditorURLPreset] = useLocalStorage<
'vscode' | 'custom',
>(LOCAL_STORAGE_OPEN_IN_EDITOR_URL_PRESET, 'vscode');
>(LOCAL_STORAGE_OPEN_IN_EDITOR_URL_PRESET, 'custom');

const [openInEditorURL, setOpenInEditorURL] = useLocalStorage<string>(
LOCAL_STORAGE_OPEN_IN_EDITOR_URL,
getDefaultOpenInEditorURL(),
);

useEffect(() => {
if (openInEditorURLPreset === 'vscode') {
setOpenInEditorURL('vscode://file/{path}:{line}');
} else {
setOpenInEditorURL('custom link');
}
}, [openInEditorURLPreset, setOpenInEditorURL]);

const [componentFilters, setComponentFilters] = useState<
Array<ComponentFilter>,
>(() => [...store.componentFilters]);
Expand Down Expand Up @@ -298,21 +290,31 @@ export default function ComponentsSettings(_: {}): React.Node {
<select
className={styles.Select}
value={openInEditorURLPreset}
onChange={({currentTarget}) =>
setOpenInEditorURLPreset(currentTarget.value)
}>
onChange={({currentTarget}) => {
const selectedValue = currentTarget.value;
setOpenInEditorURLPreset(selectedValue);
if (selectedValue === 'vscode') {
setOpenInEditorURL('vscode://file/{path}:{line}');
Copy link
Contributor

Choose a reason for hiding this comment

The 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>
<input
className={styles.Input}
type="text"
placeholder={process.env.EDITOR_URL ?? 'vscode://file/{path}:{line}'}
value={openInEditorURL}
onChange={event => {
setOpenInEditorURL(event.target.value);
}}
/>
{openInEditorURLPreset === 'custom' && (
<input
className={styles.Input}
type="text"
placeholder={
process.env.EDITOR_URL ? 'vscode://file/{path}:{line}' : ''
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
placeholder={
process.env.EDITOR_URL ? 'vscode://file/{path}:{line}' : ''
}
placeholder={getDefaultOpenInEditorURL()}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or process.env.EDITOR_URL ? process.env.EDITOR_URL : ''

value={openInEditorURL}
onChange={event => {
setOpenInEditorURL(event.target.value);
}}
/>
)}
</label>

<div className={styles.Header}>Hide components where...</div>
Expand Down