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 support for opening message in browser. #991

Merged
merged 3 commits into from
Jun 11, 2021

Conversation

zee-bit
Copy link
Member

@zee-bit zee-bit commented Apr 9, 2021

Thanks to @punchagan and @preetmishra for their major initial work in #397 and #698 respectively. 👍

This PR extracts some initial commits from both PR's and cleans and refactors them. It also adds support for opening external links in the browser from the MessageLinkButton. All the reviews on the previous PR's have also been addressed, facilitating further reviews.

Fixes last point of #452.

@zulipbot zulipbot added size: L [Automatic label added by zulipbot] size: XL [Automatic label added by zulipbot] and removed size: L [Automatic label added by zulipbot] labels Apr 9, 2021
@zee-bit zee-bit changed the title [WIP] Opening a message in the browser. Add support for opening message and external links in browser. Apr 10, 2021
Copy link
Member

@preetmishra preetmishra left a comment

Choose a reason for hiding this comment

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

@zee-bit Thanks for continuing the work. I have tested this locally with every type of narrow and this seems to work well! 👍

For the first iteration, I have left a few quick in-line comments (except for the last two commits). Of course, we would need to flesh out the security concerns prior to the merge.

While the last two commits extend the capability in a subtle way, we should perhaps introduce them post "Handle media links" PR as to an end-user it might not be apparent why some links (media links) don't open in the web browser while others do. This won't be an issue once we have the ability to handle media links in ZT itself.

zulipterminal/core.py Outdated Show resolved Hide resolved
zulipterminal/core.py Show resolved Hide resolved
zulipterminal/core.py Outdated Show resolved Hide resolved
zulipterminal/ui_tools/views.py Outdated Show resolved Hide resolved
tests/core/test_core.py Outdated Show resolved Hide resolved
zulipterminal/core.py Outdated Show resolved Hide resolved
@preetmishra
Copy link
Member

@zee-bit Hey, is this ready for another review iteration?

@preetmishra preetmishra added the PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback label Apr 18, 2021
@zee-bit
Copy link
Member Author

zee-bit commented Apr 18, 2021

@preetmishra Yes, I have already updated the PR according to your review, so it should be ready for the next iteration. :)

@zee-bit
Copy link
Member Author

zee-bit commented Apr 19, 2021

@zulipbot add "PR needs review"
@zulipbot remove "PR awaiting update"

@zulipbot zulipbot added PR needs review PR requires feedback to proceed and removed PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback labels Apr 19, 2021
Copy link
Member

@preetmishra preetmishra left a comment

Choose a reason for hiding this comment

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

@zee-bit Thanks for making the amendments! I have tested this locally (except the last two commits, see my last point in the previous review) and it seems to well. The messages open up in the expected near narrow for PMs and streams. 👍

@neiljp The first four commits look good to me! We could have them in if everything looks good to you as well.

Copy link
Collaborator

@neiljp neiljp left a comment

Choose a reason for hiding this comment

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

@zee-bit Thanks for pushing this feature forward again and @preetmishra for reviewing recently. The core features are looking good.

However, reading this there's a lot of intermediate refactoring of the new code added in this PR, which indicates the commits might be more "as explored" rather than as cleanly laid out with what we know what we want and can achieve - the tests are moved around quite a bit too. I'm not sure if more of the older commits were kept as they were for consistency, but you can always add Co-authored-by: <author> to the commit text to share authorship if things work better when split up, which you may want to do if you significantly add to (author) a commit in any case as the 'commit name' might be replaced by whoever merges the commits eventually. Of course if you completely rewrite, that's all you :)

I'm not completely opposed to the current structure and happy to discuss in the stream, but I'd suggest something like the following might be clearer (possibly with intermediate commits which we can squash together later after discussion):

  • Add output suppression functionality (same commit, by Puneeth)
  • Add open url in browser feature in near-final form, using output suppression & UI error handling (part of 2nd, adapted as per 5th?)
  • Add key+UI for opening message (current first commit + part of second + easy update using our library from the 4th)
  • General url opening implementation (to be discussed)

For sanity we could add an assert and/or tests to the url-opening method to ensure it's from the server, before we add general link opening, but it depends how we expect to proceed with general links - was the idea to maybe have a prompt like with media?

zulipterminal/core.py Show resolved Hide resolved
zulipterminal/core.py Outdated Show resolved Hide resolved
zulipterminal/core.py Outdated Show resolved Hide resolved
zulipterminal/ui_tools/views.py Show resolved Hide resolved
tests/core/test_core.py Outdated Show resolved Hide resolved
tests/ui_tools/test_popups.py Outdated Show resolved Hide resolved
zulipterminal/core.py Outdated Show resolved Hide resolved
tests/core/test_core.py Outdated Show resolved Hide resolved
zulipterminal/core.py Outdated Show resolved Hide resolved
zulipterminal/ui_tools/views.py Outdated Show resolved Hide resolved
@neiljp neiljp added PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback and removed PR needs review PR requires feedback to proceed labels Jun 3, 2021
@zee-bit zee-bit added PR needs review PR requires feedback to proceed and removed PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback labels Jun 5, 2021
Copy link
Collaborator

@neiljp neiljp left a comment

Choose a reason for hiding this comment

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

@zee-bit This is super-close, just left a few small points 👍

Maybe we'll squash the 3rd and 4th commit, and if we're planning to drop the last commit into another PR we might want to do that in this next (hopefully final!) iteration.

I'm pretty excited at the upcoming rework of the last commit too - with the work on topic links too we'll be able to open linkified PRs/issues in the browser much more easily 🎉

zulipterminal/core.py Outdated Show resolved Hide resolved
zulipterminal/core.py Show resolved Hide resolved
tests/core/test_core.py Outdated Show resolved Hide resolved
@neiljp neiljp added PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback and removed PR needs review PR requires feedback to proceed labels Jun 10, 2021
@zee-bit zee-bit force-pushed the view-in-browser branch 2 times, most recently from 150e3f0 to 55708de Compare June 10, 2021 13:05
@zee-bit zee-bit added PR needs review PR requires feedback to proceed and removed PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback labels Jun 10, 2021
@zee-bit
Copy link
Member Author

zee-bit commented Jun 10, 2021

Removed the last commit from here, will be introducing it in a new PR as requested. :)

punchagan and others added 3 commits June 10, 2021 17:08
This commit creates a context-manager that temporarily
redirects all standard output and error to /dev/null so that the
console does not log those in the corresponding log files or
current terminal window.
This adds open_in_browser() to add support for opening any link in the
web browser. This can later be used to either view any message or open
an external link in the browser.

The open_in_browser() accepts a URL and uses webbrowser module to open
that in browser. If no runnable browser is found in the system running
ZT, then an appropriate error message will be displayed in the footer.

Test added.

Co-authored-by: Puneeth Chaganti <[email protected]>
Co-authored-by: Preet Mishra <[email protected]>
Co-authored-by: Zeeshan <[email protected]>
This commit connects this functionality with a new VIEW_IN_BROWSER key
('v'). Any message can now be viewed in the browser by pressing the key
from the MessageInfo view.

Regenerated hotkeys.md.

Test added.

Co-authored-by: Puneeth Chaganti <[email protected]>
Co-authored-by: Preet Mishra <[email protected]>
@neiljp
Copy link
Collaborator

neiljp commented Jun 11, 2021

@zee-bit Thanks for the adjustments; I did that squash, adjusted some commit text and simplified the tests slightly and am merging now! 🎉

Thanks for @punchagan and @preetmishra for starting this and keeping this going too!

@neiljp neiljp merged commit e1bdf74 into zulip:main Jun 11, 2021
@neiljp neiljp removed the PR needs review PR requires feedback to proceed label Jun 11, 2021
@neiljp neiljp added this to the Next Release milestone Jun 11, 2021
@neiljp neiljp changed the title Add support for opening message and external links in browser. Add support for opening message in browser. Jun 11, 2021
@neiljp neiljp added the enhancement New feature or request label Jun 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request size: XL [Automatic label added by zulipbot]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants