Merge pull request #8520 from opf/feature/32051/replace-system-settings-tabs

[32051] Replace system settings tabs by submenu
pull/8573/head
ulferts 4 years ago committed by GitHub
commit 194e7e5248
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 45
      app/controllers/settings/display_controller.rb
  2. 42
      app/controllers/settings/general_controller.rb
  3. 42
      app/controllers/settings/projects_controller.rb
  4. 42
      app/controllers/settings/repositories_controller.rb
  5. 16
      app/controllers/settings_controller.rb
  6. 15
      app/helpers/settings_helper.rb
  7. 4
      app/views/settings/_display.html.erb
  8. 4
      app/views/settings/_general.html.erb
  9. 4
      app/views/settings/_projects.html.erb
  10. 3
      app/views/settings/_repositories.html.erb
  11. 34
      app/views/settings/show.html.erb
  12. 9
      config/initializers/menus.rb
  13. 7
      config/routes.rb
  14. 10
      spec/controllers/settings_controller_spec.rb

@ -0,0 +1,45 @@
#-- 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
include AdminSettingsUpdater
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
def default_breadcrumb
t(:label_display)
end
end

@ -0,0 +1,42 @@
#-- 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
include AdminSettingsUpdater
menu_item :settings_general
def show
render template: 'settings/_general'
end
def default_breadcrumb
t(:label_general)
end
end

@ -0,0 +1,42 @@
#-- 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
include AdminSettingsUpdater
menu_item :settings_projects
def show
render template: 'settings/_projects'
end
def default_breadcrumb
t(:label_project_plural)
end
end

@ -0,0 +1,42 @@
#-- 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
include AdminSettingsUpdater
menu_item :settings_repositories
def show
render template: 'settings/_repositories'
end
def default_breadcrumb
t(:label_repository_plural)
end
end

@ -45,12 +45,7 @@ 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
redirect_to general_settings_path
end
def plugin
@ -67,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

@ -30,32 +30,29 @@
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
}
]

@ -31,7 +31,9 @@ See docs/COPYRIGHT.rdoc for more details.
<meta name="required_script" content="administration_settings" />
<% end %>
<%= styled_form_tag(general_settings_path(tab: 'display'), method: :patch) do %>
<%= toolbar title: t(:label_display) %>
<%= styled_form_tag(update_display_settings_path, method: :patch) do %>
<section class="form--section">
<div class="form--field" id="setting_available_languages"><%= setting_multiselect :available_languages, all_lang_options_for_select(false) %></div>

@ -26,7 +26,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
See docs/COPYRIGHT.rdoc for more details.
++#%>
<%= styled_form_tag(general_settings_path, method: :patch) do %>
<%= toolbar title: t(:label_general) %>
<%= styled_form_tag(update_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>
<div class="form--field">

@ -26,7 +26,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
See docs/COPYRIGHT.rdoc for more details.
++#%>
<%= styled_form_tag(general_settings_path(tab: 'projects'), method: :patch) do %>
<%= toolbar title: t(:label_project_plural) %>
<%= styled_form_tag(update_projects_settings_path, method: :patch) do %>
<section class="form--section">
<div class="form--field"><%= setting_check_box :default_projects_public %></div>
<div class="form--field"><%= setting_multiselect(:default_projects_modules,

@ -26,8 +26,9 @@ 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 %>
<%= styled_form_tag(update_repositories_settings_path, method: :patch) do %>
<section class="form--section">
<div class="form--field">
<%= setting_check_box :autofetch_changesets %>

@ -1,34 +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) %>
<%= render_tabs administration_settings_tabs %>

@ -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',

@ -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 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)
collection do
match 'plugin/:id', action: 'plugin', via: %i[get post]

@ -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

Loading…
Cancel
Save