Add "open in new tab" context menu entry for links
Categories
(DevTools :: Console, enhancement, P5)
Tracking
(firefox72 fixed)
Tracking | Status | |
---|---|---|
firefox72 | --- | fixed |
People
(Reporter: sworddragon2, Assigned: raymond.liu.dev, Mentored)
References
Details
(Keywords: good-first-bug, Whiteboard: [btpp-backlog])
Attachments
(4 files)
610 bytes,
patch
|
Details | Diff | Splinter Review | |
3.74 KB,
patch
|
Details | Diff | Splinter Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review |
Reporter | ||
Updated•9 years ago
|
Updated•9 years ago
|
Comment 1•9 years ago
|
||
Updated•6 years ago
|
Updated•6 years ago
|
Updated•6 years ago
|
Updated•6 years ago
|
Comment 3•6 years ago
|
||
Hello! I'm looking for good-first-bugs to start contributing as I'm applying for the Outreachy internship. Would it be a good one to start with? In that case, I would like to try it.
Comment 4•6 years ago
|
||
Hi, I am Phoenix, a current Outreachy applicant.
Is this a good bug to start with for contributions..???
I would be happy to work on this :)
Comment 5•6 years ago
|
||
Hi,
I'm trying to handle this bug and I have a question. I've added the "Open URL in New Tab" on the context menu. Here's a screenshot: https://paste.pics/ccd11aa2676cf3925341c6d083b1d974
Currently, I'm using a regex pattern to detect if the text selected is a url and it works but I was wondering if there's better solution. Is there some sort of attribute that I can use to enable the option only when the variableText is a url?
For example, when I console.log("http://www.google.com") the console recognizes that it's a url and I can click on it but when I console.log("www.google.com") it's not clickable. How does the console recognize that it's a link and make it clickable?
Thank you!
Comment 6•6 years ago
|
||
Oh I'm sorry! I didn't see the other people before me. Should I still submit the patch?
Comment 7•6 years ago
|
||
Well, I was still waiting for an answer from Nicolas, Rainier.
Comment 8•6 years ago
|
||
Sounds good!
Comment 9•6 years ago
|
||
Heey. would love to take this up as a first bug. I hope its okay.
Comment 10•6 years ago
|
||
Thanks a lot everyone, it's nice to see your enthusiasm :)
Helenatxu, do you want to work on this bug rather than on the one I pinged you on? You have the priority here since you commented first :)
Rainier, make sure to read the whole thread before commenting and start to work on things :)
Getty, you're coming last here :), and as discussed over email, you may work on another bug.
Comment 11•6 years ago
|
||
Got it!! Thanks Nicolas!
Comment 12•6 years ago
|
||
(In reply to Nicolas Chevobbe from comment #10)
Thanks a lot everyone, it's nice to see your enthusiasm :)
Helenatxu, do you want to work on this bug rather than on the one I pinged you on? You have the priority here since you commented first :)
No problem, I would say let's leave Rainier to upload the code as she/he already worked on it. But I agree, make sure to read the whole thread before commenting and start to work on things next time.
Comment 13•6 years ago
|
||
Hey Helen! Thanks, but I'm not an Outreachy applicant so if you need the bug for the program I'd be more than happy to just let you handle the bug.
Comment 14•6 years ago
|
||
Looks like Helena has another bug assigned, so I'm assigning it to Rainier.
Rainer, you might want to read Bug 1457111#c11 where I explained how we can get the url and add a context menu entry.
Feel free to ask any question, either here or on our Slack.
Comment 15•6 years ago
|
||
Hey there, I'm an Outreachy applicant! Can I take on this bug? Would you recommend other first bugs?
Comment 16•6 years ago
|
||
(In reply to Lily from comment #15)
Hey there, I'm an Outreachy applicant! Can I take on this bug? Would you recommend other first bugs?
Hey Lily, sorry but this bug is already assigned (even if I did not set the appropriate flags).
I'll try to find new good first bug today :)
Comment 17•6 years ago
|
||
Hello Rainier, how is it going on? Are you blocked on anything?
Comment 18•6 years ago
|
||
Hey Nicolas! Sorry for going MIA I've been a bit busy. I'll have something up either today or tomorrow
Comment 19•6 years ago
|
||
Hey Nicolas, so I was looking at Bug 1457111#c11 and you mentioned how to get the link you would need to get the href attribute of an <a> tag, but because we're console.logging a string and not a DOM element my mind goes to regex. Is there another way of going about it?
Comment 20•6 years ago
|
||
Hm in my mind the console would detect that it's a link and then turns it into a clickable text similar to console-test-script.js:47:24
in the example you gave for Bug 1457111.
Comment 21•6 years ago
|
||
Hello Rainier,
if you look at that devtools/client/webconsole/utils/context-menu.js#51 you can see that now we have access to an url that might be clicked on. So you should only need to check that the url
param is not falsy, and create the MenuItem
(like in devtools/client/webconsole/utils/context-menu.js#211-218 , you might want to create the item in the same if
block).
Hope it helps :)
Comment 22•6 years ago
|
||
Hello Rainier,
IS there anything blocking you on this bug? (if you don't have the time to work on it, that's perfectly fine :) )
Comment 23•6 years ago
|
||
clearing assignee
Comment 24•6 years ago
|
||
Hello Nicolas
I would like to work on this bug.
Olena
Comment 25•6 years ago
|
||
Hello Olena, thanks for offering help :) The bug is now assigned to you.
You can take a look at http://docs.firefox-dev.tools/getting-started/ to setup the work environment.
Then, you can follow what I was saying on Comment 21 to see what needs to be done to make this work.
Don't hesitate to ask any question, either here or on Slack.
Updated•6 years ago
|
Comment 26•6 years ago
|
||
Hello Nicolas
So I added new menu item to the context menu. The patch is attached. But I have a couple of questions :)
- What is the right way to check if we are dealing with the url? Some menu items use property 'visible' to check on some conditions to determine if the item should be shown or not. And some use 'if blocks' for this purpose. Shouldn't it be consistent?
- This context menu already has 'Open URL in New Tab' for the network requests. And this menu item situated at the top part of the menu while those link-connected menu items are at the bottom part. Maybe, whenever this menu item is visible it should be at the same line of the menu?
Comment 27•6 years ago
|
||
Hello Olena, thanks for working on this!
What is the right way to check if we are dealing with the url? Some menu items use property 'visible' to check on some conditions to determine if the item should be shown or not. And some use 'if' blocks for this purpose. Shouldn't it be consistent?
Yes, we should be consistent. My preference would be to put those into if
blocks: if the menu item won't be visible, we shouldn't create it at all (because we're spending much needed time for something that will be useless).
This context menu already has 'Open URL in New Tab' for the network requests. And this menu item situated at the top part of the menu while those link-connected menu items are at the bottom part. Maybe, whenever this menu item is visible it should be at the same line of the menu?
Yeah, it would be nice to re-organize the context menu, as it grew a bit organically and could be better.
We should do that in a follow-up bug, as this one should only be related to the new entry.
By testing the patch, I see that it doesn't open the link in the background, which it should do (if we want to be similar to Firefox's links context menu). We also want the tab to open right-next to the current one.
You can do that by passing options to openContentLink
:
openContentLink(url, {
inBackground: true,
relatedToCurrent: true,
})
After that, we'll need a test to make sure the context menu entry appears when we right-click on a link.
You can check devtools/client/webconsole/test/mochitest/browser_webconsole_context_menu_copy_link_location.js to get some inspiration for checking the context menu entry, and devtools/client/webconsole/test/mochitest/browser_webconsole_clickable_urls.js to see how to check that the link was opened in the background.
When all of this is done, your patch will be ready for review, and you can follow https://docs.firefox-dev.tools/contributing/code-reviews.html to know how to ask for review on a patch :)
Thank you again!
Comment 28•5 years ago
|
||
Hello Olena,
Do you still plan to work on this one? That's totally okay if you can't/don't want :)
Comment 29•5 years ago
|
||
Yes, I'm sorry. I still plan to work on it. I'll try to finish it in the nearest time.
Comment 30•5 years ago
|
||
No activity for 2 months. Unassigning for now. But feel free to claim it again if/when you plan on working on it again. In the meantime let's open this up to other people.
Assignee | ||
Comment 31•5 years ago
|
||
Hello, I am a University of Toronto student interested in picking this bug up as my first Mozilla bug. Can I work on this?
Assignee | ||
Comment 32•5 years ago
|
||
I followed Nicolas' recommendations above. Since browser_webconsole_clickable_urls.js already has some tests for checking for "Open URL in New Tab", I added a new test for this change to that file.
Assignee | ||
Comment 33•5 years ago
|
||
Assignee | ||
Comment 34•5 years ago
|
||
(In reply to Raymond Liu from comment #32)
I followed Nicolas' recommendations above. Since browser_webconsole_clickable_urls.js already has some tests for checking for "Open URL in New Tab", I added a new test for this change to that file.
That is a typo, I meant browser_webconsole_context_menu_open_url.js.
Comment 35•5 years ago
|
||
Hello Raymond, thanks for taking this one. The bug is now assigned to you.
Could you send the patch to phabricator please? https://docs.firefox-dev.tools/contributing/making-prs.html (make sure to use moz-phab
and not arc
as stated in the doc).
Assignee | ||
Comment 36•5 years ago
|
||
I can't seem to run moz-phab. I get this error 'Failed to run /home/rayml/.mozbuild/moz-phab/arcanist/bin/arc.'
I installed moz-phab using pip3 install --user MozPhab
Assignee | ||
Comment 37•5 years ago
|
||
Updated•5 years ago
|
Assignee | ||
Comment 38•5 years ago
|
||
Comment 39•5 years ago
|
||
Comment 40•5 years ago
|
||
bugherder |
Description
•