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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
adjust urls and permissions
Bruno Pagnoc5a5d5260b31
diff --git a/app/components/settings/project_work_packages/header_component.html.erb b/app/components/settings/project_work_packages/header_component.html.erbindex ac9cce34495..bce39e7a1b4 100644--- a/app/components/settings/project_work_packages/header_component.html.erb+++ b/app/components/settings/project_work_packages/header_component.html.erb@@ -32,17 +32,17 @@ See COPYRIGHT and LICENSE files for more details.header.with_breadcrumbs(breadcrumbs_items)header.with_tab_nav(label: nil) do |tab_nav|if show_types?- tab_nav.with_tab(selected: selected?(:types), href: project_settings_types_path) do |tab|+ tab_nav.with_tab(selected: selected?(:types), href: project_settings_work_packages_types_path) do |tab|tab.with_text { t("settings.work_packages.types_tab") }endendif show_categories?- tab_nav.with_tab(selected: selected?(:categories), href: project_settings_categories_path) do |tab|+ tab_nav.with_tab(selected: selected?(:categories), href: project_settings_work_packages_categories_path) do |tab|tab.with_text { t("settings.work_packages.categories_tab") }endendif show_custom_fields?- tab_nav.with_tab(selected: selected?(:custom_fields), href: project_settings_custom_fields_path) do |tab|+ tab_nav.with_tab(selected: selected?(:custom_fields), href: project_settings_work_packages_custom_fields_path) do |tab|tab.with_text { t("settings.work_packages.custom_fields_tab") }endenddiff --git a/app/controllers/projects/settings/categories_controller.rb b/app/controllers/projects/settings/work_packages/categories_controller.rbsimilarity index 93%rename from app/controllers/projects/settings/categories_controller.rbrename to app/controllers/projects/settings/work_packages/categories_controller.rbindex 7ae2f8100fc..54686d26bfc 100644--- a/app/controllers/projects/settings/categories_controller.rb+++ b/app/controllers/projects/settings/work_packages/categories_controller.rb@@ -26,6 +26,6 @@# See COPYRIGHT and LICENSE files for more details.#++-class Projects::Settings::CategoriesController < Projects::SettingsController+class Projects::Settings::WorkPackages::CategoriesController < Projects::SettingsControllermenu_item :settings_work_packagesenddiff --git a/app/controllers/projects/settings/custom_fields_controller.rb b/app/controllers/projects/settings/work_packages/custom_fields_controller.rbsimilarity index 95%rename from app/controllers/projects/settings/custom_fields_controller.rbrename to app/controllers/projects/settings/work_packages/custom_fields_controller.rbindex 91f652d6725..018d26c80fb 100644--- a/app/controllers/projects/settings/custom_fields_controller.rb+++ b/app/controllers/projects/settings/work_packages/custom_fields_controller.rb@@ -26,7 +26,7 @@# See COPYRIGHT and LICENSE files for more details.#++-class Projects::Settings::CustomFieldsController < Projects::SettingsController+class Projects::Settings::WorkPackages::CustomFieldsController < Projects::SettingsControllermenu_item :settings_work_packagesdef showdiff --git a/app/controllers/projects/settings/types_controller.rb b/app/controllers/projects/settings/work_packages/types_controller.rbsimilarity index 95%rename from app/controllers/projects/settings/types_controller.rbrename to app/controllers/projects/settings/work_packages/types_controller.rbindex 7f4f115e666..6df0f8d0292 100644--- a/app/controllers/projects/settings/types_controller.rb+++ b/app/controllers/projects/settings/work_packages/types_controller.rb@@ -26,7 +26,7 @@# See COPYRIGHT and LICENSE files for more details.#++-class Projects::Settings::TypesController < Projects::SettingsController+class Projects::Settings::WorkPackages::TypesController < Projects::SettingsControllermenu_item :settings_work_packagesdef showdiff --git a/app/controllers/projects/settings/work_packages_controller.rb b/app/controllers/projects/settings/work_packages_controller.rbindex 921ad5166b6..69ef4f49f6c 100644--- a/app/controllers/projects/settings/work_packages_controller.rb+++ b/app/controllers/projects/settings/work_packages_controller.rb@@ -33,11 +33,11 @@ class Projects::Settings::WorkPackagesController < Projects::SettingsControllerdef showif User.current.allowed_in_project?(:manage_types, @project)- redirect_to project_settings_types_path+ redirect_to project_settings_work_packages_types_pathelsif User.current.allowed_in_project?(:manage_categories, @project)- redirect_to project_settings_categories_path+ redirect_to project_settings_work_packages_categories_pathelsif User.current.allowed_in_project?(:select_custom_fields, @project)- redirect_to project_settings_custom_fields_path+ redirect_to project_settings_work_packages_custom_fields_pathendendenddiff --git a/app/views/projects/settings/categories/show.html.erb b/app/views/projects/settings/work_packages/categories/show.html.erbsimilarity index 100%rename from app/views/projects/settings/categories/show.html.erbrename to app/views/projects/settings/work_packages/categories/show.html.erbdiff --git a/app/views/projects/settings/custom_fields/_form.html.erb b/app/views/projects/settings/work_packages/custom_fields/_form.html.erbsimilarity index 96%rename from app/views/projects/settings/custom_fields/_form.html.erbrename to app/views/projects/settings/work_packages/custom_fields/_form.html.erbindex d1b19307c88..c6a5312042e 100644--- a/app/views/projects/settings/custom_fields/_form.html.erb+++ b/app/views/projects/settings/work_packages/custom_fields/_form.html.erb@@ -68,7 +68,7 @@ See COPYRIGHT and LICENSE files for more details.</thead><tbody><% all_custom_fields = @project.all_work_package_custom_fields.pluck(:id) %>- <% work_package_custom_fields.includes(:types).each do |custom_field| %>+ <% work_package_custom_fields.includes(:types).find_each do |custom_field| %><%options = {lang: custom_field.name_locale,@@ -97,7 +97,7 @@ See COPYRIGHT and LICENSE files for more details.<td><% if current_user.admin? %><% type_links = custom_field.types.map { |t| link_to(t.name, edit_tab_type_path(id: t.id, tab: "form_configuration")) } %>- <%= safe_join type_links, ", ".html_safe %>+ <%= safe_join type_links, ", " %><% else %><%= custom_field.types.map(&:name).join(", ") %><% end %>diff --git a/app/views/projects/settings/custom_fields/show.html.erb b/app/views/projects/settings/work_packages/custom_fields/show.html.erbsimilarity index 96%rename from app/views/projects/settings/custom_fields/show.html.erbrename to app/views/projects/settings/work_packages/custom_fields/show.html.erbindex ba793a83dcc..8ac3bc13fe4 100644--- a/app/views/projects/settings/custom_fields/show.html.erb+++ b/app/views/projects/settings/work_packages/custom_fields/show.html.erb@@ -48,7 +48,7 @@ See COPYRIGHT and LICENSE files for more details.<% if @wp_custom_fields.any? %><%= labelled_tabular_form_for @project,- url: project_settings_custom_fields_path(@project),+ url: project_settings_work_packages_custom_fields_path(@project),html: { id: "modules-form" } do |form| %><%= render partial: "form",diff --git a/app/views/projects/settings/types/_form.html.erb b/app/views/projects/settings/work_packages/types/_form.html.erbsimilarity index 95%rename from app/views/projects/settings/types/_form.html.erbrename to app/views/projects/settings/work_packages/types/_form.html.erbindex 86aae5b6d5e..015ab9102f7 100644--- a/app/views/projects/settings/types/_form.html.erb+++ b/app/views/projects/settings/work_packages/types/_form.html.erb@@ -79,11 +79,11 @@ See COPYRIGHT and LICENSE files for more details.</thead><tbody><% projects_types_id = project.types.pluck(:id) %>- <% Type.includes(:color).each do |type| %>+ <% Type.includes(:color).find_each do |type| %><tr><td class='center'><% type_id = "project_planning_element_type_ids_#{type.id}" %>- <%= label_tag type_id, t(".enable_type_in_project", type: type.name), class: "hidden-for-sighted" %>+ <%= label_tag type_id, t("projects.settings.types.form.enable_type_in_project", type: type.name), class: "hidden-for-sighted" %><%= check_box_tag "project[type_ids][]",type.id,projects_types_id.include?(type.id),diff --git a/app/views/projects/settings/types/show.html.erb b/app/views/projects/settings/work_packages/types/show.html.erbsimilarity index 95%rename from app/views/projects/settings/types/show.html.erbrename to app/views/projects/settings/work_packages/types/show.html.erbindex 277a2212478..bcfde42c2c2 100644--- a/app/views/projects/settings/types/show.html.erb+++ b/app/views/projects/settings/work_packages/types/show.html.erb@@ -31,7 +31,7 @@ See COPYRIGHT and LICENSE files for more details.<% if Type.any? %><%= form_for @project,- url: project_settings_types_path(@project),+ url: project_settings_work_packages_types_path(@project),method: :patch,html: { id: "types-form" } do |f| %><%= render partial: "form",diff --git a/config/initializers/menus.rb b/config/initializers/menus.rbindex 48114234abb..cfa5291483f 100644--- a/config/initializers/menus.rb+++ b/config/initializers/menus.rb@@ -650,7 +650,14 @@ Redmine::MenuManager.map :project_menu do |menu|},project_custom_fields: { caption: :label_project_attributes_plural },modules: { caption: :label_module_plural },- work_packages: { caption: :label_work_package_plural },+ work_packages: {+ caption: :label_work_package_plural,+ if: ->(project) {+ User.current.allowed_in_project?(:manage_types, project) ||+ User.current.allowed_in_project?(:manage_categories, project) ||+ User.current.allowed_in_project?(:select_custom_fields, project)+ }+ },versions: { caption: :label_version_plural },repository: { caption: :label_repository },time_entry_activities: { caption: :enumeration_activities },diff --git a/config/initializers/permissions.rb b/config/initializers/permissions.rbindex 090934435ba..d42e5216801 100644--- a/config/initializers/permissions.rb+++ b/config/initializers/permissions.rb@@ -184,14 +184,14 @@ Rails.application.reloader.to_prepare domap.permission :manage_types,{- "projects/settings/types": %i[show update]+ "projects/settings/work_packages/types": %i[show update]},permissible_on: :project,require: :membermap.permission :select_custom_fields,{- "projects/settings/custom_fields": %i[show update]+ "projects/settings/work_packages/custom_fields": %i[show update]},permissible_on: :project,require: :member@@ -319,7 +319,7 @@ Rails.application.reloader.to_prepare do# WorkPackage categorieswpt.permission :manage_categories,{- "projects/settings/categories": [:show],+ "projects/settings/work_packages/categories": [:show],categories: %i[new create edit update destroy]},permissible_on: :project,diff --git a/config/routes.rb b/config/routes.rbindex 3978760b73c..9d448e89d0c 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -254,7 +254,6 @@ Rails.application.routes.draw donamespace "settings" doresource :general, only: %i[show], controller: "general"resource :modules, only: %i[show update]- resource :types, only: %i[show update]resource :project_custom_fields, only: %i[show] domember dopost :toggle@@ -273,12 +272,18 @@ Rails.application.routes.draw dopost :disable_allendend- resource :custom_fields, only: %i[show update]resource :repository, only: %i[show], controller: "repository"resource :versions, only: %i[show]- resource :categories, only: %i[show update]resource :storage, only: %i[show], controller: "storage"+ get :types, to: redirect("projects/%{project_id}/settings/work_packages/types")+ get :custom_fields, to: redirect("projects/%{project_id}/settings/work_packages/custom_fields")+ get :categories, to: redirect("projects/%{project_id}/settings/work_packages/categories")resource :work_packages, only: %i[show]+ namespace :work_packages do+ resource :types, only: %i[show update]+ resource :custom_fields, only: %i[show update]+ resource :categories, only: %i[show update]+ endendresource :templated, only: %i[create destroy], controller: "templated"diff --git a/spec/features/projects/work_packages_settings_spec.rb b/spec/features/projects/work_packages_settings_spec.rbindex b46f37a4a48..0ae018563de 100644--- a/spec/features/projects/work_packages_settings_spec.rb+++ b/spec/features/projects/work_packages_settings_spec.rb@@ -33,6 +33,7 @@ require "spec_helper"RSpec.describe "Projects", "work packages settings menu", :js dolet!(:project) { create(:project) }let(:work_packages_settings_page) { Pages::Projects::Settings::WorkPackages.new(project) }+ let(:general_settings_page) { Pages::Projects::Settings::General.new(project) }describe "view settings page" docontext "when the user has access to types tab" do@@ -42,7 +43,7 @@ RSpec.describe "Projects", "work packages settings menu", :js doit "displays the types tab" dowork_packages_settings_page.visit!- expect(page).to have_css(".tabnav-tab", text: I18n.t("settings.work_packages.types_tab"))+ expect(page).to have_css(".tabnav-tab", text: "Types")expect(page).to have_css("#types-form")endend@@ -54,8 +55,8 @@ RSpec.describe "Projects", "work packages settings menu", :js doit "displays the categories tab" dowork_packages_settings_page.visit!- expect(page).to have_css(".tabnav-tab", text: I18n.t("settings.work_packages.categories_tab"))- expect(page).to have_css("span", text: I18n.t("projects.settings.categories.no_results_title_text"))+ expect(page).to have_css(".tabnav-tab", text: "Categories")+ expect(page).to have_css("span", text: "There are currently no work package categories.")endend@@ -66,8 +67,8 @@ RSpec.describe "Projects", "work packages settings menu", :js doit "displays the custom fields tab" dowork_packages_settings_page.visit!- expect(page).to have_css(".tabnav-tab", text: I18n.t("settings.work_packages.custom_fields_tab"))- expect(page).to have_css("span", text: I18n.t("projects.settings.custom_fields.no_results_title_text"))+ expect(page).to have_css(".tabnav-tab", text: "Custom Fields")+ expect(page).to have_css("span", text: "There are currently no custom fields available.")endend@@ -76,10 +77,9 @@ RSpec.describe "Projects", "work packages settings menu", :js docurrent_user { create(:user, member_with_permissions: { project => permissions }) }- it "does not display any tabs" do- work_packages_settings_page.visit!- expect(page).to have_no_css(".tabnav-tab")- expect(page).to have_css("span", text: I18n.t("settings.work_packages.not_allowed_text"))+ it "does not display the menu entry" do+ general_settings_page.visit!+ expect(page).to have_no_css(".op-menu--item-title", text: "Work packages")endendenddiff --git a/spec/routing/project_settings_routing_spec.rb b/spec/routing/project_settings_routing_spec.rbindex ed6e3d5d7b7..a2587c92c29 100644--- a/spec/routing/project_settings_routing_spec.rb+++ b/spec/routing/project_settings_routing_spec.rb@@ -52,16 +52,16 @@ RSpec.describe Projects::SettingsController doendit do- expect(get("/projects/123/settings/custom_fields"))+ expect(get("/projects/123/settings/work_packages/custom_fields")).to route_to(- controller: "projects/settings/custom_fields", action: "show", project_id: "123"+ controller: "projects/settings/work_packages/custom_fields", action: "show", project_id: "123")endit do- expect(patch("/projects/123/settings/custom_fields"))+ expect(patch("/projects/123/settings/work_packages/custom_fields")).to route_to(- controller: "projects/settings/custom_fields", action: "update", project_id: "123"+ controller: "projects/settings/work_packages/custom_fields", action: "update", project_id: "123")end@@ -73,9 +73,9 @@ RSpec.describe Projects::SettingsController doendit do- expect(get("/projects/123/settings/categories"))+ expect(get("/projects/123/settings/work_packages/categories")).to route_to(- controller: "projects/settings/categories", action: "show", project_id: "123"+ controller: "projects/settings/work_packages/categories", action: "show", project_id: "123")end@@ -94,16 +94,16 @@ RSpec.describe Projects::SettingsController doendit do- expect(get("/projects/123/settings/types"))+ expect(get("/projects/123/settings/work_packages/types")).to route_to(- controller: "projects/settings/types", action: "show", project_id: "123"+ controller: "projects/settings/work_packages/types", action: "show", project_id: "123")endit do- expect(patch("/projects/123/settings/types"))+ expect(patch("/projects/123/settings/work_packages/types")).to route_to(- controller: "projects/settings/types", action: "update", project_id: "123"+ controller: "projects/settings/work_packages/types", action: "update", project_id: "123")endend