Skip to content

feat(PageReference): Preview "Page not found" if page is not accessible#2343

Merged
mejo- merged 2 commits intomainfrom
feat/page-not-found-reference-widget
Mar 25, 2026
Merged

feat(PageReference): Preview "Page not found" if page is not accessible#2343
mejo- merged 2 commits intomainfrom
feat/page-not-found-reference-widget

Conversation

@pymnh
Copy link
Contributor

@pymnh pymnh commented Mar 15, 2026

📝 Summary

Change

  • Let the backend return empty Reference with accessible = false if current user cannot resolve
  • In the refernce widget: If accessible = false, show an informative "Page not found" preview and explain that the page does not seem to exist or that the permissions are missing to view it.
  • On click: open a popover to confirm if user really wants to follow the link

Reasoning:

  • Currently if I have not the permission to view a collectives page, the ReferenceProvider just falls back to opengraph, even if the URL matches a collective page.
  • This is IMO not correct: The collectives preview widget should still be responsible, even if it does not preview the content
  • One consideration: The way I did it, neither the name of the collective nor the title of the page are shown to the user. Technically these are not secret information, as they are included in the link. IMO one could also just render the title and change the description to include that the page was not found. I have no strong opinion on this.

🖼️ Screenshots

🏚️ Before
image
🏡 After
image

🚧 TODO

  • A fallback preview might also make sense for other reference providers and there should be a common way of doing this, so it would be nice to gather consensus if...
    • The accessible property is the right place to indicate that a "resource not found" message should be displayed
    • If the Reference provider should return a link or a completely empty richObject or can sometimes carry some more information? (-> Decks have only numeric ids in their URL, while collectives include Collective name and Page name in the URL, so for collectives, passing on these infos might not be a privacy issue?)
  • Add some unit tests

🏁 Checklist

  • Code is properly formatted (npm run lint / npm run stylelint / composer run cs:check)
  • Sign-off message is added to all commits
  • Tests (unit, integration and/or end-to-end) passing and the changes are covered with tests
  • Documentation (README or documentation) has been updated or is not required
@pymnh pymnh force-pushed the feat/page-not-found-reference-widget branch from 1b8a148 to b9e1846 Compare March 19, 2026 22:48
@pymnh pymnh changed the title WIP: Render empty reference widget if page is not accessible feat(PageReference): Preview "Page not found" if page is not accessible Mar 19, 2026
@pymnh pymnh force-pushed the feat/page-not-found-reference-widget branch from b9e1846 to 70409ac Compare March 19, 2026 23:31
@pymnh
Copy link
Contributor Author

pymnh commented Mar 19, 2026

Psalm error looks unrelated to me, I did not touch the dependencies..

@pymnh pymnh marked this pull request as ready for review March 19, 2026 23:36
@pymnh
Copy link
Contributor Author

pymnh commented Mar 20, 2026

I just noticed that there is a vue component that might be good to use:

https://nextcloud-vue-components.netlify.app/#/Components/NcEmptyContent

What do you think?

@pymnh pymnh force-pushed the feat/page-not-found-reference-widget branch from 70409ac to e400b96 Compare March 21, 2026 08:45
@pymnh
Copy link
Contributor Author

pymnh commented Mar 21, 2026

I removed the Popover confirmation dialog and used NcEmptyContent:

image
@pymnh pymnh force-pushed the feat/page-not-found-reference-widget branch from e400b96 to afd85ef Compare March 21, 2026 09:19
@mejo-
Copy link
Member

mejo- commented Mar 21, 2026

Thanks @pymnh! Without looking at the code yet, from the screenshots it looks like the not found preview is much larger than the normal preview. I'd expect them to have the same height.

@pymnh
Copy link
Contributor Author

pymnh commented Mar 21, 2026

I am not sure if one can squeeze the NcEmptyContent to the same size as the regular preview.

Should I then rather just revert NcEmptyContent and manually set title, description and icon with fallbacks with same alignment and font size like the regular preview?

@mejo-
Copy link
Member

mejo- commented Mar 21, 2026

Should I then rather just revert NcEmptyContent and manually set title, description and icon with fallbacks with same alignment and font size like the regular preview?

I would say so, yes. NcEmptyContent has a rather strict structure with everything (icon, title, description) below each other. So I think we're better with not using it here 😉

@pymnh pymnh force-pushed the feat/page-not-found-reference-widget branch from afd85ef to 97a63c1 Compare March 23, 2026 16:43
@pymnh
Copy link
Contributor Author

pymnh commented Mar 23, 2026

The "not found" preview now has the same size as regular page previews

image
@pymnh pymnh force-pushed the feat/page-not-found-reference-widget branch from 06d84b6 to afec771 Compare March 23, 2026 23:57
// Only consider rerouting if we're inside the collectives app excluding public shares) and for links to
// collectives app.
if (window.OCA.Collectives?.vueRouter
&& !this.isPublic
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand the rationale behind this change. In public shares I still want links to other pages in this collectives to be opened by re-routing them, not in a new tab, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe I misunderstand the the rerouting logic here. What I wanted to achieve here was to not reroute within the collectives page if I am an unauthenticated user accessing a public share, since I would be prompted with a useless left sidebar and a greyed out settings button in the left corner.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Duh, now I get it! 🤦‍♀️ Of course, you are right! Simply removing the link handler is the correct way.

Copy link
Member

@mejo- mejo- left a comment

Choose a reason for hiding this comment

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

Apart from the two comments, this looks great. Thanks so much @pymnh. I'll go ahead and push the to changes I suggested to still get this into the next release. I hope that's ok for you.

:href="richObject.link"
target="_blank"
class="collective-page not-found"
@click="clickLink">
Copy link
Member

Choose a reason for hiding this comment

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

I'd remove the click handler here as I'd expected links to unknown pages to be opened in a new tab, instead of trying to reroute them via vue-router.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll go ahead and push the to changes I suggested to still get this into the next release. I hope that's ok for you.

Sure thing!

I'd remove the click handler here as I'd expected links to unknown pages to be opened in a new tab, instead of trying to reroute them via vue-router.

See my other comment

…ssible Signed-off-by: Peymaneh <peymaneh@posteo.net>
@mejo- mejo- force-pushed the feat/page-not-found-reference-widget branch from afec771 to 04a391f Compare March 25, 2026 09:38
@mejo- mejo- self-assigned this Mar 25, 2026
* Don't try to re-route not found pages via vue-router, open them as normal link (in new tab) instead. * Keep the re-routing via vue-router for resolved page links in public shares. Signed-off-by: Jonas <jonas@freesources.org>
@mejo- mejo- force-pushed the feat/page-not-found-reference-widget branch from 04a391f to 1fbf129 Compare March 25, 2026 10:41
@mejo- mejo- merged commit 05ead42 into main Mar 25, 2026
71 of 73 checks passed
@mejo- mejo- deleted the feat/page-not-found-reference-widget branch March 25, 2026 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants