plone / plone.restapi

RESTful API for Plone.
http://plonerestapi.readthedocs.org/
84 stars 73 forks source link

Add remote_url(getRemoteUrl) to link content-types in navigation #1754

Open nileshgulia1 opened 4 months ago

nileshgulia1 commented 4 months ago

When presenting a link content-type within the navigation menu, items located at the root level correctly display the remoteUrl, whereas those nested or at inner levels do not. The anticipated behavior is for remoteUrl to be returned for anonymous users.

The ongoing PR(https://github.com/plone/plone.restapi/pull/1654), adds remoteUrl in response to the get Navigation calls. I would be happy to coordinate the efforts.

nileshgulia1 commented 4 months ago

https://github.com/plone/plone.restapi/blob/daabc59813e9701d10a80dd57b0cac5aabe06238/src/plone/restapi/services/contextnavigation/get.py#L384

davisagli commented 4 months ago

@nileshgulia1 From what I see, the remoteUrl should be added for child items here: https://github.com/plone/plone.restapi/blob/1771c9c43b63dd0a6b29ab1339b6e8d6330876ab/src/plone/restapi/services/contextnavigation/get.py#L461

But, useRemoteUrl comes from the navtree code and it can only be true if the user is the not the creator of the link: https://github.com/plone/Products.CMFPlone/blob/97f00be8bdef1726c3e335d0fa189accfec6748e/Products/CMFPlone/browser/navtree.py#L144

Maybe I'm missing something but it would be good to understand why the existing code isn't working before we add new code.

nileshgulia1 commented 4 months ago

But, useRemoteUrl comes from the navtree code and it can only be true if the user is the not the creator of the link:

Hm.. I'm not sure if I get this. Anyway for now I customized it in our policy addon as it was a bit urgent https://github.com/eea/eea.volto.policy/pull/19 I will come back at this and try to fix it permanently. Thanks for the tips!

davisagli commented 4 months ago

@nileshgulia1 In general, the design for the Link content type is to take users directly to the link target URL if the users don't have permission to edit the link, but take them to the Link content item if they have permission to edit it (otherwise they don't have a way to access the edit button)