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

Add PHPStorm via IDE Remote Control plugin link option #262

Merged
merged 1 commit into from
May 25, 2023

Conversation

raveren
Copy link
Contributor

@raveren raveren commented Apr 13, 2023

Fixes spatie/laravel-ignition#141

I hope that's enough? I think the github resources pipeline compiles the js for the dropdown..?

If this is merged I'll PR a change for this comment as well:
https://github.com/spatie/laravel-ignition/blob/c21309ebf6657e0c38083afac8af9baa12885676/config/ignition.php#L35

@raveren
Copy link
Contributor Author

raveren commented Apr 28, 2023

I fixed a typo and shortened the option name to be more consistent with the rest (i.e. with VS Code Remote).

Unfortunately I found that even though it works - when clicking a link, Ignition redirects user to a blank page.

However, the IDE opens as intended, which is way way better than not having the link at all!


Xdebug author offers an alternative solution: adopted from https://xdebug.org/docs/all_settings#file_link_format:

'phpstorm-remote' => [
    'label' => 'PHPStorm via IDE Remote Control plugin',
    'url' => 'javascript:r = new XMLHttpRequest;r.open("get", "http://localhost:63342/api/file/%path:%line");r.send()',
],

Which works, but produces Warning: A future version of React will block javascript: URLs as a security precaution. in the browser developer console.

The most compatible and futureproof solution would be to always do the background XMLHttpRequest request for all editors, however I don't speak React and although the click handler should be added here: https://github.com/spatie/ignition-ui/blob/main/src/components/ui/EditorLink.tsx I can't do it on my own...

To test, I stupidly altered the compressed ignition.js where the <a> with IDE links is created (in two places) with onClick:()=>{const x = new XMLHttpRequest;x.open("get",r);x.send();return!1} and it works as intended, but I need someone fluent in React to help me please to do that part of the PR, I think all that's needed is an onclick event here:

https://github.com/spatie/ignition-ui/blob/main/src/components/ui/EditorLink.tsx#L15

Can someone please help?

@AlexVanderbist
Copy link
Member

Thank you for your PR and your patience! I will try your proposed change for sending IDE requests as XMLHttpRequests, but I'm afraid they won't work for the other editor links. We would need to add another config option to indicate whether the editor link is a "visit URL in browser" or "send request to endpoint" situation. I would be happy to merge something like that. In the meantime, the Xdebug JS URL solution may be a good compromise until React blocks those.

@AlexVanderbist AlexVanderbist merged commit bde77df into spatie:main May 25, 2023
4 checks passed
@raveren
Copy link
Contributor Author

raveren commented May 26, 2023

Wow, thanks for accepting the PR, it's a huge QOL improvement!

I made an effort to solve the concerns that you brought up, here is the first part, will need to update the configuration php file and documentation before it's fully done 😓 😃

spatie/ignition-ui#12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Open linked files in PHPStorm
2 participants