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

group work package settings under single menu

Bruno Pagno3ca4010aadc2
diff --git a/app/components/settings/project_work_packages/header_component.html.erb b/app/components/settings/project_work_packages/header_component.html.erb
new file mode 100644
index 00000000000..978e1831198
--- /dev/null
+++ b/app/components/settings/project_work_packages/header_component.html.erb
@@ -0,0 +1,51 @@
+<%#-- 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.
+
+++#%>
+<%=
+ render Primer::OpenProject::PageHeader.new do |header|
+ header.with_title { t(:label_work_package_plural) }
+ 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.with_text { "Types" }
+ end
+ end
+ if show_categories?
+ tab_nav.with_tab(selected: selected?(:categories), href: project_settings_categories_path) do |tab|
+ tab.with_text { "Categories" }
+ end
+ end
+ if show_custom_fields?
+ tab_nav.with_tab(selected: selected?(:custom_fields), href: project_settings_custom_fields_path) do |tab|
+ tab.with_text { "Custom Fields" }
+ end
+ end
+ end
+ end
+%>
diff --git a/app/components/settings/project_work_packages/header_component.rb b/app/components/settings/project_work_packages/header_component.rb
new file mode 100644
index 00000000000..213add87852
--- /dev/null
+++ b/app/components/settings/project_work_packages/header_component.rb
@@ -0,0 +1,63 @@
+# frozen_string_literal: true
+
+#-- 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 Settings
+ module ProjectWorkPackages
+ class HeaderComponent < ApplicationComponent
+ def initialize(project, selected:)
+ super
+ @project = project
+ @selected = selected
+ end
+
+ def breadcrumbs_items
+ [{ href: project_overview_path(@project.id), text: @project.name },
+ { href: project_settings_general_path(@project.id), text: I18n.t("label_project_settings") },
+ t(:label_work_package_plural)]
+ end
+
+ def selected?(key)
+ @selected == key
+ end
+
+ def show_types?
+ User.current.allowed_in_project?(:manage_types, @project)
+ end
+
+ def show_categories?
+ User.current.allowed_in_project?(:manage_categories, @project)
+ end
+
+ def show_custom_fields?
+ User.current.allowed_in_project?(:select_custom_fields, @project)
+ end
+ end
+ end
+end
diff --git a/app/controllers/projects/settings/categories_controller.rb b/app/controllers/projects/settings/categories_controller.rb
index 688465d2042..7ae2f8100fc 100644
--- a/app/controllers/projects/settings/categories_controller.rb
+++ b/app/controllers/projects/settings/categories_controller.rb
@@ -27,5 +27,5 @@
#++
class Projects::Settings::CategoriesController < Projects::SettingsController
- menu_item :settings_categories
+ menu_item :settings_work_packages
end
diff --git a/app/controllers/projects/settings/custom_fields_controller.rb b/app/controllers/projects/settings/custom_fields_controller.rb
index ffd9d0b6244..91f652d6725 100644
--- a/app/controllers/projects/settings/custom_fields_controller.rb
+++ b/app/controllers/projects/settings/custom_fields_controller.rb
@@ -27,7 +27,7 @@
#++
class Projects::Settings::CustomFieldsController < Projects::SettingsController
- menu_item :settings_custom_fields
+ menu_item :settings_work_packages
def show
@wp_custom_fields = WorkPackageCustomField.order("lower(name)")
diff --git a/app/controllers/projects/settings/types_controller.rb b/app/controllers/projects/settings/types_controller.rb
index 7e706a2eede..7f4f115e666 100644
--- a/app/controllers/projects/settings/types_controller.rb
+++ b/app/controllers/projects/settings/types_controller.rb
@@ -27,7 +27,7 @@
#++
class Projects::Settings::TypesController < Projects::SettingsController
- menu_item :settings_types
+ menu_item :settings_work_packages
def show
@types = ::Type.all
diff --git a/app/controllers/projects/settings/work_packages_controller.rb b/app/controllers/projects/settings/work_packages_controller.rb
new file mode 100644
index 00000000000..921ad5166b6
--- /dev/null
+++ b/app/controllers/projects/settings/work_packages_controller.rb
@@ -0,0 +1,43 @@
+# frozen_string_literal: true
+
+#-- 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.
+#++
+
+class Projects::Settings::WorkPackagesController < Projects::SettingsController
+ menu_item :settings_work_packages
+
+ def show
+ if User.current.allowed_in_project?(:manage_types, @project)
+ redirect_to project_settings_types_path
+ elsif User.current.allowed_in_project?(:manage_categories, @project)
+ redirect_to project_settings_categories_path
+ elsif User.current.allowed_in_project?(:select_custom_fields, @project)
+ redirect_to project_settings_custom_fields_path
+ end
+ end
+end
diff --git a/app/views/projects/settings/categories/show.html.erb b/app/views/projects/settings/categories/show.html.erb
index ff8e71e0cf3..90cc6b2b650 100644
--- a/app/views/projects/settings/categories/show.html.erb
+++ b/app/views/projects/settings/categories/show.html.erb
@@ -26,16 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
See COPYRIGHT and LICENSE files for more details.
++#%>
-<%=
- render Primer::OpenProject::PageHeader.new do |header|
- header.with_title { t(:label_work_package_category_plural) }
- header.with_breadcrumbs(
- [{ href: project_overview_path(@project.id), text: @project.name },
- { href: project_settings_general_path(@project.id), text: I18n.t("label_project_settings") },
- t(:label_work_package_category_plural)]
- )
- end
-%>
+<%= render(Settings::ProjectWorkPackages::HeaderComponent.new(@project, selected: :categories)) %>
<% if current_user.allowed_in_project?(:manage_categories, @project) %>
<%=
diff --git a/app/views/projects/settings/custom_fields/show.html.erb b/app/views/projects/settings/custom_fields/show.html.erb
index 7d1a94d91d2..ba793a83dcc 100644
--- a/app/views/projects/settings/custom_fields/show.html.erb
+++ b/app/views/projects/settings/custom_fields/show.html.erb
@@ -27,16 +27,7 @@ See COPYRIGHT and LICENSE files for more details.
++#%>
-<%=
- render Primer::OpenProject::PageHeader.new do |header|
- header.with_title { I18n.t(:label_custom_field_plural) }
- header.with_breadcrumbs(
- [{ href: project_overview_path(@project.id), text: @project.name },
- { href: project_settings_general_path(@project.id), text: I18n.t("label_project_settings") },
- I18n.t(:label_custom_field_plural)]
- )
- end
-%>
+<%= render(Settings::ProjectWorkPackages::HeaderComponent.new(@project, selected: :custom_fields)) %>
<%=
if current_user.admin?
diff --git a/app/views/projects/settings/types/show.html.erb b/app/views/projects/settings/types/show.html.erb
index 0be452eb330..277a2212478 100644
--- a/app/views/projects/settings/types/show.html.erb
+++ b/app/views/projects/settings/types/show.html.erb
@@ -27,16 +27,7 @@ See COPYRIGHT and LICENSE files for more details.
++#%>
-<%=
- render Primer::OpenProject::PageHeader.new do |header|
- header.with_title { I18n.t(:label_work_package_types) }
- header.with_breadcrumbs(
- [{ href: project_overview_path(@project.id), text: @project.name },
- { href: project_settings_general_path(@project.id), text: I18n.t("label_project_settings") },
- I18n.t(:label_work_package_types)]
- )
- end
-%>
+<%= render(Settings::ProjectWorkPackages::HeaderComponent.new(@project, selected: :types)) %>
<% if Type.any? %>
<%= form_for @project,
diff --git a/app/views/projects/settings/work_packages/show.html.erb b/app/views/projects/settings/work_packages/show.html.erb
new file mode 100644
index 00000000000..ef674952ec3
--- /dev/null
+++ b/app/views/projects/settings/work_packages/show.html.erb
@@ -0,0 +1,40 @@
+<%#-- 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.
+
+++#%>
+<%=
+ render Primer::OpenProject::PageHeader.new do |header|
+ header.with_title { t(:label_work_package_plural) }
+ header.with_breadcrumbs(
+ [{ href: project_overview_path(@project.id), text: @project.name },
+ { href: project_settings_general_path(@project.id), text: I18n.t("label_project_settings") },
+ t(:label_work_package_plural)]
+ )
+ end
+%>
+
+<%= t("settings.work_packages.not_allowed_text") %>
diff --git a/config/initializers/menus.rb b/config/initializers/menus.rb
index 75f81b84672..48114234abb 100644
--- a/config/initializers/menus.rb
+++ b/config/initializers/menus.rb
@@ -650,10 +650,8 @@ Redmine::MenuManager.map :project_menu do |menu|
},
project_custom_fields: { caption: :label_project_attributes_plural },
modules: { caption: :label_module_plural },
- types: { caption: :label_work_package_types },
- custom_fields: { caption: :label_custom_field_plural },
+ work_packages: { caption: :label_work_package_plural },
versions: { caption: :label_version_plural },
- categories: { caption: :label_work_package_category_plural },
repository: { caption: :label_repository },
time_entry_activities: { caption: :enumeration_activities },
storage: { caption: :label_required_disk_storage }
diff --git a/config/initializers/permissions.rb b/config/initializers/permissions.rb
index ec148071682..090934435ba 100644
--- a/config/initializers/permissions.rb
+++ b/config/initializers/permissions.rb
@@ -100,6 +100,7 @@ Rails.application.reloader.to_prepare do
{
"projects/settings/general": %i[show],
"projects/settings/storage": %i[show],
+ "projects/settings/work_packages": %i[show],
"projects/templated": %i[create destroy],
"projects/identifier": %i[show update]
},
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 0533c3db1a0..d7d629cdf1d 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -3983,6 +3983,8 @@ en:
working_days:
section_work_week: "Work week"
section_holidays_and_closures: "Holidays and closures"
+ work_packages:
+ not_allowed_text: "You do not have the necessary permissions to view this page."
text_formatting:
markdown: "Markdown"
diff --git a/config/routes.rb b/config/routes.rb
index 749220f4fdb..3978760b73c 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -278,6 +278,7 @@ Rails.application.routes.draw do
resource :versions, only: %i[show]
resource :categories, only: %i[show update]
resource :storage, only: %i[show], controller: "storage"
+ resource :work_packages, only: %i[show]
end
resource :templated, only: %i[create destroy], controller: "templated"
diff --git a/spec/features/projects/modules_spec.rb b/spec/features/projects/modules_spec.rb
index 69ea63ff35b..834001feae3 100644
--- a/spec/features/projects/modules_spec.rb
+++ b/spec/features/projects/modules_spec.rb
@@ -33,15 +33,16 @@ RSpec.describe "Projects module administration" do
create(:project, enabled_module_names: [])
end
- let(:permissions) { %i(edit_project select_project_modules view_work_packages) }
+ let(:permissions) { %i(edit_project select_project_modules view_work_packages manage_types manage_categories) }
let(:modules_settings_page) { Pages::Projects::Settings::Modules.new(project) }
+ let(:work_packages_settings_page) { Pages::Projects::Settings::WorkPackages.new(project) }
current_user do
create(:user, member_with_permissions: { project => permissions })
end
it "allows adding and removing modules" do
- project_work_packages_menu_link_selector = '//ul[contains(@class, "menu_root")]//span[text()="Work packages"]'
+ project_work_packages_tab_selector = '//ul[contains(@class, "tabnav-tabs")]//span[text()="Categories"]'
modules_settings_page.visit!
@@ -50,7 +51,9 @@ RSpec.describe "Projects module administration" do
expect(page).to have_unchecked_field "Time and costs"
expect(page).to have_unchecked_field "Work packages"
- expect(page).to have_no_xpath(project_work_packages_menu_link_selector)
+ work_packages_settings_page.visit!
+ expect(page).to have_no_xpath(project_work_packages_tab_selector)
+ modules_settings_page.visit!
check "Activity"
click_button "Save"
@@ -70,8 +73,11 @@ RSpec.describe "Projects module administration" do
dependency: "Work packages",
module: "Calendars"))
- expect(page).to have_no_xpath(project_work_packages_menu_link_selector)
+ work_packages_settings_page.visit!
+ expect(page).to have_no_xpath(project_work_packages_tab_selector)
+ modules_settings_page.visit!
+ check "Calendar"
check "Work packages"
click_button "Save"
@@ -82,12 +88,15 @@ RSpec.describe "Projects module administration" do
expect(page).to have_unchecked_field "Time and costs"
expect(page).to have_checked_field "Work packages"
- expect(page).to have_xpath(project_work_packages_menu_link_selector, visible: :all)
+ work_packages_settings_page.visit!
+ expect(page).to have_xpath(project_work_packages_tab_selector, visible: :all)
+ modules_settings_page.visit!
uncheck "Work packages"
click_button "Save"
- expect(page).to have_no_xpath(project_work_packages_menu_link_selector)
+ work_packages_settings_page.visit!
+ expect(page).to have_xpath(project_work_packages_tab_selector)
end
context "with a user who does not have the correct permissions (#38097)" do
diff --git a/spec/features/projects/work_package_type_mgmt_spec.rb b/spec/features/projects/work_package_type_mgmt_spec.rb
index 26cd2a63ecf..381aa3c0d3b 100644
--- a/spec/features/projects/work_package_type_mgmt_spec.rb
+++ b/spec/features/projects/work_package_type_mgmt_spec.rb
@@ -41,7 +41,7 @@ RSpec.describe "Projects", "work package type mgmt", :js do
visit projects_path
click_on "Foo project"
click_on "Project settings"
- click_on "Work package types"
+ click_on "Work packages"
expect(page).to have_checked_field("Phase", visible: :all)
expect(page).to have_checked_field("Milestone", visible: :all)
diff --git a/spec/support/pages/projects/settings/work_packages.rb b/spec/support/pages/projects/settings/work_packages.rb
new file mode 100644
index 00000000000..350e1bfb929
--- /dev/null
+++ b/spec/support/pages/projects/settings/work_packages.rb
@@ -0,0 +1,51 @@
+# frozen_string_literal: true
+
+# -- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2010-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 "support/pages/page"
+
+module Pages
+ module Projects
+ module Settings
+ class WorkPackages < Pages::Page
+ attr_accessor :project
+
+ def initialize(project)
+ super()
+
+ @project = project
+ end
+
+ def path
+ "/projects/#{project.identifier}/settings/work_packages"
+ end
+ end
+ end
+ end
+end