nextcloud / files_pdfviewer

:book: A PDF viewer for Nextcloud
GNU Affero General Public License v3.0
91 stars 43 forks source link

Show error when trying to open a shared PDF without download permissions #1077

Open danxuliu opened 3 weeks ago

danxuliu commented 3 weeks ago

Fixes #649

Although the best fix would be to fallback to Collabora if available currently it does not seem to be possible to do that, so for now just an error message is shown.

Also, while it would be possible to use this.$emit('error') to notify the viewer that the file could not be loaded currently it does not seem possible to customize the message, so the standard Viewer error with Error loading {name of the file} would be shown. In this case it is worth explaning the reason, so the error is handled directly in the PDF viewer instead (but with the markup and style for the error element copied from the viewer). Maybe custom error messages will be possible in the future with the Viewer 4.0 API and then that code can go away :-)

Regarding the error message itself feel free to improve the wording :-) After several tries this is the best I could come up with :shrug:

Finally, note that before Nextcloud 28 when the PDF viewer was opened in public pages for a single share the UI was directly injected. When it was changed to use the viewer instead a fallback to directly inject the UI was left just in case the viewer was not available. This pull request only handles the disabled download permissions when the viewer is used, but not in the fallback case:

How to test

Result with this pull request

An error message is shown

Result without this pull request

The PDF viewer is loaded, but contents are empty

danxuliu commented 3 weeks ago

/compile /

danxuliu commented 3 weeks ago

/backport to stable30

danxuliu commented 3 weeks ago

/backport to stable29

danxuliu commented 3 weeks ago

/backport to stable28