Defect #11682
closedLinks to URLs (as opposed to Controllers) in Project Menu do not work
0%
Description
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.
menu(:project_menu, :tab, { :controller => 'tab', :action => 'show' }, :caption => Proc.new { "Tab" })
Notice that if you change :project_menu to :top_menu, the code still works
menu(:top_menu, :tab, { :controller => 'tab', :action => 'show' }, :caption => Proc.new { "Tab" })
Changing the url parameter in this code to a URL likewise continues to work.
menu(:top_menu, :tab, "http://www.example.com/", :caption => Proc.new { "Tab" })
Finally changing :top_menu back to :project_menu while leaving in the URL causes no link to appear.
menu(:project_menu, :tab, "http://www.example.com/", :caption => Proc.new { "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.
Updated by Dan K almost 12 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
Updated by Ward V over 11 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?
Updated by Jean-Baptiste Barth over 11 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
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.
Updated by Jean-Baptiste Barth over 11 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.