Navigation tree won't display for users

I deployed a closed wiki with whitelist access and I’m having troubles to use Move/Rename page for users. When they use it and press a button to show navigation tree, they see “No pages found”, while administrators can see the entire tree.
Experimenting with the documentTree macro I noticed, showWikis=“true” parameter makes the tree unavailable for users. Without that parameter the tree is displayed correctly, but it seems, location picker on the Move/Rename uses that parameter. I guess, I should provide some extra permissions, but I couldn’t find, what permissions should I provide.
I’m using a single wiki without any subwikis.

Would be good to check the HTTP request that is made to fetch the tree nodes to see why it fails (what’s the status code and what’s the response). You can use the browser developer tools, Network tab.

I don’t get any errors.
browser makes a request

and this is a response:
[{“id”:“empty”,“text”:“No pages found”,“icon”:“fa fa-info-circle”,“children”:false,“data”:{“type”:“empty”,“validChildren”:[]}}]

removing “&showRoot=true” from the link above provides a json with a valid tree, I guess, I just don’t have access to the wikis listing for whatever reason, although accessing
shows the only wiki available (not using subwikis)
It used to be a subwiki before, but I started a separate server and restored it from a backup of that subwiki from the old server into the main wiki on the new server. That might have affected something.

Still could not resolve this. Users can set their user type to advanced and type in the new location in order to move pages, but using a tree would be far more convenient. Only administrators can see the tree.

Put this code in a wiki page and see what output you get for simple users and for administrators:

{{include reference="XWiki.DocumentTreeMacros" /}}

#set ($siblings = [])
#maybeAddWikiNode('xwiki' $siblings)

You should get something like this with administrators:

[{id=wiki:xwiki, text=Home, icon=fa fa-hdd-o, children=true, data={id=xwiki, type=wiki, validChildren=[space, document, pagination], canDelete=false}, a_attr={href=/xwiki/bin/view/Main/}}]

and probably [] with simple users. If that is the case then:

  • either $'xwiki') returns null
  • or $'view', $services.model.createWikiReference('xwiki')) return false for simple users, which would mean your simple users don’t have access to the wiki home page (I think).

You are right, the code above shows
[{id=wiki:xwiki, text=Home, icon=fa fa-hdd-o, children=true, data={id=xwiki, type=wiki, validChildren=[space, document, pagination], canDelete=false}, a_attr={href=/bin/view/Main/}}]
for admin (without /xwiki/ at the end) and [] for simple users.
$'xwiki') does not return null for any of them (it is, but
$'view', $services.model.createWikiReference('xwiki')) returns false for simple users.

Yet simple users do have view access to the home page (http://wiki.local/bin/view/Main/)
Maybe I don’t understand the concept of home page correctly?

When I remove access from the home page (http://wiki.local/bin/view/Main/), the navigation panel on the left side won’t show any pages, even though users can actually access some pages. Currently it works correctly for everyone, hence, I assume, that is actually the home page of the wiki.
Navigation tree in the Move/Rename page seems to be a bit different from the one in the Navigation panel. Not only it tries to show the pages of the current wiki, but for all the subwikis as well. I suspect, there is some kind of a root for the subwikis tree, that is not available to the simple users, but I don’t know, how to provide those permissions.

Actually $'view', $services.model.createWikiReference('xwiki')) doesn’t check view access for the wiki home page but for the wiki itself (globally). If this returns true then it means the current user can view pages from this wiki by default, unless view access is restricted at page level. If this returns false then it means the current user can’t view pages from this wiki by default unless view access is granted at page level.

So it looks like your simple users don’t have view access on the wiki by default. The fact that they can view the home page means that there are some lower (page) level access rights settings that allow it. You need to review your access rights setup from the wiki administration.

You are right, by default no one but admins have access to wiki pages. I had to manually provide access to different common pages, so that different buttons, panels and extensions are shown correctly. The only current problem is with this navigation tree. So permitting default access to the entire wiki is the only way to show the navigation tree? In that case I guess, I’ll have to pass:/

If you look at the code of maybeAddWikiNode macro in XWiki.DocumentTreeMacros wiki page you’ll see that you have 3 options:

  1. Give view right at wiki level by default and add restrictions at lower (nested page) level
  2. Set the showOnlyViewable parameter to false when calling the document tree macro. For this you probably need to edit the locationPicker_macros.vm Velocity template and look for the documentTree macro call.
  3. Modify the code of the maybeAddWikiNode Velocity macro from the XWiki.DocumentTreeMacros page to remove the check for view access rights on the wiki

The last 2 options will make XWiki upgrades a bit more difficult.

1 Like