diff --git a/config/locales/en.yml b/config/locales/en.yml index adec4598123004b628e164828b89a9c8f6a7ba00..a879da48840c30058589f58b75980544e172aed8 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -309,6 +309,9 @@ en: field_visible: Visible field_warn_on_leaving_unsaved: "Warn me when leaving a page with unsaved text" 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_subtitle: Application subtitle diff --git a/lib/redmine.rb b/lib/redmine.rb index 832dd56f4c2ecff71a4343ef2a474726bba5879e..70d39b3b27c4cc6de6409dc1a603d0aeab99c7dd 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -212,25 +212,178 @@ Redmine::MenuManager.map :admin_menu do |menu| end Redmine::MenuManager.map :project_menu do |menu| - 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? } - menu.push :issues, { :controller => 'issues', :action => 'index' }, :param => :project_id, :caption => :label_issue_plural - menu.push :new_issue, { :controller => 'issues', :action => 'new' }, :param => :project_id, :caption => :label_issue_new, + include ProjectsHelper + + # TODO: refactor to a helper that is available before app/helpers along with the other procs. + issue_query_proc = Proc.new { |p| + ##### Taken from IssuesHelper + # 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) } - 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 :documents, { :controller => 'documents', :action => 'index' }, :param => :project_id, :caption => :label_document_plural - menu.push :wiki, { :controller => 'wiki', :action => 'show', :id => nil }, :param => :project_id, + }) + menu.push(:all_open_issues, { :controller => 'issues', :action => 'index', :set_filter => 1 }, { + :param => :project_id, + :caption => :field_issue_view_all_open, + :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? } + }) + menu.push(:wiki_by_title, { :controller => 'wiki', :action => 'index' }, { + :caption => :label_index_by_title, + :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, - :if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural - menu.push :files, { :controller => 'files', :action => 'index' }, :caption => :label_file_plural, :param => :project_id - menu.push :repository, { :controller => 'repositories', :action => 'show' }, + }) + 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? } - 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 Redmine::Activity.map do |activity| diff --git a/test/unit/lib/redmine_test.rb b/test/unit/lib/redmine_test.rb index 599a04d1809b3fbd5d8929e4cb59971e1d9476df..94d60a74c5ca7ee36e57d9633bc60d7eb621579e 100644 --- a/test/unit/lib/redmine_test.rb +++ b/test/unit/lib/redmine_test.rb @@ -73,8 +73,8 @@ class RedmineTest < ActiveSupport::TestCase assert_menu_contains_item_named :project_menu, :settings 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) - assert_equal :root, new_issue.parent.name + assert_equal :issues, new_issue.parent.name end end