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

[WebProfiler] Add copy button on runnable and formatted queries #1056

Merged
merged 3 commits into from Jan 26, 2020

Conversation

fancyweb
Copy link
Contributor

@fancyweb fancyweb commented Nov 18, 2019

This PR adds a "copy" button on runnable queries.

I also took the opportunity to copy paste all the specific CSS for the Doctrine panel from Symfony core inside this bundle so we can remove it from Symfony core (in 5.0). Let me know if you prefer to have the two things splitted for clarity.

Screenshot:
Screenshot 2019-11-18 at 18 11 31

@fancyweb fancyweb changed the title [WebProfiler] Add copy button on runnable queries [WIP][WebProfiler] Add copy button on runnable queries Nov 18, 2019
@stof
Copy link
Member

stof commented Nov 18, 2019

I'm wondering whether we should bundle the clipboard.js library here (and maybe again in another bundle wanting to provide such button), or whether we should add a feature in the WebProfilerBundle JS to allow having such copy button easily anywhere in the WebProfilerBundle (no duplicate in each bundle) using native APIs.

Note that clipboard.js does 2 things mainly:

  • adding DOM listeners to trigger the copy, which is easy to do in the Sfjs code
  • implementing a cross-browser way to write text to the clipboard. But as the profiler UI only cares about modern browsers (not true for the toolbar itself), this is unnecessary. Modern code for that is navigator.clipboard.writeText() (inside the click listener, as it requires a user-gesture)

@fancyweb
Copy link
Contributor Author

Having a copy button in Symfony's core totally makes sense indeed 👍 Replacing clipboard.js by custom code is fine as well.

However, as a new feature, this copy button would now be available in Symfony WPB 5.1 while we support 3.4 here. Can we add it like this firstly and if someone ever implements it in core (I personally don't have the skills to do it), we then remove our "own" copy button implementation from the DoctrineBundle?

Tests/ProfilerTest.php Outdated Show resolved Hide resolved
@alcaeus alcaeus added this to 2.x in Roadmap Nov 19, 2019
@stof
Copy link
Member

stof commented Nov 19, 2019

btw, even if we keep it in DoctrineBundle, we could avoid bundling the library.

@fancyweb fancyweb changed the title [WIP][WebProfiler] Add copy button on runnable queries [WAIT][WebProfiler] Add copy button on runnable queries Nov 19, 2019
@beberlei
Copy link
Member

beberlei commented Dec 7, 2019

I want to back @stof here with navigator.clipboard.writeText. Users of the profiler have modern browsers, so we can be sure that API exists, otherwise just not show the button is also fine.

@ostrolucky
Copy link
Member

ostrolucky commented Dec 7, 2019

Agreed. @fancyweb can you please remove bundling of library and replace with native API? Then we don't need this upstream.

@ostrolucky
Copy link
Member

I've removed clipboard.js, unrelated changes and implemented copy button for formatted query too
Screenshot 2020-01-04 at 16 35 47

Ready to review

@ostrolucky ostrolucky changed the base branch from 1.12.x to master January 4, 2020 15:37
@ostrolucky ostrolucky self-assigned this Jan 4, 2020
@ostrolucky ostrolucky changed the title [WAIT][WebProfiler] Add copy button on runnable queries [WebProfiler] Add copy button on runnable queries Jan 4, 2020
@ostrolucky ostrolucky changed the title [WebProfiler] Add copy button on runnable queries [WebProfiler] Add copy button on runnable and formatted queries Jan 4, 2020
Copy link
Contributor Author

@fancyweb fancyweb left a comment

Choose a reason for hiding this comment

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

Thanks for continuing this @ostrolucky!

Resources/views/Collector/db.html.twig Outdated Show resolved Hide resolved
@ostrolucky ostrolucky merged commit 5ff92f1 into doctrine:master Jan 26, 2020
@fancyweb fancyweb deleted the add-copy-btn branch January 27, 2020 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging this pull request may close these issues.

None yet

5 participants