[#559] Group menus and add some dynamic menus

This commit is contained in:
Eric Davis 2012-02-17 10:16:04 -08:00
parent fbc71a80f8
commit b9b2c8c0d7
3 changed files with 174 additions and 18 deletions

View File

@ -309,6 +309,9 @@ en:
field_visible: Visible field_visible: Visible
field_warn_on_leaving_unsaved: "Warn me when leaving a page with unsaved text" field_warn_on_leaving_unsaved: "Warn me when leaving a page with unsaved text"
field_custom_filter: Custom LDAP filter field_custom_filter: Custom LDAP filter
field_issue_summary: Issue summary
field_new_saved_query: New saved query
field_issue_view_all_open: View all open issues
setting_app_title: Application title setting_app_title: Application title
setting_app_subtitle: Application subtitle setting_app_subtitle: Application subtitle

View File

@ -212,25 +212,178 @@ Redmine::MenuManager.map :admin_menu do |menu|
end end
Redmine::MenuManager.map :project_menu do |menu| Redmine::MenuManager.map :project_menu do |menu|
menu.push :overview, { :controller => 'projects', :action => 'show' } include ProjectsHelper
menu.push :activity, { :controller => 'activities', :action => 'index' }
menu.push :roadmap, { :controller => 'versions', :action => 'index' }, :param => :project_id, # TODO: refactor to a helper that is available before app/helpers along with the other procs.
:if => Proc.new { |p| p.shared_versions.any? } issue_query_proc = Proc.new { |p|
menu.push :issues, { :controller => 'issues', :action => 'index' }, :param => :project_id, :caption => :label_issue_plural ##### Taken from IssuesHelper
menu.push :new_issue, { :controller => 'issues', :action => 'new' }, :param => :project_id, :caption => :label_issue_new, # User can see public queries and his own queries
visible = ARCondition.new(["is_public = ? OR user_id = ?", true, (User.current.logged? ? User.current.id : 0)])
# Project specific queries and global queries
visible << (p.nil? ? ["project_id IS NULL"] : ["project_id IS NULL OR project_id = ?", p.id])
sidebar_queries = Query.find(:all,
:select => 'id, name',
:order => "name ASC",
:conditions => visible.conditions)
sidebar_queries.collect do |query|
Redmine::MenuManager::MenuItem.new("query-#{query.id}".to_sym, { :controller => 'issues', :action => 'index', :project_id => p, :query_id => query }, {
:caption => query.name,
:param => :project_id,
:parent => :issues
})
end
}
menu.push(:overview, { :controller => 'projects', :action => 'show' })
menu.push(:activity, { :controller => 'activities', :action => 'index' })
menu.push(:roadmap, { :controller => 'versions', :action => 'index' }, {
:param => :project_id,
:if => Proc.new { |p| p.shared_versions.any? },
:children => Proc.new { |p|
versions = p.shared_versions.sort
versions.reject! {|version| version.closed? || version.completed? }
versions.collect do |version|
Redmine::MenuManager::MenuItem.new("version-#{version.id}".to_sym,
{ :controller => 'versions', :action => 'show', :id => version },
{
:caption => version.name,
:parent => :roadmap
})
end
}
})
menu.push(:issues, { :controller => 'issues', :action => 'index' }, {
:param => :project_id,
:caption => :label_issue_plural,
:children => issue_query_proc
})
menu.push(:new_issue, { :controller => 'issues', :action => 'new' }, {
:param => :project_id,
:caption => :label_issue_new,
:parent => :issues,
:html => { :accesskey => Redmine::AccessKeys.key_for(:new_issue) } :html => { :accesskey => Redmine::AccessKeys.key_for(:new_issue) }
menu.push :gantt, { :controller => 'gantts', :action => 'show' }, :param => :project_id, :caption => :label_gantt })
menu.push :calendar, { :controller => 'calendars', :action => 'show' }, :param => :project_id, :caption => :label_calendar menu.push(:all_open_issues, { :controller => 'issues', :action => 'index', :set_filter => 1 }, {
menu.push :news, { :controller => 'news', :action => 'index' }, :param => :project_id, :caption => :label_news_plural :param => :project_id,
menu.push :documents, { :controller => 'documents', :action => 'index' }, :param => :project_id, :caption => :label_document_plural :caption => :field_issue_view_all_open,
menu.push :wiki, { :controller => 'wiki', :action => 'show', :id => nil }, :param => :project_id, :parent => :issues
})
menu.push(:new_query, { :controller => 'queries', :action => 'new'}, {
:param => :project_id,
:caption => :field_new_saved_query,
:parent => :issues
})
menu.push(:issue_summary, { :controller => 'reports', :action => 'issue_report' }, {
:caption => :field_issue_summary,
:parent => :issues
})
menu.push(:time_entries, { :controller => 'timelog', :action => 'index' }, {
:param => :project_id,
:if => Proc.new {|p| User.current.allowed_to?(:view_time_entries, p) }
});
menu.push(:new_time_entry, { :controller => 'timelog', :action => 'new' }, {
:param => :project_id,
:if => Proc.new {|p| User.current.allowed_to?(:log_time, p) },
:parent => :time_entries
})
menu.push(:time_entry_report, { :controller => 'time_entry_reports', :action => 'report' }, {
:param => :project_id,
:if => Proc.new {|p| User.current.allowed_to?(:view_time_entries, p) },
:parent => :time_entries
})
menu.push(:gantt, { :controller => 'gantts', :action => 'show' }, {
:param => :project_id,
:caption => :label_gantt
})
menu.push(:calendar, { :controller => 'calendars', :action => 'show' }, {
:param => :project_id,
:caption => :label_calendar
})
menu.push(:news, { :controller => 'news', :action => 'index' }, {
:param => :project_id,
:caption => :label_news_plural
})
menu.push(:new_news, {:controller => 'news', :action => 'new' }, {
:param => :project_id,
:caption => :label_news_new,
:parent => :news,
:if => Proc.new {|p| User.current.allowed_to?(:manage_news, p) }
})
menu.push(:documents, { :controller => 'documents', :action => 'index' }, {
:param => :project_id,
:caption => :label_document_plural
})
menu.push(:new_document, { :controller => 'documents', :action => 'new' }, {
:param => :project_id,
:caption => :label_document_new,
:parent => :documents,
:if => Proc.new {|p| User.current.allowed_to?(:manage_documents, p) }
})
menu.push(:wiki, { :controller => 'wiki', :action => 'show', :id => nil }, {
:param => :project_id,
:if => Proc.new { |p| p.wiki && !p.wiki.new_record? } :if => Proc.new { |p| p.wiki && !p.wiki.new_record? }
menu.push :boards, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id, })
:if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural menu.push(:wiki_by_title, { :controller => 'wiki', :action => 'index' }, {
menu.push :files, { :controller => 'files', :action => 'index' }, :caption => :label_file_plural, :param => :project_id :caption => :label_index_by_title,
menu.push :repository, { :controller => 'repositories', :action => 'show' }, :parent => :wiki,
:param => :project_id,
:if => Proc.new { |p| p.wiki && !p.wiki.new_record? }
})
menu.push(:wiki_by_date, { :controller => 'wiki', :action => 'date_index'}, {
:caption => :label_index_by_date,
:parent => :wiki,
:param => :project_id,
:if => Proc.new { |p| p.wiki && !p.wiki.new_record? }
})
menu.push(:boards, { :controller => 'boards', :action => 'index', :id => nil }, {
:param => :project_id,
:caption => :label_board_plural,
:if => Proc.new { |p| p.boards.any? },
:children => Proc.new {|project|
project.boards.collect do |board|
Redmine::MenuManager::MenuItem.new(
"board-#{board.id}".to_sym,
{ :controller => 'boards', :action => 'show', :id => board },
{
:caption => board.name # is h() in menu_helper.rb
})
end
}
})
menu.push(:new_board, { :controller => 'boards', :action => 'new' }, {
:caption => :label_board_new,
:param => :project_id,
:parent => :boards,
:if => Proc.new {|p| User.current.allowed_to?(:manage_boards, p) }
})
menu.push(:files, { :controller => 'files', :action => 'index' }, {
:caption => :label_file_plural,
:param => :project_id
})
menu.push(:new_file, { :controller => 'files', :action => 'new' }, {
:caption => :label_attachment_new,
:param => :project_id,
:parent => :files,
:if => Proc.new {|p| User.current.allowed_to?(:manage_files, p) }
})
menu.push(:repository, { :controller => 'repositories', :action => 'show' }, {
:if => Proc.new { |p| p.repository && !p.repository.new_record? } :if => Proc.new { |p| p.repository && !p.repository.new_record? }
menu.push :settings, { :controller => 'projects', :action => 'settings' }, :last => true })
menu.push(:settings, { :controller => 'projects', :action => 'settings' }, {
:last => true,
:children => Proc.new { |p|
@project = p # @project used in the helper
project_settings_tabs.collect do |tab|
Redmine::MenuManager::MenuItem.new("settings-#{tab[:name]}".to_sym,
{ :controller => 'projects', :action => 'settings', :id => p, :tab => tab[:name] },
{
:caption => tab[:label]
})
end
}
})
end end
Redmine::Activity.map do |activity| Redmine::Activity.map do |activity|

View File

@ -73,8 +73,8 @@ class RedmineTest < ActiveSupport::TestCase
assert_menu_contains_item_named :project_menu, :settings assert_menu_contains_item_named :project_menu, :settings
end end
def test_new_issue_should_have_root_as_a_parent def test_new_issue_should_have_issues_as_a_parent
new_issue = get_menu_item(:project_menu, :new_issue) new_issue = get_menu_item(:project_menu, :new_issue)
assert_equal :root, new_issue.parent.name assert_equal :issues, new_issue.parent.name
end end
end end