Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Replace system settings tabs by submenu

Inga Mai1afc6782f727
diff --git a/app/controllers/settings/display_controller.rb b/app/controllers/settings/display_controller.rb
new file mode 100644
index 00000000000..e8dd17a39f3
--- /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 00000000000..a80195eae8d
--- /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 00000000000..2c3f1d6111b
--- /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 00000000000..6a1ebffc33e
--- /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 4f83ac33cf9..daa6e9a2f7c 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 d67c3dcc9d1..1b6ee2c6a26 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.
<meta name="required_script" content="administration_settings" />
<% end %>
+<%= toolbar title: t(:label_display) %>
+
<%= styled_form_tag(general_settings_path(tab: 'display'), method: :patch) do %>
<section class="form--section">
diff --git a/app/views/settings/_general.html.erb b/app/views/settings/_general.html.erb
index 0b16ad6cdb6..f8e893e90df 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 %>
<section class="form--section">
<div class="form--field"><%= setting_text_field :app_title, size: 30, container_class: '-middle' %></div>
diff --git a/app/views/settings/_projects.html.erb b/app/views/settings/_projects.html.erb
index e6dd924f50c..98bc41ad265 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 %>
<section class="form--section">
<div class="form--field"><%= setting_check_box :default_projects_public %></div>
diff --git a/app/views/settings/_repositories.html.erb b/app/views/settings/_repositories.html.erb
index 1909c733bf1..cad9f662aa5 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 %>
<section class="form--section">
diff --git a/app/views/settings/show.html.erb b/app/views/settings/show.html.erb
index 133853eebd9..1f7f759410b 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 3d31cc5de93..f216212ef3d 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 7744eeadded..75622b96883 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