From 1afc6782f72774119a34e38a2a67c7a88222aa4d Mon Sep 17 00:00:00 2001 From: Inga Mai Date: Thu, 23 Jul 2020 10:32:11 +0200 Subject: [PATCH 1/5] Replace system settings tabs by submenu --- .../settings/display_controller.rb | 36 +++++++++++++++++++ .../settings/general_controller.rb | 36 +++++++++++++++++++ .../settings/projects_controller.rb | 36 +++++++++++++++++++ .../settings/repositories_controller.rb | 36 +++++++++++++++++++ app/helpers/settings_helper.rb | 24 ++++++++----- app/views/settings/_display.html.erb | 2 ++ app/views/settings/_general.html.erb | 2 ++ app/views/settings/_projects.html.erb | 2 ++ app/views/settings/_repositories.html.erb | 1 + app/views/settings/show.html.erb | 2 -- config/initializers/menus.rb | 9 ++++- config/routes.rb | 9 +++-- 12 files changed, 181 insertions(+), 14 deletions(-) create mode 100644 app/controllers/settings/display_controller.rb create mode 100644 app/controllers/settings/general_controller.rb create mode 100644 app/controllers/settings/projects_controller.rb create mode 100644 app/controllers/settings/repositories_controller.rb diff --git a/app/controllers/settings/display_controller.rb b/app/controllers/settings/display_controller.rb new file mode 100644 index 0000000000..e8dd17a39f --- /dev/null +++ b/app/controllers/settings/display_controller.rb @@ -0,0 +1,36 @@ +#-- encoding: UTF-8 +#-- copyright +# OpenProject is an open source project management software. +# Copyright (C) 2012-2020 the OpenProject GmbH +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2017 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See docs/COPYRIGHT.rdoc for more details. +#++ + +class Settings::DisplayController < SettingsController + menu_item :settings_display + + def show + render template: 'settings/_display' + end +end diff --git a/app/controllers/settings/general_controller.rb b/app/controllers/settings/general_controller.rb new file mode 100644 index 0000000000..a80195eae8 --- /dev/null +++ b/app/controllers/settings/general_controller.rb @@ -0,0 +1,36 @@ +#-- encoding: UTF-8 +#-- copyright +# OpenProject is an open source project management software. +# Copyright (C) 2012-2020 the OpenProject GmbH +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2017 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See docs/COPYRIGHT.rdoc for more details. +#++ + +class Settings::GeneralController < SettingsController + menu_item :settings_general + + def show + render template: 'settings/_general' + end +end diff --git a/app/controllers/settings/projects_controller.rb b/app/controllers/settings/projects_controller.rb new file mode 100644 index 0000000000..2c3f1d6111 --- /dev/null +++ b/app/controllers/settings/projects_controller.rb @@ -0,0 +1,36 @@ +#-- encoding: UTF-8 +#-- copyright +# OpenProject is an open source project management software. +# Copyright (C) 2012-2020 the OpenProject GmbH +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2017 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See docs/COPYRIGHT.rdoc for more details. +#++ + +class Settings::ProjectsController < SettingsController + menu_item :settings_projects + + def show + render template: 'settings/_projects' + end +end diff --git a/app/controllers/settings/repositories_controller.rb b/app/controllers/settings/repositories_controller.rb new file mode 100644 index 0000000000..6a1ebffc33 --- /dev/null +++ b/app/controllers/settings/repositories_controller.rb @@ -0,0 +1,36 @@ +#-- encoding: UTF-8 +#-- copyright +# OpenProject is an open source project management software. +# Copyright (C) 2012-2020 the OpenProject GmbH +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2017 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See docs/COPYRIGHT.rdoc for more details. +#++ + +class Settings::RepositoriesController < SettingsController + menu_item :settings_repositories + + def show + render template: 'settings/_repositories' + end +end diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb index 4f83ac33cf..daa6e9a2f7 100644 --- a/app/helpers/settings_helper.rb +++ b/app/helpers/settings_helper.rb @@ -30,37 +30,43 @@ require 'securerandom' module SettingsHelper + extend self include OpenProject::FormTagHelper - def administration_settings_tabs + def system_settings_tabs [ { name: 'general', - partial: 'settings/general', - path: general_settings_path, + action: { controller: '/settings/general', action: 'show' }, label: :label_general }, { name: 'display', - partial: 'settings/display', - path: general_settings_path(tab: :display), + action: { controller: '/settings/display', action: 'show' }, label: :label_display }, { name: 'projects', - partial: 'settings/projects', - path: general_settings_path(tab: :projects), + action: { controller: '/settings/projects', action: 'show' }, label: :label_project_plural }, { name: 'repositories', - partial: 'settings/repositories', - path: general_settings_path(tab: :repositories), + action: { controller: '/settings/repositories', action: 'show' }, label: :label_repository_plural } ] end + def general_settings_path(opts = {}) + if opts[:tab] + url_for controller: "settings/#{opts[:tab]}", action: 'show', only_path: true + else + url_for controller: "settings/general", action: 'show', only_path: true + end + end + + def setting_select(setting, choices, options = {}) if blank_text = options.delete(:blank) choices = [[blank_text.is_a?(Symbol) ? I18n.t(blank_text) : blank_text, '']] + choices diff --git a/app/views/settings/_display.html.erb b/app/views/settings/_display.html.erb index d67c3dcc9d..1b6ee2c6a2 100644 --- a/app/views/settings/_display.html.erb +++ b/app/views/settings/_display.html.erb @@ -31,6 +31,8 @@ See docs/COPYRIGHT.rdoc for more details. <% end %> +<%= toolbar title: t(:label_display) %> + <%= styled_form_tag(general_settings_path(tab: 'display'), method: :patch) do %>
diff --git a/app/views/settings/_general.html.erb b/app/views/settings/_general.html.erb index 0b16ad6cdb..f8e893e90d 100644 --- a/app/views/settings/_general.html.erb +++ b/app/views/settings/_general.html.erb @@ -26,6 +26,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. See docs/COPYRIGHT.rdoc for more details. ++#%> +<%= toolbar title: t(:label_general) %> + <%= styled_form_tag(general_settings_path, method: :patch) do %>
<%= setting_text_field :app_title, size: 30, container_class: '-middle' %>
diff --git a/app/views/settings/_projects.html.erb b/app/views/settings/_projects.html.erb index e6dd924f50..98bc41ad26 100644 --- a/app/views/settings/_projects.html.erb +++ b/app/views/settings/_projects.html.erb @@ -26,6 +26,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. See docs/COPYRIGHT.rdoc for more details. ++#%> +<%= toolbar title: t(:label_project_plural) %> + <%= styled_form_tag(general_settings_path(tab: 'projects'), method: :patch) do %>
<%= setting_check_box :default_projects_public %>
diff --git a/app/views/settings/_repositories.html.erb b/app/views/settings/_repositories.html.erb index 1909c733bf..cad9f662aa 100644 --- a/app/views/settings/_repositories.html.erb +++ b/app/views/settings/_repositories.html.erb @@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. See docs/COPYRIGHT.rdoc for more details. ++#%> +<%= toolbar title: t(:label_repository_plural) %> <%= styled_form_tag(general_settings_path(tab: 'repositories'), method: :patch) do %>
diff --git a/app/views/settings/show.html.erb b/app/views/settings/show.html.erb index 133853eebd..1f7f759410 100644 --- a/app/views/settings/show.html.erb +++ b/app/views/settings/show.html.erb @@ -30,5 +30,3 @@ See docs/COPYRIGHT.rdoc for more details. <% html_title t(:label_administration), t(:label_system_settings) -%> <%= toolbar title: t(:label_system_settings) %> - -<%= render_tabs administration_settings_tabs %> diff --git a/config/initializers/menus.rb b/config/initializers/menus.rb index 3d31cc5de9..f216212ef3 100644 --- a/config/initializers/menus.rb +++ b/config/initializers/menus.rb @@ -217,10 +217,17 @@ Redmine::MenuManager.map :admin_menu do |menu| icon: 'icon2 icon-enumerations' menu.push :settings, - { controller: '/settings', action: 'show' }, + { controller: '/settings/general', action: 'show' }, caption: :label_system_settings, icon: 'icon2 icon-settings2' + SettingsHelper.system_settings_tabs.each do |node| + menu.push :"settings_#{node[:name]}", + node[:action], + caption: node[:label], + parent: :settings + end + menu.push :email, { controller: '/admin/mail_notifications', action: 'show' }, caption: :'attributes.mail', diff --git a/config/routes.rb b/config/routes.rb index 7744eeadde..75622b9688 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -394,7 +394,12 @@ OpenProject::Application.routes.draw do resource :mail_notifications, only: %i[show update] end - resource :settings, as: :general_settings, only: %i(update show) do + resource :settings, only: %i(update show) do + SettingsHelper.system_settings_tabs.each do |tab| + get "settings/#{tab[:name]}", controller: "settings/#{tab[:name]}", action: 'show', as: "settings_#{tab[:name]}" + end + get "settings", controller: "settings/general", action: 'show', as: "settings" + # We should fix this crappy routing (split up and rename controller methods) collection do match 'plugin/:id', action: 'plugin', via: %i[get post] @@ -403,7 +408,7 @@ OpenProject::Application.routes.draw do resource :workflows, only: %i[edit update show] do member do - # We should fix this crappy routing (split up and rename controller methods) + # We should fix this crappy routing (split upΩand rename controller methods) match 'copy', action: 'copy', via: %i[get post] end end From 7779ca7a0428a732d2c26c0bc46000755886911a Mon Sep 17 00:00:00 2001 From: Inga Mai Date: Thu, 23 Jul 2020 17:35:49 +0200 Subject: [PATCH 2/5] Fix display page and incorrect paths --- app/controllers/settings/display_controller.rb | 3 +++ app/controllers/settings_controller.rb | 3 --- app/helpers/settings_helper.rb | 1 - config/initializers/menus.rb | 2 +- config/routes.rb | 4 ++-- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/controllers/settings/display_controller.rb b/app/controllers/settings/display_controller.rb index e8dd17a39f..479b4d52d5 100644 --- a/app/controllers/settings/display_controller.rb +++ b/app/controllers/settings/display_controller.rb @@ -31,6 +31,9 @@ class Settings::DisplayController < SettingsController menu_item :settings_display def show + @options = {} + @options[:user_format] = User::USER_FORMATS_STRUCTURE.keys.map { |f| [User.current.name(f), f.to_s] } + render template: 'settings/_display' end end diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb index 46d4349d3d..a928ec8f73 100644 --- a/app/controllers/settings_controller.rb +++ b/app/controllers/settings_controller.rb @@ -45,9 +45,6 @@ class SettingsController < ApplicationController end def show - @options = {} - @options[:user_format] = User::USER_FORMATS_STRUCTURE.keys.map { |f| [User.current.name(f), f.to_s] } - @guessed_host = request.host_with_port.dup @custom_style = CustomStyle.current || CustomStyle.new diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb index daa6e9a2f7..4c53807751 100644 --- a/app/helpers/settings_helper.rb +++ b/app/helpers/settings_helper.rb @@ -66,7 +66,6 @@ module SettingsHelper end end - def setting_select(setting, choices, options = {}) if blank_text = options.delete(:blank) choices = [[blank_text.is_a?(Symbol) ? I18n.t(blank_text) : blank_text, '']] + choices diff --git a/config/initializers/menus.rb b/config/initializers/menus.rb index f216212ef3..fd85bd55dc 100644 --- a/config/initializers/menus.rb +++ b/config/initializers/menus.rb @@ -217,7 +217,7 @@ Redmine::MenuManager.map :admin_menu do |menu| icon: 'icon2 icon-enumerations' menu.push :settings, - { controller: '/settings/general', action: 'show' }, + { controller: '/settings', action: 'show' }, caption: :label_system_settings, icon: 'icon2 icon-settings2' diff --git a/config/routes.rb b/config/routes.rb index 75622b9688..9e612d3aa2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -394,11 +394,11 @@ OpenProject::Application.routes.draw do resource :mail_notifications, only: %i[show update] end + get "settings", controller: "settings/general", action: 'show', as: "settings" resource :settings, only: %i(update show) do SettingsHelper.system_settings_tabs.each do |tab| - get "settings/#{tab[:name]}", controller: "settings/#{tab[:name]}", action: 'show', as: "settings_#{tab[:name]}" + get "#{tab[:name]}", controller: "settings/#{tab[:name]}", action: 'show', as: "settings_#{tab[:name]}" end - get "settings", controller: "settings/general", action: 'show', as: "settings" # We should fix this crappy routing (split up and rename controller methods) collection do From 00665e791355881bf87fd3b9da4c3aca74289fd1 Mon Sep 17 00:00:00 2001 From: Inga Mai Date: Fri, 24 Jul 2020 10:58:39 +0200 Subject: [PATCH 3/5] Correct routing for PATCH and cleanup --- .../settings/display_controller.rb | 2 ++ .../settings/general_controller.rb | 2 ++ .../settings/projects_controller.rb | 2 ++ .../settings/repositories_controller.rb | 2 ++ app/controllers/settings_controller.rb | 4 +-- app/helpers/settings_helper.rb | 8 ----- app/views/settings/_display.html.erb | 2 +- app/views/settings/_general.html.erb | 2 +- app/views/settings/_projects.html.erb | 2 +- app/views/settings/_repositories.html.erb | 2 +- app/views/settings/show.html.erb | 32 ------------------- config/initializers/menus.rb | 2 +- config/routes.rb | 6 ++-- 13 files changed, 17 insertions(+), 51 deletions(-) delete mode 100644 app/views/settings/show.html.erb diff --git a/app/controllers/settings/display_controller.rb b/app/controllers/settings/display_controller.rb index 479b4d52d5..f7501da764 100644 --- a/app/controllers/settings/display_controller.rb +++ b/app/controllers/settings/display_controller.rb @@ -28,6 +28,8 @@ #++ class Settings::DisplayController < SettingsController + include AdminSettingsUpdater + menu_item :settings_display def show diff --git a/app/controllers/settings/general_controller.rb b/app/controllers/settings/general_controller.rb index a80195eae8..11f05fcfb1 100644 --- a/app/controllers/settings/general_controller.rb +++ b/app/controllers/settings/general_controller.rb @@ -28,6 +28,8 @@ #++ class Settings::GeneralController < SettingsController + include AdminSettingsUpdater + menu_item :settings_general def show diff --git a/app/controllers/settings/projects_controller.rb b/app/controllers/settings/projects_controller.rb index 2c3f1d6111..3309760084 100644 --- a/app/controllers/settings/projects_controller.rb +++ b/app/controllers/settings/projects_controller.rb @@ -28,6 +28,8 @@ #++ class Settings::ProjectsController < SettingsController + include AdminSettingsUpdater + menu_item :settings_projects def show diff --git a/app/controllers/settings/repositories_controller.rb b/app/controllers/settings/repositories_controller.rb index 6a1ebffc33..c2d2ce18f3 100644 --- a/app/controllers/settings/repositories_controller.rb +++ b/app/controllers/settings/repositories_controller.rb @@ -28,6 +28,8 @@ #++ class Settings::RepositoriesController < SettingsController + include AdminSettingsUpdater + menu_item :settings_repositories def show diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb index a928ec8f73..12f7155ce7 100644 --- a/app/controllers/settings_controller.rb +++ b/app/controllers/settings_controller.rb @@ -45,9 +45,7 @@ class SettingsController < ApplicationController end def show - @guessed_host = request.host_with_port.dup - - @custom_style = CustomStyle.current || CustomStyle.new + redirect_to general_settings_path end def plugin diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb index 4c53807751..ebd6c6c9b6 100644 --- a/app/helpers/settings_helper.rb +++ b/app/helpers/settings_helper.rb @@ -58,14 +58,6 @@ module SettingsHelper ] end - def general_settings_path(opts = {}) - if opts[:tab] - url_for controller: "settings/#{opts[:tab]}", action: 'show', only_path: true - else - url_for controller: "settings/general", action: 'show', only_path: true - end - end - def setting_select(setting, choices, options = {}) if blank_text = options.delete(:blank) choices = [[blank_text.is_a?(Symbol) ? I18n.t(blank_text) : blank_text, '']] + choices diff --git a/app/views/settings/_display.html.erb b/app/views/settings/_display.html.erb index 1b6ee2c6a2..7c1dd0f186 100644 --- a/app/views/settings/_display.html.erb +++ b/app/views/settings/_display.html.erb @@ -33,7 +33,7 @@ See docs/COPYRIGHT.rdoc for more details. <%= toolbar title: t(:label_display) %> -<%= styled_form_tag(general_settings_path(tab: 'display'), method: :patch) do %> +<%= styled_form_tag(update_display_settings_path, method: :patch) do %>
<%= setting_multiselect :available_languages, all_lang_options_for_select(false) %>
diff --git a/app/views/settings/_general.html.erb b/app/views/settings/_general.html.erb index f8e893e90d..6bbe31359e 100644 --- a/app/views/settings/_general.html.erb +++ b/app/views/settings/_general.html.erb @@ -28,7 +28,7 @@ See docs/COPYRIGHT.rdoc for more details. ++#%> <%= toolbar title: t(:label_general) %> -<%= styled_form_tag(general_settings_path, method: :patch) do %> +<%= styled_form_tag(update_general_settings_path, method: :patch) do %>
<%= setting_text_field :app_title, size: 30, container_class: '-middle' %>
diff --git a/app/views/settings/_projects.html.erb b/app/views/settings/_projects.html.erb index 98bc41ad26..63954400d5 100644 --- a/app/views/settings/_projects.html.erb +++ b/app/views/settings/_projects.html.erb @@ -28,7 +28,7 @@ See docs/COPYRIGHT.rdoc for more details. ++#%> <%= toolbar title: t(:label_project_plural) %> -<%= styled_form_tag(general_settings_path(tab: 'projects'), method: :patch) do %> +<%= styled_form_tag(update_projects_settings_path, method: :patch) do %>
<%= setting_check_box :default_projects_public %>
<%= setting_multiselect(:default_projects_modules, diff --git a/app/views/settings/_repositories.html.erb b/app/views/settings/_repositories.html.erb index cad9f662aa..c9ce9d9512 100644 --- a/app/views/settings/_repositories.html.erb +++ b/app/views/settings/_repositories.html.erb @@ -28,7 +28,7 @@ See docs/COPYRIGHT.rdoc for more details. ++#%> <%= toolbar title: t(:label_repository_plural) %> -<%= styled_form_tag(general_settings_path(tab: 'repositories'), method: :patch) do %> +<%= styled_form_tag(update_repositories_settings_path, method: :patch) do %>
<%= setting_check_box :autofetch_changesets %> diff --git a/app/views/settings/show.html.erb b/app/views/settings/show.html.erb deleted file mode 100644 index 1f7f759410..0000000000 --- a/app/views/settings/show.html.erb +++ /dev/null @@ -1,32 +0,0 @@ -<%#-- copyright -OpenProject is an open source project management software. -Copyright (C) 2012-2020 the OpenProject GmbH - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License version 3. - -OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: -Copyright (C) 2006-2017 Jean-Philippe Lang -Copyright (C) 2010-2013 the ChiliProject Team - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -See docs/COPYRIGHT.rdoc for more details. - -++#%> - -<% html_title t(:label_administration), t(:label_system_settings) -%> - -<%= toolbar title: t(:label_system_settings) %> diff --git a/config/initializers/menus.rb b/config/initializers/menus.rb index fd85bd55dc..f216212ef3 100644 --- a/config/initializers/menus.rb +++ b/config/initializers/menus.rb @@ -217,7 +217,7 @@ Redmine::MenuManager.map :admin_menu do |menu| icon: 'icon2 icon-enumerations' menu.push :settings, - { controller: '/settings', action: 'show' }, + { controller: '/settings/general', action: 'show' }, caption: :label_system_settings, icon: 'icon2 icon-settings2' diff --git a/config/routes.rb b/config/routes.rb index 9e612d3aa2..1fea06c607 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -394,10 +394,10 @@ OpenProject::Application.routes.draw do resource :mail_notifications, only: %i[show update] end - get "settings", controller: "settings/general", action: 'show', as: "settings" resource :settings, only: %i(update show) do SettingsHelper.system_settings_tabs.each do |tab| - get "#{tab[:name]}", controller: "settings/#{tab[:name]}", action: 'show', as: "settings_#{tab[:name]}" + get tab[:name], controller: "settings/#{tab[:name]}", action: 'show', as: "#{tab[:name]}" + patch tab[:name], controller: "settings/#{tab[:name]}", action: 'update', as: "update_#{tab[:name]}" end # We should fix this crappy routing (split up and rename controller methods) @@ -408,7 +408,7 @@ OpenProject::Application.routes.draw do resource :workflows, only: %i[edit update show] do member do - # We should fix this crappy routing (split upΩand rename controller methods) + # We should fix this crappy routing (split up and rename controller methods) match 'copy', action: 'copy', via: %i[get post] end end From ff6dd091e317cf13279089155a591ecb78465d0d Mon Sep 17 00:00:00 2001 From: Inga Mai Date: Fri, 24 Jul 2020 11:20:32 +0200 Subject: [PATCH 4/5] Show correct breadcrumb name --- app/controllers/settings/display_controller.rb | 4 ++++ app/controllers/settings/general_controller.rb | 4 ++++ app/controllers/settings/projects_controller.rb | 4 ++++ app/controllers/settings/repositories_controller.rb | 4 ++++ app/controllers/settings_controller.rb | 9 --------- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/app/controllers/settings/display_controller.rb b/app/controllers/settings/display_controller.rb index f7501da764..f371c7efc2 100644 --- a/app/controllers/settings/display_controller.rb +++ b/app/controllers/settings/display_controller.rb @@ -38,4 +38,8 @@ class Settings::DisplayController < SettingsController render template: 'settings/_display' end + + def default_breadcrumb + t(:label_display) + end end diff --git a/app/controllers/settings/general_controller.rb b/app/controllers/settings/general_controller.rb index 11f05fcfb1..fff9ba9942 100644 --- a/app/controllers/settings/general_controller.rb +++ b/app/controllers/settings/general_controller.rb @@ -35,4 +35,8 @@ class Settings::GeneralController < SettingsController def show render template: 'settings/_general' end + + def default_breadcrumb + t(:label_general) + end end diff --git a/app/controllers/settings/projects_controller.rb b/app/controllers/settings/projects_controller.rb index 3309760084..66453b8c4c 100644 --- a/app/controllers/settings/projects_controller.rb +++ b/app/controllers/settings/projects_controller.rb @@ -35,4 +35,8 @@ class Settings::ProjectsController < SettingsController def show render template: 'settings/_projects' end + + def default_breadcrumb + t(:label_project_plural) + end end diff --git a/app/controllers/settings/repositories_controller.rb b/app/controllers/settings/repositories_controller.rb index c2d2ce18f3..2d4341a723 100644 --- a/app/controllers/settings/repositories_controller.rb +++ b/app/controllers/settings/repositories_controller.rb @@ -35,4 +35,8 @@ class Settings::RepositoriesController < SettingsController def show render template: 'settings/_repositories' end + + def default_breadcrumb + t(:label_repository_plural) + end end diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb index 12f7155ce7..0b95a8e0ec 100644 --- a/app/controllers/settings_controller.rb +++ b/app/controllers/settings_controller.rb @@ -62,15 +62,6 @@ class SettingsController < ApplicationController render_404 end - def default_breadcrumb - if params[:action] == "plugin" - plugin = Redmine::Plugin.find(params[:id]) - plugin.name - else - t(:label_system_settings) - end - end - def show_local_breadcrumb true end From 92eef3b2d08d7a5a141c5e326e9e98e25ddb4a1a Mon Sep 17 00:00:00 2001 From: Inga Mai Date: Thu, 6 Aug 2020 11:13:40 +0200 Subject: [PATCH 5/5] Fix test for projects settings --- spec/controllers/settings_controller_spec.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/controllers/settings_controller_spec.rb b/spec/controllers/settings_controller_spec.rb index 5c1e12e239..c091b17204 100644 --- a/spec/controllers/settings_controller_spec.rb +++ b/spec/controllers/settings_controller_spec.rb @@ -28,7 +28,7 @@ require 'spec_helper' -describe SettingsController, type: :controller do +describe Settings::ProjectsController, type: :controller do before :each do allow(@controller).to receive(:set_localization) @params = {} @@ -53,7 +53,7 @@ describe SettingsController, type: :controller do get 'show', params: { tab: 'projects' } expect(response).to be_successful - expect(response).to render_template 'show' + expect(response).to render_template 'settings/_projects' expect(response.body).to have_selector "input[@name='settings[default_projects_modules][]'][@value='activity']" end @@ -61,7 +61,7 @@ describe SettingsController, type: :controller do get 'show', params: { tab: 'projects' } expect(response).to be_successful - expect(response).to render_template 'show' + expect(response).to render_template 'settings/_projects' expect(response.body).to have_selector "input[@name='settings[default_projects_modules][]'][@value='activity']" end @@ -74,7 +74,7 @@ describe SettingsController, type: :controller do get 'show', params: { tab: 'projects' } expect(response).to be_successful - expect(response).to render_template 'show' + expect(response).to render_template 'settings/_projects' expect(response.body).not_to have_selector "input[@name='settings[default_projects_modules][]'][@value='activity'][@checked='checked']" end @@ -89,7 +89,7 @@ describe SettingsController, type: :controller do get 'show', params: { tab: 'projects' } expect(response).to be_successful - expect(response).to render_template 'show' + expect(response).to render_template 'settings/_projects' expect(response.body).to have_selector "input[@name='settings[default_projects_modules][]'][@value='activity'][@checked='checked']" end