Merge pull request #6543 from opf/fix/28299/wiki-menu-item-missing

Ensure wiki menu items get created
pull/6548/head
Wieland Lindenthal 6 years ago committed by GitHub
commit 7061f4f15a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/controllers/concerns/layout.rb
  2. 4
      app/controllers/work_packages_controller.rb
  3. 9
      config/initializers/menus.rb
  4. 15
      lib/redmine/menu_manager/menu_helper.rb

@ -42,11 +42,11 @@ module Concerns::Layout
end
end
def project_or_module_menu
def project_or_wp_query_menu
if @project
:project_menu
else
:module_menu
:wp_query_menu
end
end
end

@ -48,7 +48,7 @@ class WorkPackagesController < ApplicationController
def show
respond_to do |format|
format.html do
render :show, locals: { work_package: work_package, menu_name: project_or_module_menu }, layout: 'angular'
render :show, locals: { work_package: work_package, menu_name: project_or_wp_query_menu }, layout: 'angular'
end
format.any(*WorkPackage::Exporter.single_formats) do
@ -64,7 +64,7 @@ class WorkPackagesController < ApplicationController
def index
respond_to do |format|
format.html do
render :index, locals: { query: @query, project: @project, menu_name: project_or_module_menu },
render :index, locals: { query: @query, project: @project, menu_name: project_or_wp_query_menu },
layout: 'angular'
end

@ -82,15 +82,6 @@ Redmine::MenuManager.map :account_menu do |menu|
end
Redmine::MenuManager.map :application_menu do |menu|
# menu.push :work_packages,
# { controller: '/work_packages', action: 'index' },
# caption: :label_work_package_plural,
# icon: 'icon2 icon-view-timeline',
# html: {
# id: 'main-menu-work-packages',
# :'wp-query-menu' => 'wp-query-menu'
# }
menu.push :work_packages_query_select,
{ controller: '/work_packages', action: 'index' },
parent: :work_packages,

@ -39,29 +39,24 @@ module Redmine::MenuManager::MenuHelper
# Renders the application main menu
def render_main_menu(menu, project = nil)
# Fall back to module_menu when project exists
# Fall back to project_menu when project exists (not during project creation)
if menu.nil? && project && project.persisted?
menu = :module_menu
menu = :project_menu
end
if !menu
# For some global pages such as home
nil
elsif menu == :module_menu && project && project.persisted?
elsif menu == :project_menu && project && project.persisted?
build_wiki_menus(project)
render_menu(:project_menu, project)
elsif menu == :module_menu
elsif menu == :wp_query_menu
render_menu(:application_menu, project)
else
render_menu(menu, project)
end
end
def display_main_menu?(project)
menu_name = project && !project.new_record? ? :project_menu : :application_menu
Redmine::MenuManager.items(menu_name).size > 1 # 1 element is the root
end
def render_menu(menu, project = nil)
links = []

Loading…
Cancel
Save