From dde1cb37da5cc01a260c4c7a97e2f1ac7693a5d7 Mon Sep 17 00:00:00 2001 From: Christophe Bliard Date: Thu, 29 Aug 2024 10:57:28 +0200 Subject: [PATCH 01/10] Rename 'Work packages settings' page as 'General' --- app/components/types/edit_page_header_component.rb | 2 +- app/components/workflows/page_header_component.rb | 2 +- .../admin/settings/work_packages_settings_controller.rb | 2 +- .../admin/settings/work_packages_settings/show.html.erb | 8 ++++---- app/views/custom_actions/edit.html.erb | 2 +- app/views/custom_actions/index.html.erb | 2 +- app/views/custom_actions/new.html.erb | 2 +- app/views/statuses/edit.html.erb | 2 +- app/views/statuses/index.html.erb | 2 +- app/views/statuses/new.html.erb | 2 +- app/views/types/index.html.erb | 2 +- app/views/types/new.html.erb | 2 +- config/initializers/menus.rb | 4 ++-- config/locales/en.yml | 1 - config/routes.rb | 2 +- 15 files changed, 18 insertions(+), 19 deletions(-) diff --git a/app/components/types/edit_page_header_component.rb b/app/components/types/edit_page_header_component.rb index 950c93203bfd..ad254afd81b1 100644 --- a/app/components/types/edit_page_header_component.rb +++ b/app/components/types/edit_page_header_component.rb @@ -42,7 +42,7 @@ def initialize(type:, tabs: nil) def breadcrumb_items [{ href: admin_index_path, text: t("label_administration") }, - { href: admin_settings_work_package_tracking_path, text: t(:label_work_package_plural) }, + { href: admin_settings_work_packages_general_path, text: t(:label_work_package_plural) }, { href: types_path, text: t(:label_type_plural) }, @type.name] end diff --git a/app/components/workflows/page_header_component.rb b/app/components/workflows/page_header_component.rb index 7d93e1d92c3c..0df058b70a17 100644 --- a/app/components/workflows/page_header_component.rb +++ b/app/components/workflows/page_header_component.rb @@ -40,7 +40,7 @@ def initialize(state:) def breadcrumb_items base_items = [{ href: admin_index_path, text: t("label_administration") }, - { href: admin_settings_work_package_tracking_path, text: t(:label_work_package_plural) }, + { href: admin_settings_work_packages_general_path, text: t(:label_work_package_plural) }, title] if @state == :edit diff --git a/app/controllers/admin/settings/work_packages_settings_controller.rb b/app/controllers/admin/settings/work_packages_settings_controller.rb index d2f1f369f00f..20e9004c6d93 100644 --- a/app/controllers/admin/settings/work_packages_settings_controller.rb +++ b/app/controllers/admin/settings/work_packages_settings_controller.rb @@ -29,7 +29,7 @@ module Admin::Settings class WorkPackagesSettingsController < ::Admin::SettingsController current_menu_item :show do - :work_packages_setting + :work_packages_settings_general end end end diff --git a/app/views/admin/settings/work_packages_settings/show.html.erb b/app/views/admin/settings/work_packages_settings/show.html.erb index 24865fffc3c2..06610ce17128 100644 --- a/app/views/admin/settings/work_packages_settings/show.html.erb +++ b/app/views/admin/settings/work_packages_settings/show.html.erb @@ -27,14 +27,14 @@ See COPYRIGHT and LICENSE files for more details. ++#%> -<% html_title t(:label_administration), t(:label_work_packages_settings) -%> +<% html_title t(:label_administration), t(:label_work_package_plural), t(:label_general) -%> <%= render Primer::OpenProject::PageHeader.new do |header| - header.with_title { t(:label_work_packages_settings) } + header.with_title { t(:label_general) } header.with_breadcrumbs([{ href: admin_index_path, text: t("label_administration") }, - { href: admin_settings_work_package_tracking_path, text: t(:label_work_package_plural) }, - t(:label_work_packages_settings)]) + { href: admin_settings_work_packages_general_path, text: t(:label_work_package_plural) }, + t(:label_general)]) end %> diff --git a/app/views/custom_actions/edit.html.erb b/app/views/custom_actions/edit.html.erb index 6c6a563ca8ca..9005be612aaf 100644 --- a/app/views/custom_actions/edit.html.erb +++ b/app/views/custom_actions/edit.html.erb @@ -33,7 +33,7 @@ See COPYRIGHT and LICENSE files for more details. render Primer::OpenProject::PageHeader.new do |header| header.with_title { @custom_action.name } header.with_breadcrumbs([{ href: admin_index_path, text: t("label_administration") }, - { href: admin_settings_work_package_tracking_path, text: t(:label_work_package_plural) }, + { href: admin_settings_work_packages_general_path, text: t(:label_work_package_plural) }, { href: custom_actions_path, text: t("custom_actions.plural") }, @custom_action.name ]) end diff --git a/app/views/custom_actions/index.html.erb b/app/views/custom_actions/index.html.erb index 7b56c168457a..f391825bb692 100644 --- a/app/views/custom_actions/index.html.erb +++ b/app/views/custom_actions/index.html.erb @@ -4,7 +4,7 @@ render Primer::OpenProject::PageHeader.new do |header| header.with_title { t("custom_actions.plural") } header.with_breadcrumbs([{ href: admin_index_path, text: t("label_administration") }, - { href: admin_settings_work_package_tracking_path, text: t(:label_work_package_plural) }, + { href: admin_settings_work_packages_general_path, text: t(:label_work_package_plural) }, t("custom_actions.plural") ]) end %> diff --git a/app/views/custom_actions/new.html.erb b/app/views/custom_actions/new.html.erb index f124a55d65bb..50b2cebfa625 100644 --- a/app/views/custom_actions/new.html.erb +++ b/app/views/custom_actions/new.html.erb @@ -33,7 +33,7 @@ See COPYRIGHT and LICENSE files for more details. render Primer::OpenProject::PageHeader.new do |header| header.with_title { t("custom_actions.new") } header.with_breadcrumbs([{ href: admin_index_path, text: t("label_administration") }, - { href: admin_settings_work_package_tracking_path, text: t(:label_work_package_plural) }, + { href: admin_settings_work_packages_general_path, text: t(:label_work_package_plural) }, { href: custom_actions_path, text: t("custom_actions.plural") }, t("custom_actions.new") ]) end diff --git a/app/views/statuses/edit.html.erb b/app/views/statuses/edit.html.erb index d955e4ce3c2c..428fe61dd969 100644 --- a/app/views/statuses/edit.html.erb +++ b/app/views/statuses/edit.html.erb @@ -33,7 +33,7 @@ See COPYRIGHT and LICENSE files for more details. render Primer::OpenProject::PageHeader.new do |header| header.with_title { @status.name } header.with_breadcrumbs([{ href: admin_index_path, text: t("label_administration") }, - { href: admin_settings_work_package_tracking_path, text: t(:label_work_package_plural) }, + { href: admin_settings_work_packages_general_path, text: t(:label_work_package_plural) }, { href: statuses_path, text: t(:label_status) }, @status.name]) end diff --git a/app/views/statuses/index.html.erb b/app/views/statuses/index.html.erb index 5bbbfe24fc45..cf0dbfb93692 100644 --- a/app/views/statuses/index.html.erb +++ b/app/views/statuses/index.html.erb @@ -33,7 +33,7 @@ See COPYRIGHT and LICENSE files for more details. render Primer::OpenProject::PageHeader.new do |header| header.with_title { I18n.t(:label_status) } header.with_breadcrumbs([{ href: admin_index_path, text: t("label_administration") }, - { href: admin_settings_work_package_tracking_path, text: t(:label_work_package_plural) }, + { href: admin_settings_work_packages_general_path, text: t(:label_work_package_plural) }, I18n.t(:label_status)]) end %> diff --git a/app/views/statuses/new.html.erb b/app/views/statuses/new.html.erb index a3537b90d16e..8b5b660713a6 100644 --- a/app/views/statuses/new.html.erb +++ b/app/views/statuses/new.html.erb @@ -33,7 +33,7 @@ See COPYRIGHT and LICENSE files for more details. render Primer::OpenProject::PageHeader.new do |header| header.with_title { t(:label_work_package_status_new) } header.with_breadcrumbs([{ href: admin_index_path, text: t("label_administration") }, - { href: admin_settings_work_package_tracking_path, text: t(:label_work_package_plural) }, + { href: admin_settings_work_packages_general_path, text: t(:label_work_package_plural) }, { href: statuses_path, text: t(:label_status) }, t(:label_work_package_status_new)]) end diff --git a/app/views/types/index.html.erb b/app/views/types/index.html.erb index 7794772696fe..1b8856b626e1 100644 --- a/app/views/types/index.html.erb +++ b/app/views/types/index.html.erb @@ -33,7 +33,7 @@ See COPYRIGHT and LICENSE files for more details. render Primer::OpenProject::PageHeader.new do |header| header.with_title { t(:label_type_plural) } header.with_breadcrumbs([{ href: admin_index_path, text: t("label_administration") }, - { href: admin_settings_work_package_tracking_path, text: t(:label_work_package_plural) }, + { href: admin_settings_work_packages_general_path, text: t(:label_work_package_plural) }, t(:label_type_plural)]) end %> diff --git a/app/views/types/new.html.erb b/app/views/types/new.html.erb index 44eee4a52a3a..60cc30a16a0e 100644 --- a/app/views/types/new.html.erb +++ b/app/views/types/new.html.erb @@ -33,7 +33,7 @@ See COPYRIGHT and LICENSE files for more details. render Primer::OpenProject::PageHeader.new do |header| header.with_title { t(:label_type_new) } header.with_breadcrumbs([{ href: admin_index_path, text: t("label_administration") }, - { href: admin_settings_work_package_tracking_path, text: t(:label_work_package_plural) }, + { href: admin_settings_work_packages_general_path, text: t(:label_work_package_plural) }, { href: types_path, text: t(:label_type_plural) }, t(:label_type_new)]) end diff --git a/config/initializers/menus.rb b/config/initializers/menus.rb index 8800c3d6a770..e07c9ca255d1 100644 --- a/config/initializers/menus.rb +++ b/config/initializers/menus.rb @@ -305,10 +305,10 @@ caption: :label_work_package_plural, icon: "op-view-list" - menu.push :work_packages_setting, + menu.push :work_packages_settings_general, { controller: "/admin/settings/work_packages_settings", action: :show }, if: Proc.new { User.current.admin? }, - caption: :label_work_packages_settings, + caption: :label_general, parent: :admin_work_packages menu.push :types, diff --git a/config/locales/en.yml b/config/locales/en.yml index d647c65ab1db..a6fdc41e63b3 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2598,7 +2598,6 @@ en: label_work_package_new: "New work package" label_work_package_edit: "Edit work package %{name}" label_work_package_plural: "Work packages" - label_work_packages_settings: "Work packages settings" label_work_package_status: "Work package status" label_work_package_status_new: "New status" label_work_package_status_plural: "Work package statuses" diff --git a/config/routes.rb b/config/routes.rb index 599deee6f166..0f580ac17c59 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -490,7 +490,7 @@ resource :api, controller: "/admin/settings/api_settings", only: %i[show update] # It is important to have this named something else than "work_packages". # Otherwise the angular ui-router will also recognize that as a WorkPackage page and apply according classes. - resource :work_package_tracking, controller: "/admin/settings/work_packages_settings", only: %i[show update] + resource :work_packages_general, 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 From aea93c6835eb17f3260310cf596f064fb1f6dcb3 Mon Sep 17 00:00:00 2001 From: Christophe Bliard Date: Thu, 29 Aug 2024 11:20:26 +0200 Subject: [PATCH 02/10] refactor: Rename WorkPackageSettingsController to WorkPackageGeneralController --- ...gs_controller.rb => work_packages_general_controller.rb} | 4 ++-- .../_enterprise_feature_hint.html.erb | 0 .../show.html.erb | 0 config/initializers/menus.rb | 6 +++--- config/routes.rb | 2 +- ...ler_spec.rb => work_packages_general_controller_spec.rb} | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) rename app/controllers/admin/settings/{work_packages_settings_controller.rb => work_packages_general_controller.rb} (92%) rename app/views/admin/settings/{work_packages_settings => work_packages_general}/_enterprise_feature_hint.html.erb (100%) rename app/views/admin/settings/{work_packages_settings => work_packages_general}/show.html.erb (100%) rename spec/controllers/admin/settings/{work_packages_settings_controller_spec.rb => work_packages_general_controller_spec.rb} (96%) diff --git a/app/controllers/admin/settings/work_packages_settings_controller.rb b/app/controllers/admin/settings/work_packages_general_controller.rb similarity index 92% rename from app/controllers/admin/settings/work_packages_settings_controller.rb rename to app/controllers/admin/settings/work_packages_general_controller.rb index 20e9004c6d93..82164cb79875 100644 --- a/app/controllers/admin/settings/work_packages_settings_controller.rb +++ b/app/controllers/admin/settings/work_packages_general_controller.rb @@ -27,9 +27,9 @@ #++ module Admin::Settings - class WorkPackagesSettingsController < ::Admin::SettingsController + class WorkPackagesGeneralController < ::Admin::SettingsController current_menu_item :show do - :work_packages_settings_general + :work_packages_general end end end diff --git a/app/views/admin/settings/work_packages_settings/_enterprise_feature_hint.html.erb b/app/views/admin/settings/work_packages_general/_enterprise_feature_hint.html.erb similarity index 100% rename from app/views/admin/settings/work_packages_settings/_enterprise_feature_hint.html.erb rename to app/views/admin/settings/work_packages_general/_enterprise_feature_hint.html.erb diff --git a/app/views/admin/settings/work_packages_settings/show.html.erb b/app/views/admin/settings/work_packages_general/show.html.erb similarity index 100% rename from app/views/admin/settings/work_packages_settings/show.html.erb rename to app/views/admin/settings/work_packages_general/show.html.erb diff --git a/config/initializers/menus.rb b/config/initializers/menus.rb index e07c9ca255d1..8f6f602152cb 100644 --- a/config/initializers/menus.rb +++ b/config/initializers/menus.rb @@ -300,13 +300,13 @@ parent: :users_and_permissions menu.push :admin_work_packages, - { controller: "/admin/settings/work_packages_settings", action: :show }, + { controller: "/admin/settings/work_packages_general", action: :show }, if: Proc.new { User.current.admin? }, caption: :label_work_package_plural, icon: "op-view-list" - menu.push :work_packages_settings_general, - { controller: "/admin/settings/work_packages_settings", action: :show }, + menu.push :work_packages_general, + { controller: "/admin/settings/work_packages_general", action: :show }, if: Proc.new { User.current.admin? }, caption: :label_general, parent: :admin_work_packages diff --git a/config/routes.rb b/config/routes.rb index 0f580ac17c59..010719637780 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -490,7 +490,7 @@ resource :api, controller: "/admin/settings/api_settings", only: %i[show update] # It is important to have this named something else than "work_packages". # Otherwise the angular ui-router will also recognize that as a WorkPackage page and apply according classes. - resource :work_packages_general, controller: "/admin/settings/work_packages_settings", only: %i[show update] + resource :work_packages_general, controller: "/admin/settings/work_packages_general", 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 diff --git a/spec/controllers/admin/settings/work_packages_settings_controller_spec.rb b/spec/controllers/admin/settings/work_packages_general_controller_spec.rb similarity index 96% rename from spec/controllers/admin/settings/work_packages_settings_controller_spec.rb rename to spec/controllers/admin/settings/work_packages_general_controller_spec.rb index 98a0e6067bfc..4f4140fe0255 100644 --- a/spec/controllers/admin/settings/work_packages_settings_controller_spec.rb +++ b/spec/controllers/admin/settings/work_packages_general_controller_spec.rb @@ -31,12 +31,12 @@ require "spec_helper" -RSpec.describe Admin::Settings::WorkPackagesSettingsController do +RSpec.describe Admin::Settings::WorkPackagesGeneralController do shared_let(:user) { create(:admin) } current_user { user } - require_admin_and_render_template("work_packages_settings") + require_admin_and_render_template("work_packages_general") context "when changing progress calculation from work-based to status-based" do shared_let(:status) { create(:status, default_done_ratio: 42) } From 1affbd5f24a62a28350f0d5ade1ae0a3a35dec81 Mon Sep 17 00:00:00 2001 From: Christophe Bliard Date: Thu, 29 Aug 2024 16:02:52 +0200 Subject: [PATCH 03/10] Remove unused css class --- config/initializers/menus.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/config/initializers/menus.rb b/config/initializers/menus.rb index 8f6f602152cb..8fbdd3f96f7b 100644 --- a/config/initializers/menus.rb +++ b/config/initializers/menus.rb @@ -321,8 +321,7 @@ { controller: "/statuses" }, if: Proc.new { User.current.admin? }, caption: :label_status, - parent: :admin_work_packages, - html: { class: "statuses" } + parent: :admin_work_packages menu.push :workflows, { controller: "/workflows", action: "edit" }, From e4e18cdf6c56372e90346e31c81b26bf52a1eca2 Mon Sep 17 00:00:00 2001 From: Christophe Bliard Date: Wed, 4 Sep 2024 14:45:31 +0200 Subject: [PATCH 04/10] refactor: use shared_examples instead of obscure method I did not understand what `require_admin_and_render_template` was supposed to do. I thought it was creating some initial user and rendering the template as a before action, but actually it only adds some examples. Using RSpec shared examples makes intent clearer. --- .../admin/settings/aggregation_settings_controller_spec.rb | 6 +++--- .../admin/settings/api_settings_controller_spec.rb | 4 ++-- .../admin/settings/attachments_settings_controller_spec.rb | 4 ++-- .../settings/authentication_settings_controller_spec.rb | 2 +- .../admin/settings/date_format_settings_controller_spec.rb | 2 +- .../admin/settings/general_settings_controller_spec.rb | 4 ++-- .../admin/settings/icalendar_settings_controller_spec.rb | 2 +- .../settings/incoming_mails_settings_controller_spec.rb | 4 ++-- .../admin/settings/languages_settings_controller_spec.rb | 2 +- .../settings/mail_notifications_settings_controller_spec.rb | 4 ++-- .../admin/settings/repositories_settings_controller_spec.rb | 4 ++-- .../admin/settings/users_settings_controller_spec.rb | 4 ++-- .../admin/settings/work_packages_general_controller_spec.rb | 2 +- .../working_days_and_hours_settings_controller_spec.rb | 2 +- spec/support/shared/require_admin.rb | 2 +- 15 files changed, 24 insertions(+), 24 deletions(-) diff --git a/spec/controllers/admin/settings/aggregation_settings_controller_spec.rb b/spec/controllers/admin/settings/aggregation_settings_controller_spec.rb index d2a3ba3e6da9..9495179af8a4 100644 --- a/spec/controllers/admin/settings/aggregation_settings_controller_spec.rb +++ b/spec/controllers/admin/settings/aggregation_settings_controller_spec.rb @@ -31,10 +31,10 @@ require "spec_helper" -RSpec.describe Admin::Settings::AggregationSettingsController do # rubocop:disable RSpec/EmptyExampleGroup +RSpec.describe Admin::Settings::AggregationSettingsController do shared_let(:user) { create(:admin) } - current_user { user } + shared_current_user { user } - require_admin_and_render_template("aggregation_settings") + include_examples "GET #show requires admin permission and renders template", path: "aggregation_settings" end diff --git a/spec/controllers/admin/settings/api_settings_controller_spec.rb b/spec/controllers/admin/settings/api_settings_controller_spec.rb index 89b3c233114a..ce1c3519f10f 100644 --- a/spec/controllers/admin/settings/api_settings_controller_spec.rb +++ b/spec/controllers/admin/settings/api_settings_controller_spec.rb @@ -31,10 +31,10 @@ require "spec_helper" -RSpec.describe Admin::Settings::APISettingsController do # rubocop:disable RSpec/EmptyExampleGroup +RSpec.describe Admin::Settings::APISettingsController do shared_let(:user) { create(:admin) } current_user { user } - require_admin_and_render_template("api_settings") + include_examples "GET #show requires admin permission and renders template", path: "api_settings" end diff --git a/spec/controllers/admin/settings/attachments_settings_controller_spec.rb b/spec/controllers/admin/settings/attachments_settings_controller_spec.rb index aa9687bba2f6..a1cdf7639e4e 100644 --- a/spec/controllers/admin/settings/attachments_settings_controller_spec.rb +++ b/spec/controllers/admin/settings/attachments_settings_controller_spec.rb @@ -31,10 +31,10 @@ require "spec_helper" -RSpec.describe Admin::Settings::AttachmentsSettingsController do # rubocop:disable RSpec/EmptyExampleGroup +RSpec.describe Admin::Settings::AttachmentsSettingsController do shared_let(:user) { create(:admin) } current_user { user } - require_admin_and_render_template("attachments_settings") + include_examples "GET #show requires admin permission and renders template", path: "attachments_settings" end diff --git a/spec/controllers/admin/settings/authentication_settings_controller_spec.rb b/spec/controllers/admin/settings/authentication_settings_controller_spec.rb index e494d2bd3e67..9c7122c49db5 100644 --- a/spec/controllers/admin/settings/authentication_settings_controller_spec.rb +++ b/spec/controllers/admin/settings/authentication_settings_controller_spec.rb @@ -33,7 +33,7 @@ current_user { user } - require_admin_and_render_template("authentication_settings") + include_examples "GET #show requires admin permission and renders template", path: "authentication_settings" describe "PATCH #update" do describe "registration_footer" do diff --git a/spec/controllers/admin/settings/date_format_settings_controller_spec.rb b/spec/controllers/admin/settings/date_format_settings_controller_spec.rb index 558d194e37e8..85eba47390cd 100644 --- a/spec/controllers/admin/settings/date_format_settings_controller_spec.rb +++ b/spec/controllers/admin/settings/date_format_settings_controller_spec.rb @@ -35,7 +35,7 @@ shared_let(:user) { create(:admin) } current_user { user } - require_admin_and_render_template("date_format_settings") + include_examples "GET #show requires admin permission and renders template", path: "date_format_settings" describe "PATCH #update" do subject { patch "update", params: } diff --git a/spec/controllers/admin/settings/general_settings_controller_spec.rb b/spec/controllers/admin/settings/general_settings_controller_spec.rb index b1021f913f7f..74d2b21927f2 100644 --- a/spec/controllers/admin/settings/general_settings_controller_spec.rb +++ b/spec/controllers/admin/settings/general_settings_controller_spec.rb @@ -31,10 +31,10 @@ require "spec_helper" -RSpec.describe Admin::Settings::GeneralSettingsController do # rubocop:disable RSpec/EmptyExampleGroup +RSpec.describe Admin::Settings::GeneralSettingsController do shared_let(:user) { create(:admin) } current_user { user } - require_admin_and_render_template("general_settings") + include_examples "GET #show requires admin permission and renders template", path: "general_settings" end diff --git a/spec/controllers/admin/settings/icalendar_settings_controller_spec.rb b/spec/controllers/admin/settings/icalendar_settings_controller_spec.rb index e97c865fd8b7..b6638bdc8117 100644 --- a/spec/controllers/admin/settings/icalendar_settings_controller_spec.rb +++ b/spec/controllers/admin/settings/icalendar_settings_controller_spec.rb @@ -36,7 +36,7 @@ current_user { user } - require_admin_and_render_template("icalendar_settings") + include_examples "GET #show requires admin permission and renders template", path: "icalendar_settings" describe "PATCH #update" do subject { patch "update", params: } diff --git a/spec/controllers/admin/settings/incoming_mails_settings_controller_spec.rb b/spec/controllers/admin/settings/incoming_mails_settings_controller_spec.rb index afaa981e60ce..37479f01da36 100644 --- a/spec/controllers/admin/settings/incoming_mails_settings_controller_spec.rb +++ b/spec/controllers/admin/settings/incoming_mails_settings_controller_spec.rb @@ -31,10 +31,10 @@ require "spec_helper" -RSpec.describe Admin::Settings::IncomingMailsSettingsController do # rubocop:disable RSpec/EmptyExampleGroup +RSpec.describe Admin::Settings::IncomingMailsSettingsController do shared_let(:user) { create(:admin) } current_user { user } - require_admin_and_render_template("incoming_mails_settings") + include_examples "GET #show requires admin permission and renders template", path: "incoming_mails_settings" end diff --git a/spec/controllers/admin/settings/languages_settings_controller_spec.rb b/spec/controllers/admin/settings/languages_settings_controller_spec.rb index fbca7cb60217..2de57b1bc435 100644 --- a/spec/controllers/admin/settings/languages_settings_controller_spec.rb +++ b/spec/controllers/admin/settings/languages_settings_controller_spec.rb @@ -36,7 +36,7 @@ current_user { user } - require_admin_and_render_template("languages_settings") + include_examples "GET #show requires admin permission and renders template", path: "languages_settings" describe "PATCH #update" do subject { patch "update", params: } diff --git a/spec/controllers/admin/settings/mail_notifications_settings_controller_spec.rb b/spec/controllers/admin/settings/mail_notifications_settings_controller_spec.rb index 2aee4c85c482..6938a5610691 100644 --- a/spec/controllers/admin/settings/mail_notifications_settings_controller_spec.rb +++ b/spec/controllers/admin/settings/mail_notifications_settings_controller_spec.rb @@ -31,10 +31,10 @@ require "spec_helper" -RSpec.describe Admin::Settings::MailNotificationsSettingsController do # rubocop:disable RSpec/EmptyExampleGroup +RSpec.describe Admin::Settings::MailNotificationsSettingsController do shared_let(:user) { create(:admin) } current_user { user } - require_admin_and_render_template("mail_notifications_settings") + include_examples "GET #show requires admin permission and renders template", path: "mail_notifications_settings" end diff --git a/spec/controllers/admin/settings/repositories_settings_controller_spec.rb b/spec/controllers/admin/settings/repositories_settings_controller_spec.rb index c8ba2ac3f7ff..1b32c9e115be 100644 --- a/spec/controllers/admin/settings/repositories_settings_controller_spec.rb +++ b/spec/controllers/admin/settings/repositories_settings_controller_spec.rb @@ -31,10 +31,10 @@ require "spec_helper" -RSpec.describe Admin::Settings::RepositoriesSettingsController do # rubocop:disable RSpec/EmptyExampleGroup +RSpec.describe Admin::Settings::RepositoriesSettingsController do shared_let(:user) { create(:admin) } current_user { user } - require_admin_and_render_template("repositories_settings") + include_examples "GET #show requires admin permission and renders template", path: "repositories_settings" end diff --git a/spec/controllers/admin/settings/users_settings_controller_spec.rb b/spec/controllers/admin/settings/users_settings_controller_spec.rb index fae872a90daa..d805a05b4de7 100644 --- a/spec/controllers/admin/settings/users_settings_controller_spec.rb +++ b/spec/controllers/admin/settings/users_settings_controller_spec.rb @@ -31,10 +31,10 @@ require "spec_helper" -RSpec.describe Admin::Settings::UsersSettingsController do # rubocop:disable RSpec/EmptyExampleGroup +RSpec.describe Admin::Settings::UsersSettingsController do shared_let(:user) { create(:admin) } current_user { user } - require_admin_and_render_template("users_settings") + include_examples "GET #show requires admin permission and renders template", path: "users_settings" end diff --git a/spec/controllers/admin/settings/work_packages_general_controller_spec.rb b/spec/controllers/admin/settings/work_packages_general_controller_spec.rb index 4f4140fe0255..fb2d97be5dfd 100644 --- a/spec/controllers/admin/settings/work_packages_general_controller_spec.rb +++ b/spec/controllers/admin/settings/work_packages_general_controller_spec.rb @@ -36,7 +36,7 @@ current_user { user } - require_admin_and_render_template("work_packages_general") + include_examples "GET #show requires admin permission and renders template", path: "work_packages_general" context "when changing progress calculation from work-based to status-based" do shared_let(:status) { create(:status, default_done_ratio: 42) } diff --git a/spec/controllers/admin/settings/working_days_and_hours_settings_controller_spec.rb b/spec/controllers/admin/settings/working_days_and_hours_settings_controller_spec.rb index 99daa77fd285..be85865f0d40 100644 --- a/spec/controllers/admin/settings/working_days_and_hours_settings_controller_spec.rb +++ b/spec/controllers/admin/settings/working_days_and_hours_settings_controller_spec.rb @@ -33,7 +33,7 @@ current_user { user } - require_admin_and_render_template("working_days_and_hours_settings") + include_examples "GET #show requires admin permission and renders template", path: "working_days_and_hours_settings" describe "update" do let(:working_days) { [*"1".."7"] } diff --git a/spec/support/shared/require_admin.rb b/spec/support/shared/require_admin.rb index a115fbc5b6ac..2b71a5ab6f3f 100644 --- a/spec/support/shared/require_admin.rb +++ b/spec/support/shared/require_admin.rb @@ -26,7 +26,7 @@ # See COPYRIGHT and LICENSE files for more details. #++ -def require_admin_and_render_template(path) +RSpec.shared_examples "GET #show requires admin permission and renders template" do |path:| describe "GET #show" do subject { get "show" } From edc1d1843af5bbd09854af51a1264c9653c836d6 Mon Sep 17 00:00:00 2001 From: Christophe Bliard Date: Wed, 4 Sep 2024 15:00:27 +0200 Subject: [PATCH 05/10] Move progress tracking fields in dedicated admin page --- .../settings/progress_tracking_controller.rb | 35 ++++++ .../settings/progress_tracking/show.html.erb | 71 +++++++++++++ .../work_packages_general/show.html.erb | 20 +--- config/initializers/menus.rb | 6 ++ config/locales/en.yml | 1 + config/routes.rb | 1 + ...ler.ts => progress-tracking.controller.ts} | 2 +- .../progress_tracking_controller_spec.rb | 100 ++++++++++++++++++ .../work_packages_general_controller_spec.rb | 60 ----------- 9 files changed, 216 insertions(+), 80 deletions(-) create mode 100644 app/controllers/admin/settings/progress_tracking_controller.rb create mode 100644 app/views/admin/settings/progress_tracking/show.html.erb rename frontend/src/stimulus/controllers/dynamic/admin/{work-packages-settings.controller.ts => progress-tracking.controller.ts} (97%) create mode 100644 spec/controllers/admin/settings/progress_tracking_controller_spec.rb diff --git a/app/controllers/admin/settings/progress_tracking_controller.rb b/app/controllers/admin/settings/progress_tracking_controller.rb new file mode 100644 index 000000000000..e6687d0afd6e --- /dev/null +++ b/app/controllers/admin/settings/progress_tracking_controller.rb @@ -0,0 +1,35 @@ +#-- copyright +# OpenProject is an open source project management software. +# Copyright (C) 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 ProgressTrackingController < ::Admin::SettingsController + current_menu_item :show do + :progress_tracking + end + end +end diff --git a/app/views/admin/settings/progress_tracking/show.html.erb b/app/views/admin/settings/progress_tracking/show.html.erb new file mode 100644 index 000000000000..45e7dcb48f08 --- /dev/null +++ b/app/views/admin/settings/progress_tracking/show.html.erb @@ -0,0 +1,71 @@ +<%#-- copyright +OpenProject is an open source project management software. +Copyright (C) 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. + +++#%> + +<% html_title t(:label_administration), t(:label_work_package_plural), t(:label_progress_tracking) -%> + +<%= + render Primer::OpenProject::PageHeader.new do |header| + header.with_title { t(:label_progress_tracking) } + header.with_breadcrumbs([{ href: admin_index_path, text: t("label_administration") }, + { href: admin_settings_work_packages_general_path, text: t(:label_work_package_plural) }, + t(:label_progress_tracking)]) + end +%> + +<%= styled_form_tag({ action: :update }, method: :patch) do %> +
+
+ <%= setting_select :work_package_done_ratio, + WorkPackage::DONE_RATIO_OPTIONS.collect { |i| [t("setting_work_package_done_ratio_#{i}"), i] }, + container_class: "-middle", + data: { admin__progress_tracking_target: "progressCalculationModeSelect", + action: "admin--progress-tracking#displayWarning" } %> +
<%= + if OpenProject::FeatureDecisions.percent_complete_edition_active? + t("setting_work_package_done_ratio_explanation_html") + else + # This condition branch to be removed in 15.0 with :percent_complete_edition feature flag removal + t("setting_work_package_done_ratio_explanation_pre_14_4_without_percent_complete_edition_html") + end + %>
+
+ +
+ + <%= styled_button_tag t(:button_save), class: "-primary -with-icon icon-checkmark" %> +<% end %> diff --git a/app/views/admin/settings/work_packages_general/show.html.erb b/app/views/admin/settings/work_packages_general/show.html.erb index 06610ce17128..b0c7d3445a65 100644 --- a/app/views/admin/settings/work_packages_general/show.html.erb +++ b/app/views/admin/settings/work_packages_general/show.html.erb @@ -39,28 +39,10 @@ See COPYRIGHT and LICENSE files for more details. %> <%= styled_form_tag({ action: :update }, method: :patch) do %> -
+
<%= setting_check_box :cross_project_work_package_relations %>
<%= setting_check_box :display_subprojects_work_packages %>
<%= setting_check_box :work_package_startdate_is_adddate %>
-
- <%= setting_select :work_package_done_ratio, - WorkPackage::DONE_RATIO_OPTIONS.collect { |i| [t("setting_work_package_done_ratio_#{i}"), i] }, - container_class: "-middle", - data: { admin__work_packages_settings_target: "progressCalculationModeSelect", - action: "change->admin--work-packages-settings#displayWarning" } %> -
<%= - if OpenProject::FeatureDecisions.percent_complete_edition_active? - t("setting_work_package_done_ratio_explanation_html") - else - # This condition branch to be removed in 15.0 with :percent_complete_edition feature flag removal - t("setting_work_package_done_ratio_explanation_pre_14_4_without_percent_complete_edition_html") - end - %>
-