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

[#51793] Split existing project administration settings into multiple pages

Dombi Attila35783e1d2f42
diff --git a/app/controllers/admin/settings/new_project_settings_controller.rb b/app/controllers/admin/settings/new_project_settings_controller.rb
new file mode 100644
index 00000000000..656d919284e
--- /dev/null
+++ b/app/controllers/admin/settings/new_project_settings_controller.rb
@@ -0,0 +1,71 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2024 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-2013 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 COPYRIGHT and LICENSE files for more details.
+#++
+
+module Admin::Settings
+ class NewProjectSettingsController < ::Admin::SettingsController
+ menu_item :new_project_settings
+
+ before_action :validate_enabled_modules, only: :update # rubocop:disable Rails/LexicallyScopedActionFilter
+
+ def default_breadcrumb
+ t(:label_project_new)
+ end
+
+ private
+
+ # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
+ def validate_enabled_modules
+ return if settings_params[:default_projects_modules].blank?
+
+ enabled_modules = settings_params[:default_projects_modules].map(&:to_sym)
+
+ module_missing_deps = OpenProject::AccessControl
+ .modules
+ .filter_map do |m|
+ if m[:dependencies] &&
+ enabled_modules.include?(m[:name]) &&
+ (m[:dependencies] & enabled_modules) != m[:dependencies]
+
+ I18n.t(
+ "settings.projects.missing_dependencies",
+ module: I18n.t("project_module_#{m[:name]}"),
+ dependencies: m[:dependencies].map { |dep| I18n.t("project_module_#{dep}") }.join(", ")
+ )
+ end
+ end
+
+ if module_missing_deps.any?
+ flash[:error] = helpers.list_of_messages(module_missing_deps)
+
+ redirect_to action: :show
+ end
+ end
+
+ # rubocop:enable Metrics/AbcSize, Metrics/PerceivedComplexity
+ end
+end
diff --git a/app/controllers/admin/settings/projects_settings_controller.rb b/app/controllers/admin/settings/projects_settings_controller.rb
index 69e1cd2e8ac..fcde77f502a 100644
--- a/app/controllers/admin/settings/projects_settings_controller.rb
+++ b/app/controllers/admin/settings/projects_settings_controller.rb
@@ -28,37 +28,10 @@
module Admin::Settings
class ProjectsSettingsController < ::Admin::SettingsController
- menu_item :projects_settings
-
- before_action :validate_enabled_modules, only: :update
+ menu_item :project_lists_settings
def default_breadcrumb
- t(:label_project_settings)
- end
-
- private
-
- def validate_enabled_modules
- return if settings_params[:default_projects_modules].blank?
-
- enabled_modules = settings_params[:default_projects_modules].map(&:to_sym)
-
- module_missing_deps = OpenProject::AccessControl
- .modules
- .select { |m| m[:dependencies] && enabled_modules.include?(m[:name]) && (m[:dependencies] & enabled_modules) != m[:dependencies] }
- .map do |m|
- I18n.t(
- "settings.projects.missing_dependencies",
- module: I18n.t("project_module_#{m[:name]}"),
- dependencies: m[:dependencies].map { |dep| I18n.t("project_module_#{dep}") }.join(", ")
- )
- end
-
- if module_missing_deps.any?
- flash[:error] = helpers.list_of_messages(module_missing_deps)
-
- redirect_to action: :show
- end
+ t(:label_project_list_plural)
end
end
end
diff --git a/app/views/admin/settings/new_project_settings/show.html.erb b/app/views/admin/settings/new_project_settings/show.html.erb
new file mode 100644
index 00000000000..363af97b32c
--- /dev/null
+++ b/app/views/admin/settings/new_project_settings/show.html.erb
@@ -0,0 +1,47 @@
+<%#-- copyright
+OpenProject is an open source project management software.
+Copyright (C) 2012-2024 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-2013 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 COPYRIGHT and LICENSE files for more details.
+
+++#%>
+<%= toolbar title: t(:label_project_new) %>
+
+<%= styled_form_tag(admin_settings_new_project_path, method: :patch) do %>
+ <section class="form--section">
+ <fieldset class="form--fieldset">
+ <div class="form--field"><%= setting_check_box :default_projects_public %></div>
+ <div class="form--field">
+ <%= setting_multiselect(:default_projects_modules,
+ OpenProject::AccessControl.available_project_modules.collect {|m| [l_or_humanize(m, prefix: "project_module_"), m.to_s]}) %>
+ </div>
+ <div class="form--field"><%= setting_select :new_project_user_role_id,
+ Role.givable.collect {|r| [r.name, r.id.to_s]},
+ blank: "--- #{t(:actionview_instancetag_blank_option)} ---",
+ container_class: '-middle' %></div>
+ </fieldset>
+ </section>
+
+ <%= styled_button_tag t(:button_save), class: '-primary -with-icon icon-checkmark' %>
+<% end %>
diff --git a/app/views/admin/settings/projects_settings/show.html.erb b/app/views/admin/settings/projects_settings/show.html.erb
index 25ad606a3a4..a7412a5e31f 100644
--- a/app/views/admin/settings/projects_settings/show.html.erb
+++ b/app/views/admin/settings/projects_settings/show.html.erb
@@ -26,27 +26,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
See COPYRIGHT and LICENSE files for more details.
++#%>
-<%= toolbar title: t(:label_project_settings) %>
+<%= toolbar title: t(:label_project_list_plural) %>
<%= styled_form_tag(admin_settings_projects_path, method: :patch) do %>
<section class="form--section">
<fieldset class="form--fieldset">
- <legend class="form--fieldset-legend"><%= t('settings.projects.section_new_projects') %></legend>
- <div class="form--field"><%= setting_check_box :default_projects_public %></div>
- <div class="form--field">
- <%= setting_multiselect(:default_projects_modules,
- OpenProject::AccessControl.available_project_modules.collect {|m| [l_or_humanize(m, prefix: "project_module_"), m.to_s]}) %>
- </div>
- <div class="form--field"><%= setting_select :new_project_user_role_id,
- Role.givable.collect {|r| [r.name, r.id.to_s]},
- blank: "--- #{t(:actionview_instancetag_blank_option)} ---",
- container_class: '-middle' %></div>
- </fieldset>
- </section>
-
- <section class="form--section">
- <fieldset class="form--fieldset">
- <legend class="form--fieldset-legend"><%= t('settings.projects.section_project_overview') %></legend>
<% unless EnterpriseToken.allows_to?(:custom_fields_in_projects_list) %>
<div class="form--field">
<%=
@@ -102,4 +86,4 @@ See COPYRIGHT and LICENSE files for more details.
</section>
<%= styled_button_tag t(:button_save), class: '-primary -with-icon icon-checkmark' %>
-<% end %>
\ No newline at end of file
+<% end %>
diff --git a/config/initializers/menus.rb b/config/initializers/menus.rb
index 2e1af183876..da27d59089c 100644
--- a/config/initializers/menus.rb
+++ b/config/initializers/menus.rb
@@ -331,21 +331,27 @@ Redmine::MenuManager.map :admin_menu do |menu|
parent: :admin_work_packages
menu.push :admin_projects_settings,
- { controller: '/admin/settings/project_custom_fields', action: :index },
+ { controller: "/admin/settings/project_custom_fields", action: :index },
if: Proc.new { User.current.admin? },
caption: :label_project_plural,
- icon: 'projects'
+ icon: "projects"
menu.push :project_custom_fields_settings,
- { controller: '/admin/settings/project_custom_fields', action: :index },
+ { controller: "/admin/settings/project_custom_fields", action: :index },
if: Proc.new { User.current.admin? },
caption: :label_project_attributes_plural,
parent: :admin_projects_settings
- menu.push :projects_settings,
- { controller: '/admin/settings/projects_settings', action: :show },
+ menu.push :new_project_settings,
+ { controller: "/admin/settings/new_project_settings", action: :show },
if: Proc.new { User.current.admin? },
- caption: :label_setting_plural,
+ caption: :label_project_new,
+ parent: :admin_projects_settings
+
+ menu.push :project_lists_settings,
+ { controller: "/admin/settings/projects_settings", action: :show },
+ if: Proc.new { User.current.admin? },
+ caption: :label_project_list_plural,
parent: :admin_projects_settings
menu.push :custom_fields,
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 06a22a130d1..e312c7eaa96 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -2235,6 +2235,7 @@ Project attributes and sections are defined in the <a href=%{admin_settings_url}
label_project_hierarchy: "Project hierarchy"
label_project_new: "New project"
label_project_plural: "Projects"
+ label_project_list_plural: "Project lists"
label_project_attributes_plural: "Project attributes"
label_project_custom_field_plural: "Project attributes"
label_project_settings: "Project settings"
diff --git a/config/routes.rb b/config/routes.rb
index d419764abf7..53d5f621c2a 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -447,6 +447,7 @@ Rails.application.routes.draw do
resource :api, controller: "/admin/settings/api_settings", only: %i[show update]
resource :work_packages, controller: "/admin/settings/work_packages_settings", only: %i[show update]
resource :projects, controller: "/admin/settings/projects_settings", only: %i[show update]
+ resource :new_project, controller: "/admin/settings/new_project_settings", only: %i[show update]
resources :project_custom_fields, controller: "/admin/settings/project_custom_fields" do
member do
delete "options/:option_id", action: "delete_option", as: :delete_option_of
diff --git a/modules/storages/spec/features/storages_module_spec.rb b/modules/storages/spec/features/storages_module_spec.rb
index 06af43e500a..8d42f38ea49 100644
--- a/modules/storages/spec/features/storages_module_spec.rb
+++ b/modules/storages/spec/features/storages_module_spec.rb
@@ -73,7 +73,7 @@ RSpec.describe "Storages module", :js do
context "when showing system project settings page" do
it_behaves_like "has storages module", sections: [:content] do
- let(:path) { admin_settings_projects_path }
+ let(:path) { admin_settings_new_project_path }
end
end
diff --git a/spec/controllers/admin/settings/new_project_settings_controller_spec.rb b/spec/controllers/admin/settings/new_project_settings_controller_spec.rb
new file mode 100644
index 00000000000..375adc12b66
--- /dev/null
+++ b/spec/controllers/admin/settings/new_project_settings_controller_spec.rb
@@ -0,0 +1,219 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2024 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-2013 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 COPYRIGHT and LICENSE files for more details.
+#++
+
+require "spec_helper"
+
+RSpec.describe Admin::Settings::NewProjectSettingsController do
+ shared_let(:user) { create(:admin) }
+ current_user { user }
+
+ before do
+ allow(controller).to receive(:set_localization)
+ end
+
+ describe "GET #show" do
+ render_views
+
+ describe "default project modules" do
+ it "contains a check box for the activity module on the projects tab" do
+ get "show", params: { tab: "projects" }
+
+ expect(response).to be_successful
+ expect(response).to render_template "admin/settings/new_project_settings/show"
+ expect(response.body).to have_css "input[@name='settings[default_projects_modules][]'][@value='activity']"
+ end
+
+ context "without activated activity module" do
+ before do
+ Setting.default_projects_modules = %w[wiki]
+ end
+
+ it "contains an unchecked checkbox for activity" do
+ get "show", params: { tab: "projects" }
+
+ expect(response).to be_successful
+ expect(response).to render_template "admin/settings/new_project_settings/show"
+
+ expect(response.body)
+ .to have_no_css "input[@name='settings[default_projects_modules][]'][@value='activity'][@checked='checked']"
+ end
+ end
+
+ context "with activity in Setting.default_projects_modules" do
+ before do
+ Setting.default_projects_modules = %w[activity]
+ end
+
+ it "contains a checked checkbox for activity" do
+ get "show", params: { tab: "projects" }
+
+ expect(response).to be_successful
+ expect(response).to render_template "admin/settings/new_project_settings/show"
+ expect(response.body)
+ .to have_css "input[@name='settings[default_projects_modules][]'][@value='activity'][@checked='checked']"
+ end
+ end
+ end
+ end
+
+ describe "PATCH #update" do
+ render_views
+
+ describe "default project modules" do
+ it "does not store the activity in the default_projects_modules if unchecked" do
+ patch "update",
+ params: {
+ tab: "projects",
+ settings: {
+ default_projects_modules: ["wiki"]
+ }
+ }
+
+ expect(response).to be_redirect
+ expect(response).to redirect_to action: "show", tab: "projects"
+
+ expect(Setting.default_projects_modules).to eq(["wiki"])
+ end
+
+ it "stores the activity in the default_projects_modules if checked" do
+ patch "update",
+ params: {
+ tab: "projects",
+ settings: {
+ default_projects_modules: ["activity", "wiki"]
+ }
+ }
+
+ expect(response).to be_redirect
+ expect(response).to redirect_to action: "show", tab: "projects"
+
+ expect(Setting.default_projects_modules).to eq(["activity", "wiki"])
+ end
+ end
+
+ describe "password settings" do
+ let(:new_settings) do
+ {
+ password_min_length: 42,
+ password_active_rules: %w(uppercase lowercase),
+ password_min_adhered_rules: 7,
+ password_days_valid: 13,
+ password_count_former_banned: 80,
+ lost_password: false
+ }
+ end
+
+ before do
+ old_settings = {
+ password_min_length: 10,
+ password_active_rules: [],
+ password_min_adhered_rules: 0,
+ password_days_valid: 365,
+ password_count_former_banned: 2,
+ lost_password: true
+ }
+
+ old_settings.each do |key, value|
+ Setting[key] = value
+ end
+ end
+
+ context "with password login enabled" do
+ before do
+ allow(OpenProject::Configuration).to receive(:disable_password_login?).and_return(false)
+
+ patch "update", params: { tab: "authentication", settings: new_settings }
+ end
+
+ it "is successful" do
+ expect(response).to be_redirect # to auth tab
+ end
+
+ it "sets the minimum password length to 42" do
+ expect(Setting[:password_min_length]).to eq 42
+ end
+
+ it "sets the active character classes to lowercase and uppercase" do
+ expect(Setting[:password_active_rules]).to eq %w[uppercase lowercase]
+ end
+
+ it "sets the required number of classes to 7" do
+ expect(Setting[:password_min_adhered_rules]).to eq 7
+ end
+
+ it "sets passwords to expire after 13 days" do
+ expect(Setting[:password_days_valid]).to eq 13
+ end
+
+ it "bans the last 80 passwords" do
+ expect(Setting[:password_count_former_banned]).to eq 80
+ end
+
+ it "sets the lost password option to false" do
+ expect(Setting[:lost_password]).to be false
+ end
+ end
+
+ describe "with password login disabled" do
+ before do
+ allow(OpenProject::Configuration).to receive(:disable_password_login?).and_return(true)
+
+ patch "update", params: { tab: "authentication", settings: new_settings }
+ end
+
+ it "is successful" do
+ expect(response).to be_redirect # to auth tab
+ end
+
+ it "does not set the minimum password length to 42" do
+ expect(Setting[:password_min_length]).to eq 10
+ end
+
+ it "does not set the active character classes to lowercase and uppercase" do
+ expect(Setting[:password_active_rules]).to eq []
+ end
+
+ it "does not set the required number of classes to 7" do
+ expect(Setting[:password_min_adhered_rules]).to eq 0
+ end
+
+ it "does not set passwords to expire after 13 days" do
+ expect(Setting[:password_days_valid]).to eq 365
+ end
+
+ it "does not ban the last 80 passwords" do
+ expect(Setting[:password_count_former_banned]).to eq 2
+ end
+
+ it "keeps the lost password option" do
+ expect(Setting[:lost_password]).to be true
+ end
+ end
+ end
+ end
+end
diff --git a/spec/controllers/admin/settings/projects_settings_controller_spec.rb b/spec/controllers/admin/settings/projects_settings_controller_spec.rb
index d4c6250c022..a4adf3326e7 100644
--- a/spec/controllers/admin/settings/projects_settings_controller_spec.rb
+++ b/spec/controllers/admin/settings/projects_settings_controller_spec.rb
@@ -39,180 +39,11 @@ RSpec.describe Admin::Settings::ProjectsSettingsController do
describe "GET #show" do
render_views
- describe "default project modules" do
- it "contains a check box for the activity module on the projects tab" do
- get "show", params: { tab: "projects" }
+ it "renders the project list settings" do
+ get "show"
- expect(response).to be_successful
- expect(response).to render_template "admin/settings/projects_settings/show"
- expect(response.body).to have_css "input[@name='settings[default_projects_modules][]'][@value='activity']"
- end
-
- context "without activated activity module" do
- before do
- Setting.default_projects_modules = %w[wiki]
- end
-
- it "contains an unchecked checkbox for activity" do
- get "show", params: { tab: "projects" }
-
- expect(response).to be_successful
- expect(response).to render_template "admin/settings/projects_settings/show"
-
- expect(response.body).to have_no_css "input[@name='settings[default_projects_modules][]'][@value='activity'][@checked='checked']"
- end
- end
-
- context "with activity in Setting.default_projects_modules" do
- before do
- Setting.default_projects_modules = %w[activity]
- end
-
- it "contains a checked checkbox for activity" do
- get "show", params: { tab: "projects" }
-
- expect(response).to be_successful
- expect(response).to render_template "admin/settings/projects_settings/show"
-
- expect(response.body).to have_css "input[@name='settings[default_projects_modules][]'][@value='activity'][@checked='checked']"
- end
- end
- end
- end
-
- describe "PATCH #update" do
- render_views
-
- describe "default project modules" do
- it "does not store the activity in the default_projects_modules if unchecked" do
- patch "update",
- params: {
- tab: "projects",
- settings: {
- default_projects_modules: ["wiki"]
- }
- }
-
- expect(response).to be_redirect
- expect(response).to redirect_to action: "show", tab: "projects"
-
- expect(Setting.default_projects_modules).to eq(["wiki"])
- end
-
- it "stores the activity in the default_projects_modules if checked" do
- patch "update",
- params: {
- tab: "projects",
- settings: {
- default_projects_modules: ["activity", "wiki"]
- }
- }
-
- expect(response).to be_redirect
- expect(response).to redirect_to action: "show", tab: "projects"
-
- expect(Setting.default_projects_modules).to eq(["activity", "wiki"])
- end
- end
-
- describe "password settings" do
- let(:new_settings) do
- {
- password_min_length: 42,
- password_active_rules: %w(uppercase lowercase),
- password_min_adhered_rules: 7,
- password_days_valid: 13,
- password_count_former_banned: 80,
- lost_password: false
- }
- end
-
- before do
- old_settings = {
- password_min_length: 10,
- password_active_rules: [],
- password_min_adhered_rules: 0,
- password_days_valid: 365,
- password_count_former_banned: 2,
- lost_password: true
- }
-
- old_settings.each do |key, value|
- Setting[key] = value
- end
- end
-
- context "with password login enabled" do
- before do
- allow(OpenProject::Configuration).to receive(:disable_password_login?).and_return(false)
-
- patch "update", params: { tab: "authentication", settings: new_settings }
- end
-
- it "is successful" do
- expect(response).to be_redirect # to auth tab
- end
-
- it "sets the minimum password length to 42" do
- expect(Setting[:password_min_length]).to eq 42
- end
-
- it "sets the active character classes to lowercase and uppercase" do
- expect(Setting[:password_active_rules]).to eq %w[uppercase lowercase]
- end
-
- it "sets the required number of classes to 7" do
- expect(Setting[:password_min_adhered_rules]).to eq 7
- end
-
- it "sets passwords to expire after 13 days" do
- expect(Setting[:password_days_valid]).to eq 13
- end
-
- it "bans the last 80 passwords" do
- expect(Setting[:password_count_former_banned]).to eq 80
- end
-
- it "sets the lost password option to false" do
- expect(Setting[:lost_password]).to be false
- end
- end
-
- describe "with password login disabled" do
- before do
- allow(OpenProject::Configuration).to receive(:disable_password_login?).and_return(true)
-
- patch "update", params: { tab: "authentication", settings: new_settings }
- end
-
- it "is successful" do
- expect(response).to be_redirect # to auth tab
- end
-
- it "does not set the minimum password length to 42" do
- expect(Setting[:password_min_length]).to eq 10
- end
-
- it "does not set the active character classes to lowercase and uppercase" do
- expect(Setting[:password_active_rules]).to eq []
- end
-
- it "does not set the required number of classes to 7" do
- expect(Setting[:password_min_adhered_rules]).to eq 0
- end
-
- it "does not set passwords to expire after 13 days" do
- expect(Setting[:password_days_valid]).to eq 365
- end
-
- it "does not ban the last 80 passwords" do
- expect(Setting[:password_count_former_banned]).to eq 2
- end
-
- it "keeps the lost password option" do
- expect(Setting[:lost_password]).to be true
- end
- end
+ expect(response).to be_successful
+ expect(response).to render_template "admin/settings/projects_settings/show"
end
end
end