Display PDF using the browser's PDF viewer rather than GitLab's

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Problem

When one puts a PDF file into a Git repository, and opens that page, then Gitlab renders a preview of that PDF. However that preview is way inferior to having the same PDF displayed in the browser directly -- it doesn't even support copying text. It should be possible somehow to display the PDF using the browser's PDF viewer rather than Gitlab's.

I know I can click the "download" button, but that will, well, download the PDF. I don't want to download it. That just creates some junk files it my Downloads folder that I have to clean up manually later. I just want to display it online, using the browser's PDF viewer.

Design recommendation

See #434513 (comment 2819139173).

Put an "Open in a new window" button next to the download button. This allows users to stay within the application and keep the context of the blob page, while also giving a path to quickly view the file in their browser if desired.

Current Proposed

current.jpg

update - file - pdf.jpg

  • Add "Open in a new window" button next to the download button in the blob page for PDF files
  • When the button is clicked, the PDF will open in a new window using the browser's default PDF viewer.
  • Button hover text: Open in a new window

Implementation plan

Add a new button in app/assets/javascripts/blob/components/blob_header_default_actions.vue. Button should have aria-label and hover tooltip. URL should have download property explicitly set to false to have the link open in new window.

Edited by 🤖 GitLab Bot 🤖