Defect #11682

Links to URLs (as opposed to Controllers) in Project Menu do not work

Added by Derric Atzrott over 9 years ago. Updated over 8 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:-% Done:


Category:Plugin API
Target version:-
Resolution:Invalid Affected version:2.3.0


In init.rb for a plugin you can define various additions to the menus in Redmine. When doing so for the project menu, but specifying a URL instead of a controller, the menu item will not appear and will not generate any error message.

Steps to Duplicate:
I will present four pieces of code, three that work, and one that does not to demonstrate the issue.

In your init.rb for you extension use the following code to add a menu item called Tab to the menu. This will work.

       { :controller => 'tab', :action => 'show' },
       :caption => { "Tab" })

Notice that if you change :project_menu to :top_menu, the code still works

       { :controller => 'tab', :action => 'show' },
       :caption => { "Tab" })

Changing the url parameter in this code to a URL likewise continues to work.

       :caption => { "Tab" })

Finally changing :top_menu back to :project_menu while leaving in the URL causes no link to appear.

       :caption => { "Tab" })

I think the problem is in menu_manager.rb in the function extract_node_details or in the function render_menu_node. I am able to track the menu item all the way to render_menu_node, but that is as far as I've managed.

I would have submitted a patch with this, but as my knowledge of Ruby is quite poor, I was unable to find where exactly the problem lays.


#1 Updated by Dan K about 9 years ago

I think the root of such behaviuor in permissions check while rendering project_menu items.
As first case { :controller => 'tab', :action => 'show' } based on routing patterns then it passes conditions.
May be a full url with domain does not mathch any of the route patterns. Try just '/' instead

#2 Updated by Ward V almost 9 years ago

I am seeing the same problem on redmine 2.3.0.

As Dan K said, this appears to be a permission problem.

Any ideas on a workaround/fix?

#3 Updated by Jean-Baptiste Barth over 8 years ago

  • Status changed from New to Closed
  • Affected version (unused) changed from 1.3.0 to 2.3.0
  • Resolution set to Invalid
  • Affected version changed from 1.3.0 to 2.3.0
That's confirmed and expected behaviour:
  • top_menu is not dependent on the currently viewed project ; hence it wouldn't make much sense to make suppositions about permissions at this level, it stays on the developer side (he can add an :if statement to check global permission or admin status of the user)
  • project_menu is dependent on the currently view project ; it is evaluated/rendered depending on current user's permissions, which actually constitutes a safety net for plugin developers, since they don't have to think about permissions, Redmine will just display the accessible tabs for current user

If you really want to have an external URL in a project tab, for now the only solution I see is making a dummy controller/action that redirects to this URL. Then declare a public permission for this controller/action and you're OK. I can provide an example if you want.

It might be possible to change Redmine's default behaviour but I don't think it's such a common pattern, so I think we'd better leave all this as it is now.

I close the issue because I think there's nothing to fix, but please reopen if you think there is.

#4 Updated by Jean-Baptiste Barth over 8 years ago

Oh of course there's an other solution, you can inject the tab via JS or by overriding the template. If you don't use Redmine's builtin tab mechanism you won't have this problem.

Also available in: Atom PDF