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

Conversation

Biki-das
Copy link
Contributor

@Biki-das Biki-das commented Jun 14, 2023

Currently the Open in editor just is a placeholder input where the developer would need to type the whole Vscode file path being shown as a placeholder, we can make this process a little easier by just already setting the URL .

Screen.Recording.2023-06-14.at.8.03.28.PM.mov

Earlier it used to be a placeholder describing the URL
Screenshot 2023-06-14 at 7 55 38 PM

cc @hoxyq

Copy link
Contributor

@hoxyq hoxyq left a comment

Choose a reason for hiding this comment

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

Great idea!

I left some comments, please also consider that we support setting the placeholder for the url value from environment variable EDITOR_URL. If this variable is set, we should display Custom option by default.

if (openInEditorURLPreset === 'vscode') {
setOpenInEditorURL('vscode://file/{path}:{line}');
} else {
setOpenInEditorURL('custom link');
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we leave it empty? Since the option label will be already "Custom"?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, why are you using useEffect for it? Can we update editorURL in onChange callback of select?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, why are you using useEffect for it? Can we update editorURL in onChange callback of select?

😅 ah! i was about to refactor dropping the useEffect, something like below

   const selectedValue = currentTarget.value;
            setOpenInEditorURLPreset(selectedValue);
            if (selectedValue === 'vscode') {
              setOpenInEditorURL('vscode://file/{path}:{line}');
            } else if (selectedValue === 'custom') {
              setOpenInEditorURL('');
            }
          }}>

Co-authored-by: Ruslan Lesiutin <rdlesyutin@gmail.com>
@Biki-das
Copy link
Contributor Author

@hoxyq will look at this tommorow , thanks for the nits!

@Biki-das
Copy link
Contributor Author

Biki-das commented Jun 15, 2023

@hoxyq made a few changes as per your request, waiting for another set of review!

i feel this UI feels more reasonable

Screen.Recording.2023-06-15.at.1.43.17.PM.mov

Copy link
Contributor

@hoxyq hoxyq left a comment

Choose a reason for hiding this comment

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

Thanks!

I thing we need two more things before merging this:

  1. Can you please add a small margin between select and input?
  2. Can you update / add new tests for this logic inside these react components? For both internal case (when EDITOR_URL env variable is set) and for public with custom url case

Comment on lines 309 to 311
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 : ''

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?

@Biki-das
Copy link
Contributor Author

Biki-das commented Jun 15, 2023

@hoxyq thanks for the nits! i would try to make the changes as you requested! Could you confirm the test file location for the ones you asked me to write tests! packages/react-devtools-shared/src/__tests__/componentStacks-test.js is this the one!

@hoxyq
Copy link
Contributor

hoxyq commented Jun 16, 2023

@hoxyq thanks for the nits! i would try to make the changes as you requested! Could you confirm the test file location for the ones you asked me to write tests! packages/react-devtools-shared/src/__tests__/componentStacks-test.js is this the one!

No, I think you need to create a new one, something like ComponentSettings-test.js, because this is the component that you will test

@Biki-das
Copy link
Contributor Author

@hoxyq on running the test getting this error

Error

$ C:\Users\bikid\react-1\node_modules.bin\jest ComponentSettings-test.js
FAIL src/tests/ComponentSettings-test.js
● Test suite failed to run

ReferenceError: __DEV__ is not defined

  10 |
  11 | const emptyObject = {};
> 12 | if (__DEV__) {
     | ^
  13 |   Object.freeze(emptyObject);
  14 | }
  15 |

  at Object.<anonymous> (../react/src/ReactBaseClasses.js:12:1)
  at Object.<anonymous> (../react/src/React.js:25:1)
  at Object.<anonymous> (../react/index.js:33:1)
  at Object.<anonymous> (src/__tests__/ComponentSettings-test.js:10:1)

Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 1.555 s
Ran all test suites matching /ComponentSettings-test.js/i.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @flow
 */

import React from 'react';
import {render, fireEvent} from '@testing-library/react';
import ComponentsSettings from './ComponentsSettings';

describe('ComponentsSettings', () => {
  it('should add a filter when "Add filter" button is clicked', () => {
    const {getByText} = render(<ComponentsSettings />);
    const addButton = getByText('Add filter');

    fireEvent.click(addButton);

    // Assert that a new filter is added
    expect(getByText('Filter matches')).toBeInTheDocument();
  });

  it('should remove a filter when "Delete filter" button is clicked', () => {
    const {getByText, queryByText} = render(<ComponentsSettings />);
    const addButton = getByText('Add filter');
    const deleteButton = getByText('Delete filter');

    fireEvent.click(addButton);
    fireEvent.click(deleteButton);

    // Assert that the filter is removed
    expect(queryByText('Filter matches')).toBeNull();
  });

  it('should update the collapseNodesByDefault setting when expand/collapse checkbox is clicked', () => {
    const {getByLabelText} = render(<ComponentsSettings />);
    const expandCollapseCheckbox = getByLabelText(
      'Expand component tree by default',
    );

    fireEvent.click(expandCollapseCheckbox);

    // Assert that the setting is updated
    expect(expandCollapseCheckbox.checked).toBe(false);
  });

  it('should update the parseHookNames setting when parse hook names checkbox is clicked', () => {
    const {getByLabelText} = render(<ComponentsSettings />);
    const parseHookNamesCheckbox = getByLabelText(
      'Always parse hook names from source',
    );

    fireEvent.click(parseHookNamesCheckbox);

    // Assert that the setting is updated
    expect(parseHookNamesCheckbox.checked).toBe(true);
  });

  it('should update the openInEditorURLPreset and openInEditorURL settings when selecting a different preset', () => {
    const {getByLabelText, getByPlaceholderText} = render(
      <ComponentsSettings />,
    );
    const openInEditorURLPresetSelect = getByLabelText('Open in Editor URL:');
    const openInEditorURLInput = getByPlaceholderText(
      'vscode://file/{path}:{line}',
    );

    // Select the "VS Code" preset
    fireEvent.change(openInEditorURLPresetSelect, {target: {value: 'vscode'}});

    // Assert that the preset and URL input are updated
    expect(openInEditorURLPresetSelect.value).toBe('vscode');
    expect(openInEditorURLInput.value).toBe('vscode://file/{path}:{line}');

    // Select the "Custom" preset
    fireEvent.change(openInEditorURLPresetSelect, {target: {value: 'custom'}});

    // Assert that the preset and URL input are updated
    expect(openInEditorURLPresetSelect.value).toBe('custom');
    expect(openInEditorURLInput.value).toBe('');

    // Update the custom URL input
    fireEvent.change(openInEditorURLInput, {
      target: {value: 'https://example.com'},
    });

    // Assert that the custom URL input is updated
    expect(openInEditorURLInput.value).toBe('https://example.com');
  });

  it('should update the filter type when selecting a different type in the filter dropdown', () => {
    const {getByText, getByLabelText} = render(<ComponentsSettings />);
    const addButton = getByText('Add filter');
    fireEvent.click(addButton);

    const filterTypeSelect = getByLabelText('Filter type:');
    fireEvent.change(filterTypeSelect, {target: {value: 'location'}});

    // Assert that the filter type is updated
    expect(filterTypeSelect.value).toBe('location');
  });

  it('should update the filter value when entering a value in the filter input field', () => {
    const {getByText, getByPlaceholderText} = render(<ComponentsSettings />);
    const addButton = getByText('Add filter');
    fireEvent.click(addButton);

    const filterInput = getByPlaceholderText('Enter filter value');
    fireEvent.change(filterInput, {target: {value: 'example'}});

    // Assert that the filter value is updated
    expect(filterInput.value).toBe('example');
  });

  // Add more test cases for other functionality and interactions
});




@hoxyq
Copy link
Contributor

hoxyq commented Jun 16, 2023

@hoxyq on running the test getting this error

Error

$ C:\Users\bikid\react-1\node_modules.bin\jest ComponentSettings-test.js FAIL src/tests/ComponentSettings-test.js ● Test suite failed to run

ReferenceError: __DEV__ is not defined

  10 |
  11 | const emptyObject = {};
> 12 | if (__DEV__) {
     | ^
  13 |   Object.freeze(emptyObject);
  14 | }
  15 |

  at Object.<anonymous> (../react/src/ReactBaseClasses.js:12:1)
  at Object.<anonymous> (../react/src/React.js:25:1)
  at Object.<anonymous> (../react/index.js:33:1)
  at Object.<anonymous> (src/__tests__/ComponentSettings-test.js:10:1)

Test Suites: 1 failed, 1 total Tests: 0 total Snapshots: 0 total Time: 1.555 s Ran all test suites matching /ComponentSettings-test.js/i. error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @flow
 */

import React from 'react';
import {render, fireEvent} from '@testing-library/react';
import ComponentsSettings from './ComponentsSettings';

describe('ComponentsSettings', () => {
  it('should add a filter when "Add filter" button is clicked', () => {
    const {getByText} = render(<ComponentsSettings />);
    const addButton = getByText('Add filter');

    fireEvent.click(addButton);

    // Assert that a new filter is added
    expect(getByText('Filter matches')).toBeInTheDocument();
  });

  it('should remove a filter when "Delete filter" button is clicked', () => {
    const {getByText, queryByText} = render(<ComponentsSettings />);
    const addButton = getByText('Add filter');
    const deleteButton = getByText('Delete filter');

    fireEvent.click(addButton);
    fireEvent.click(deleteButton);

    // Assert that the filter is removed
    expect(queryByText('Filter matches')).toBeNull();
  });

  it('should update the collapseNodesByDefault setting when expand/collapse checkbox is clicked', () => {
    const {getByLabelText} = render(<ComponentsSettings />);
    const expandCollapseCheckbox = getByLabelText(
      'Expand component tree by default',
    );

    fireEvent.click(expandCollapseCheckbox);

    // Assert that the setting is updated
    expect(expandCollapseCheckbox.checked).toBe(false);
  });

  it('should update the parseHookNames setting when parse hook names checkbox is clicked', () => {
    const {getByLabelText} = render(<ComponentsSettings />);
    const parseHookNamesCheckbox = getByLabelText(
      'Always parse hook names from source',
    );

    fireEvent.click(parseHookNamesCheckbox);

    // Assert that the setting is updated
    expect(parseHookNamesCheckbox.checked).toBe(true);
  });

  it('should update the openInEditorURLPreset and openInEditorURL settings when selecting a different preset', () => {
    const {getByLabelText, getByPlaceholderText} = render(
      <ComponentsSettings />,
    );
    const openInEditorURLPresetSelect = getByLabelText('Open in Editor URL:');
    const openInEditorURLInput = getByPlaceholderText(
      'vscode://file/{path}:{line}',
    );

    // Select the "VS Code" preset
    fireEvent.change(openInEditorURLPresetSelect, {target: {value: 'vscode'}});

    // Assert that the preset and URL input are updated
    expect(openInEditorURLPresetSelect.value).toBe('vscode');
    expect(openInEditorURLInput.value).toBe('vscode://file/{path}:{line}');

    // Select the "Custom" preset
    fireEvent.change(openInEditorURLPresetSelect, {target: {value: 'custom'}});

    // Assert that the preset and URL input are updated
    expect(openInEditorURLPresetSelect.value).toBe('custom');
    expect(openInEditorURLInput.value).toBe('');

    // Update the custom URL input
    fireEvent.change(openInEditorURLInput, {
      target: {value: 'https://example.com'},
    });

    // Assert that the custom URL input is updated
    expect(openInEditorURLInput.value).toBe('https://example.com');
  });

  it('should update the filter type when selecting a different type in the filter dropdown', () => {
    const {getByText, getByLabelText} = render(<ComponentsSettings />);
    const addButton = getByText('Add filter');
    fireEvent.click(addButton);

    const filterTypeSelect = getByLabelText('Filter type:');
    fireEvent.change(filterTypeSelect, {target: {value: 'location'}});

    // Assert that the filter type is updated
    expect(filterTypeSelect.value).toBe('location');
  });

  it('should update the filter value when entering a value in the filter input field', () => {
    const {getByText, getByPlaceholderText} = render(<ComponentsSettings />);
    const addButton = getByText('Add filter');
    fireEvent.click(addButton);

    const filterInput = getByPlaceholderText('Enter filter value');
    fireEvent.change(filterInput, {target: {value: 'example'}});

    // Assert that the filter value is updated
    expect(filterInput.value).toBe('example');
  });

  // Add more test cases for other functionality and interactions
});

Can you try to run this test via yarn test --project devtools --build ComponentSettings?

@Biki-das
Copy link
Contributor Author

@hoxyq , does not seem to work :-(

yarn test --project devtools --build ComponentSettings
yarn run v1.22.19
error Command "test" not found. Did you mean "jest"?

@hoxyq
Copy link
Contributor

hoxyq commented Jun 17, 2023

@hoxyq , does not seem to work :-(

yarn test --project devtools --build ComponentSettings
yarn run v1.22.19
error Command "test" not found. Did you mean "jest"?

Are you running this command from root folder?

@Biki-das
Copy link
Contributor Author

Biki-das commented Jun 17, 2023

@hoxyq , does not seem to work :-(

yarn test --project devtools --build ComponentSettings
yarn run v1.22.19
error Command "test" not found. Did you mean "jest"?

Are you running this command from root folder?

yep tried from the repo root folder and also by making the cd to the test file , both did not work!


react-1 on  devtools-editor-patch [!?] via  v16.20.0
❯ yarn test --project devtools --build ComponentSettings
yarn run v1.22.19
$ node ./scripts/jest/jest-cli.js --project devtools --build ComponentSettings

Build directory does not exist, please run `yarn build` or remove the --build option.

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

react-1 on  devtools-editor-patch [!?] via  v16.20.0
❯



@hoxyq
Copy link
Contributor

hoxyq commented Jun 19, 2023

@hoxyq , does not seem to work :-(

yarn test --project devtools --build ComponentSettings
yarn run v1.22.19
error Command "test" not found. Did you mean "jest"?

Are you running this command from root folder?

yep tried from the repo root folder and also by making the cd to the test file , both did not work!


react-1 on  devtools-editor-patch [!?] via  v16.20.0
❯ yarn test --project devtools --build ComponentSettings
yarn run v1.22.19
$ node ./scripts/jest/jest-cli.js --project devtools --build ComponentSettings

Build directory does not exist, please run `yarn build` or remove the --build option.

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

react-1 on  devtools-editor-patch [!?] via  v16.20.0
❯

Try to run yarn build before this command, as it is recommended in the error message:

Build directory does not exist, please run yarn build or remove the --build option.

@Biki-das
Copy link
Contributor Author

Biki-das commented Jun 19, 2023

hey @hoxyq test have started to run , am i allowed to install the react-testing-library? also what could be the reason, the test are being skipped by Jest!
Screenshot 2023-06-19 at 6 07 35 PM

this is where i have created the test file, it ain't wrong i guess!

@Biki-das
Copy link
Contributor Author

@hoxyq can i install react testing library to write the tests?

@Biki-das
Copy link
Contributor Author

Biki-das commented Jun 19, 2023

@hoxyq can i install react testing library to write the tests?

Rest all work is done, the input now renders with a small amount of margin from left

confused while running the test,

 TypeError: Cannot read properties of null (reading 'parseHookNames')

      57 | export default function ComponentsSettings(_: {}): React.Node {
      58 |   const store = useContext(StoreContext);
    > 59 |   const {parseHookNames, setParseHookNames} = useContext(SettingsContext);

i think an example from you running the test might help, the test are running but i am not able to understand the error messages!

@Biki-das Biki-das requested a review from hoxyq June 20, 2023 07:15
@hoxyq
Copy link
Contributor

hoxyq commented Jun 20, 2023

@hoxyq can i install react testing library to write the tests?

Will this work properly with the fact that we are using React from source?

TypeError: Cannot read properties of null (reading 'parseHookNames')

I believe you need to mock the SettingsContext.

<input
className={styles.Input}
type="text"
placeholder={process.env.EDITOR_URL ? process.env.EDITOR_URL : ''}
Copy link

@subashcs subashcs Jun 20, 2023

Choose a reason for hiding this comment

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

{process.env.EDITOR_URL || ' ' } would be a cleaner approach.

@Biki-das
Copy link
Contributor Author

@hoxyq tried mocking the setting context still not able to write tests properly, could you help out to write a few tests so we can progress with this PR, if you find some time!

@Biki-das
Copy link
Contributor Author

@Jack-Works could you help out with the test i am sort of confused on writing it, a small help would be appreciated :-)

see comment
#26949 (review)

<input
className={styles.Input}
type="text"
placeholder={process.env.EDITOR_URL ? process.env.EDITOR_URL : ''}
Copy link
Contributor

Choose a reason for hiding this comment

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

please add a try-catch around process.env.EDITOR_URL, it might throw an error because process is undefined

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you possibly help out with the tests, i tried to but could not wrap my head around the structure for the same! The file is already initialized could you try something up :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if there is an old test for the settings panel and you can add things there

Comment on lines +42 to +44
export const LOCAL_STORAGE_OPEN_IN_EDITOR_URL_PRESET =
'React::DevTools::openInEditorUrlPreset';

Copy link
Contributor

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 the VSCode option. That will be simpler.

Copy link
Contributor

@Jack-Works Jack-Works Jul 26, 2023

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

Copy link
Contributor

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

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 to VSCode option and hide input?

Copy link
Contributor Author

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

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 to VSCode option and hide input?

yup current implementation looks right i think @hoxyq

Copy link
Contributor

Choose a reason for hiding this comment

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

For example, if I select "custom" and then put "vscode://file/{path}:{line}", should we automatically switch to VSCode option and hide input?

Yes. I think this is good, but plz continue this PR if you don't agree with me!

Comment on lines 23 to 29
const useContextMock = jest.fn().mockReturnValue({
collapseNodesByDefault: true,
addListener: jest.fn(),
removeListener: jest.fn(),
});

render(<ComponentsSettings />, container);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please try to render ComponentsSettings wrapper in required contexts?
Like this:

render(
  <StoreContext.Provider value={...}>
    <SettingsContext.Provider value={...}>
      <ComponentsSettings />
    </SettingsContext.Provider>
  </StoreContext.Provider>,
  container
);

I think this should resolve your problem with mocking contexts and you won't be required to mock useContextMock

Copy link
Contributor

Choose a reason for hiding this comment

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

cc @Biki-das, have you tried this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hoxyq let me try :-) , was busy with other stuff!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the issue here is i don't have experience testing react components without rtl 😅, so i am really struggline to make this up!
Plain jest tests are hard to come up with

Copy link
Contributor

Choose a reason for hiding this comment

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

There is no rush, thanks for working on this!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hoxyq did you looked the test files?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not yet, sorry, I am finishing something and then will take a look at this, it is still in my queue

Copy link
Contributor

Choose a reason for hiding this comment

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

I've tried to find a workaround for these tests, but I think we will need to find a better approach on how they should be implemented.

We can remove these tests for now:

  • We don't have a good example with unit tests for custom components, some tests seem outdated and cover integration with user code
  • It is quite painful atm to write tests with using dispatchEvent because of how SyntheticEvents work

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup that's what i felt too, when i started out, so for now we would remove the test and get this merged?

Copy link
Contributor

Choose a reason for hiding this comment

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

yup that's what i felt too, when i started out, so for now we would remove the test and get this merged?

Yes, I will review the PR after your changes and hope we can ship this soon :)

container = null;
});

// @reactVersion >= 17
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove these annotations, my change has landed on main, so these tests should be included in tests runs now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup i was going to remove it eventually!

@Biki-das
Copy link
Contributor Author

@hoxyq Now the PR is at the stage of how it was working and doing as it was expected to do, if you have any changes to request please review back and direct me the same!

Copy link
Contributor

@hoxyq hoxyq left a comment

Choose a reason for hiding this comment

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

Looks good to me, one small nit is to move constant outside of component.

Please address it, I will also poke it tomorrow and if everything is good, will merge it, thanks!

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

const vscodeFilepath = '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 move it outside of function? Same file, but outside of the component.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for the review! let me do the same :-)

@hoxyq hoxyq merged commit 493f72b into facebook:main Jul 27, 2023
2 checks passed
@Biki-das Biki-das deleted the devtools-editor-patch branch July 27, 2023 16:26
hoxyq added a commit that referenced this pull request Aug 29, 2023
List of changes:
* refactor: refactored devtools browser extension scripts to improve
port management and service worker lifetime
([hoxyq](https://github.com/hoxyq) in
[#27215](#27215))
* refactor[devtools/extension]: minify production builds to strip
comments ([hoxyq](https://github.com/hoxyq) in
[#27304](#27304))
* fix[devtools]: allow element updates polling only if bridge is alive
([hoxyq](https://github.com/hoxyq) in
[#27067](#27067))
* refactor: resolve browser via env variables based on build rather than
user agent ([hoxyq](https://github.com/hoxyq) in
[#27179](#27179))
* fix[devtools/updateFiberRecursively]: mount suspense fallback set in
timed out case ([hoxyq](https://github.com/hoxyq) in
[#27147](#27147))
* Feat:-Added open in editor to appear by default
([Biki-das](https://github.com/Biki-das) in
[#26949](#26949))
* fix[devtools/inspect]: null check memoized props before trying to call
hasOwnProperty ([hoxyq](https://github.com/hoxyq) in
[#27057](#27057))
* rename SuspenseList export to unstable_SuspenseList
([noahlemen](https://github.com/noahlemen) in
[#27061](#27061))
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
Currently the Open in editor just is a placeholder input where the
developer would need to type the whole Vscode file path being shown as a
placeholder, we can make this process a little easier by just already
setting the URL .




https://github.com/facebook/react/assets/72331432/96f43230-6c49-45f7-907c-c99a0d3d8bf7

Earlier it used to be a placeholder describing the URL
<img width="1284" alt="Screenshot 2023-06-14 at 7 55 38 PM"
src="https://github.com/facebook/react/assets/72331432/4e8234ad-e1cd-4b55-8ef8-46dea82a9c7c">


cc @hoxyq

---------

Co-authored-by: Ruslan Lesiutin <rdlesyutin@gmail.com>
Co-authored-by: BIKI <biki@BIKIs-MacBook-Pro.local>
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
List of changes:
* refactor: refactored devtools browser extension scripts to improve
port management and service worker lifetime
([hoxyq](https://github.com/hoxyq) in
[facebook#27215](facebook#27215))
* refactor[devtools/extension]: minify production builds to strip
comments ([hoxyq](https://github.com/hoxyq) in
[facebook#27304](facebook#27304))
* fix[devtools]: allow element updates polling only if bridge is alive
([hoxyq](https://github.com/hoxyq) in
[facebook#27067](facebook#27067))
* refactor: resolve browser via env variables based on build rather than
user agent ([hoxyq](https://github.com/hoxyq) in
[facebook#27179](facebook#27179))
* fix[devtools/updateFiberRecursively]: mount suspense fallback set in
timed out case ([hoxyq](https://github.com/hoxyq) in
[facebook#27147](facebook#27147))
* Feat:-Added open in editor to appear by default
([Biki-das](https://github.com/Biki-das) in
[facebook#26949](facebook#26949))
* fix[devtools/inspect]: null check memoized props before trying to call
hasOwnProperty ([hoxyq](https://github.com/hoxyq) in
[facebook#27057](facebook#27057))
* rename SuspenseList export to unstable_SuspenseList
([noahlemen](https://github.com/noahlemen) in
[facebook#27061](facebook#27061))
bigfootjon pushed a commit that referenced this pull request Apr 18, 2024
Currently the Open in editor just is a placeholder input where the
developer would need to type the whole Vscode file path being shown as a
placeholder, we can make this process a little easier by just already
setting the URL .

https://github.com/facebook/react/assets/72331432/96f43230-6c49-45f7-907c-c99a0d3d8bf7

Earlier it used to be a placeholder describing the URL
<img width="1284" alt="Screenshot 2023-06-14 at 7 55 38 PM"
src="https://github.com/facebook/react/assets/72331432/4e8234ad-e1cd-4b55-8ef8-46dea82a9c7c">

cc @hoxyq

---------

Co-authored-by: Ruslan Lesiutin <rdlesyutin@gmail.com>
Co-authored-by: BIKI <biki@BIKIs-MacBook-Pro.local>

DiffTrain build for commit 493f72b.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants