mirror of
https://github.com/opf/openproject.git
synced 2026-06-13 19:20:00 +00:00
Remove option to show wiki item as submenu
This option seems to have been broken for quite some time and lead to pretty inconsistent results. What it clearly didn't do was to show the item in the project navigation. Some effects were visible in the wiki navigation, some of them only in some views of the wiki. This must have been broken for quite some time without major complaints about it. Since we want to generalize our wiki options going forward and also integrate with external wikis, this is a good chance for simplification. Therefore instead of trying to reverse engineer what this option was supposed to do, it's going to be removed for the time being.
This commit is contained in:
@@ -67,12 +67,11 @@ class WikiMenuItemsController < ApplicationController
|
||||
|
||||
def update # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
|
||||
wiki_menu_setting = wiki_menu_item_params[:setting]
|
||||
parent_wiki_menu_item = params[:parent_wiki_menu_item]
|
||||
|
||||
get_data_from_params(params)
|
||||
|
||||
if wiki_menu_setting == "no_item"
|
||||
unless @wiki_menu_item.nil?
|
||||
if @wiki_menu_item
|
||||
if @wiki_menu_item.is_only_main_item?
|
||||
if @page.only_wiki_page?
|
||||
flash.now[:error] = t(:wiki_menu_item_delete_not_permitted)
|
||||
@@ -89,12 +88,8 @@ class WikiMenuItemsController < ApplicationController
|
||||
@wiki_menu_item.name = @page.slug
|
||||
@wiki_menu_item.title = wiki_menu_item_params[:title] || @page_title
|
||||
|
||||
if wiki_menu_setting == "sub_item"
|
||||
@wiki_menu_item.parent_id = parent_wiki_menu_item
|
||||
elsif wiki_menu_setting == "main_item"
|
||||
@wiki_menu_item.parent_id = nil
|
||||
assign_wiki_menu_item_params @wiki_menu_item
|
||||
end
|
||||
@wiki_menu_item.parent_id = nil
|
||||
assign_wiki_menu_item_params @wiki_menu_item
|
||||
end
|
||||
|
||||
if @wiki_menu_item.destroyed? || @wiki_menu_item.save
|
||||
|
||||
@@ -50,7 +50,9 @@ class MenuItem < ApplicationRecord
|
||||
elsif is_main_item?
|
||||
:main_item
|
||||
else
|
||||
:sub_item
|
||||
# backwards compatibility for removed configuration option
|
||||
# sub items are not offered anymore and are effectively not visible
|
||||
:no_item
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -57,12 +57,6 @@ See COPYRIGHT and LICENSE files for more details.
|
||||
<%= form.radio_button "setting", :main_item %>
|
||||
<%= form.label "setting_main_item", t(:label_wiki_show_menu_item) %>
|
||||
</p>
|
||||
<p>
|
||||
<% disabled = @parent_menu_item_options.empty? %>
|
||||
<%= form.radio_button "setting", :sub_item, disabled: disabled %>
|
||||
<%= form.label "setting_sub_item", t(:label_wiki_show_submenu_item), { id: "with-select" } %>
|
||||
<%= select_tag "parent_wiki_menu_item", options_for_select(@parent_menu_item_options, @selected_parent_menu_item_id), disabled: disabled %>
|
||||
</p>
|
||||
</fieldset>
|
||||
<p>
|
||||
<%= styled_button_tag t(:button_save), method: :post,
|
||||
|
||||
@@ -4090,7 +4090,6 @@ en:
|
||||
label_wiki_show_index_page_link: "Show submenu item 'Table of Contents'"
|
||||
label_wiki_show_menu_item: "Show as menu item in project navigation"
|
||||
label_wiki_show_new_page_link: "Show submenu item 'Create new child page'"
|
||||
label_wiki_show_submenu_item: "Show as submenu item of "
|
||||
label_wiki_start: "Start page"
|
||||
label_work: "Work"
|
||||
label_work_package: "Work package"
|
||||
|
||||
@@ -25,7 +25,6 @@ To add a wiki page as a menu item to the project menu, select the **More** funct
|
||||
|
||||
- **Do not show this wikipage in the project navigation** will NOT display a separate menu item in the project navigation. The wiki page is just displayed within the wiki module itself.
|
||||
- **Show as menu item in project navigation** will add a separate menu item to the project navigation.
|
||||
- **Show as submenu item of ...** will display the wiki page a sub-menu item in the project navigation.
|
||||
|
||||
3. **Save** your changes to the wiki page menu.
|
||||
|
||||
@@ -35,8 +34,4 @@ To add a wiki page as a menu item to the project menu, select the **More** funct
|
||||
|
||||

|
||||
|
||||
**Visibility** show as submenu item of project-documentation:
|
||||
|
||||

|
||||
|
||||
The default option is **Do not show this wiki page in project navigation**. Check this option if you want to undo earlier changes and hide the wiki page from the project menu.
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 54 KiB |
@@ -36,10 +36,6 @@ module Redmine::MenuManager::WikiMenuHelper
|
||||
wiki_main_items(project_wiki).reverse_each do |main_item|
|
||||
Redmine::MenuManager.loose :project_menu do |menu|
|
||||
push_wiki_main_menu(menu, main_item, project)
|
||||
|
||||
main_item.children.each do |child|
|
||||
push_wiki_menu_subitem(menu, main_item, child)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -60,17 +56,6 @@ module Redmine::MenuManager::WikiMenuHelper
|
||||
main_item.destroy
|
||||
end
|
||||
|
||||
def push_wiki_menu_subitem(menu, main_item, child)
|
||||
menu.push child.menu_identifier,
|
||||
{ controller: "/wiki", action: "show", id: child.slug },
|
||||
caption: child.title,
|
||||
html: { class: "wiki-menu--sub-item" },
|
||||
parent: main_item.menu_identifier
|
||||
rescue ArgumentError => e
|
||||
Rails.logger.error "Failed to add wiki item #{child.slug} to wiki menu: #{e}. Deleting it."
|
||||
child.destroy
|
||||
end
|
||||
|
||||
def default_menu_item(page)
|
||||
if (main_item = page.nearest_main_item)
|
||||
main_item
|
||||
|
||||
@@ -105,8 +105,6 @@ RSpec.describe Projects::Settings::ModulesController, "menu" do
|
||||
it_behaves_like "renders the modules show page"
|
||||
|
||||
it_behaves_like "has selector", "#main-menu a.wiki-example-menu-item"
|
||||
|
||||
it_behaves_like "has selector", "#main-menu a.wiki-sub-menu-item"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -64,11 +64,11 @@ RSpec.describe "Wiki menu items",
|
||||
# Create two items with identical slugs (one with space, which is removed)
|
||||
let(:item1) do
|
||||
MenuItems::WikiMenuItem.new(navigatable_id: wiki.id,
|
||||
parent: parent_menu, title: "Item 1", name: "slug")
|
||||
parent: nil, title: "Item 1", name: "slug ")
|
||||
end
|
||||
let(:item2) do
|
||||
MenuItems::WikiMenuItem.new(navigatable_id: wiki.id,
|
||||
parent: parent_menu, title: "Item 2", name: "slug ")
|
||||
parent: nil, title: "Item 2", name: "slug")
|
||||
end
|
||||
|
||||
it "one is invalid and deleted during visit" do
|
||||
@@ -114,38 +114,27 @@ RSpec.describe "Wiki menu items",
|
||||
expect(page)
|
||||
.to have_current_path(project_wiki_path(project, wiki_page))
|
||||
|
||||
# modifying the menu item to a different name and to be a subpage
|
||||
# modifying the menu item to a different name
|
||||
|
||||
page.find_test_selector("wiki-more-dropdown-menu").click
|
||||
page.find_test_selector("wiki-configure-menu-action-menu-item").click
|
||||
wait_for_network_idle
|
||||
|
||||
fill_in "Name of menu item", with: "Custom page name"
|
||||
choose "Show as submenu item of"
|
||||
|
||||
select other_wiki_page.slug, from: "parent_wiki_menu_item"
|
||||
|
||||
click_link_or_button "Save"
|
||||
wait_for_network_idle
|
||||
|
||||
# the other page is now the main heading
|
||||
# the custom name is used as the main heading
|
||||
expect(page)
|
||||
.to have_css(".main-menu--children-menu-header", text: other_wiki_page.title)
|
||||
.to have_css(".main-menu--children-menu-header", text: "Custom page name")
|
||||
|
||||
expect(page)
|
||||
.to have_css(".wiki-menu--sub-item", text: "Custom page name")
|
||||
|
||||
find(".wiki-menu--sub-item", text: "Custom page name").click
|
||||
wait_for_network_idle
|
||||
|
||||
expect(page)
|
||||
.to have_current_path(project_wiki_path(project, wiki_page))
|
||||
|
||||
# the submenu item is not visible on top level
|
||||
# the item is visible on top level
|
||||
visit(project_wiki_path(project, wiki_page))
|
||||
find(".main-menu--arrow-left-to-project").click
|
||||
|
||||
expect(page)
|
||||
.to have_no_css(".main-item-wrapper", text: "Custom page name")
|
||||
.to have_css(".main-item-wrapper", text: "Custom page name")
|
||||
|
||||
# deleting the page will remove the menu item
|
||||
visit project_wiki_path(project, wiki_page)
|
||||
|
||||
Reference in New Issue
Block a user