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

scaffold settings page for activities

Bruno Pagnoe61b0447ee45
diff --git a/app/components/settings/project_work_packages/header_component.html.erb b/app/components/settings/project_work_packages/header_component.html.erb
index 2e9adcffcc2..46b857b392f 100644
--- a/app/components/settings/project_work_packages/header_component.html.erb
+++ b/app/components/settings/project_work_packages/header_component.html.erb
@@ -46,6 +46,9 @@ See COPYRIGHT and LICENSE files for more details.
tab.with_text { t("attributes.custom_values") }
end
end
+ tab_nav.with_tab(selected: selected?(:activities), href: project_settings_work_packages_activities_path) do |tab|
+ tab.with_text { t("label_activity") }
+ end
end
end
%>
diff --git a/app/controllers/projects/settings/work_packages/activities_controller.rb b/app/controllers/projects/settings/work_packages/activities_controller.rb
new file mode 100644
index 00000000000..b1db79446d2
--- /dev/null
+++ b/app/controllers/projects/settings/work_packages/activities_controller.rb
@@ -0,0 +1,37 @@
+# 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::WorkPackages::ActivitiesController < Projects::SettingsController
+ menu_item :settings_work_packages
+
+ def update
+ redirect_to :show
+ end
+end
diff --git a/app/controllers/projects/settings/work_packages_controller.rb b/app/controllers/projects/settings/work_packages_controller.rb
index 69ef4f49f6c..1f02129df55 100644
--- a/app/controllers/projects/settings/work_packages_controller.rb
+++ b/app/controllers/projects/settings/work_packages_controller.rb
@@ -38,6 +38,8 @@ class Projects::Settings::WorkPackagesController < Projects::SettingsController
redirect_to project_settings_work_packages_categories_path
elsif User.current.allowed_in_project?(:select_custom_fields, @project)
redirect_to project_settings_work_packages_custom_fields_path
+ elsif User.current.allowed_in_project?(:edit_project, @project)
+ redirect_to project_settings_work_packages_activities_path
end
end
end
diff --git a/app/views/projects/settings/work_packages/activities/show.html.erb b/app/views/projects/settings/work_packages/activities/show.html.erb
new file mode 100644
index 00000000000..1ea3a215e43
--- /dev/null
+++ b/app/views/projects/settings/work_packages/activities/show.html.erb
@@ -0,0 +1,32 @@
+<%#-- 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(Settings::ProjectWorkPackages::HeaderComponent.new(@project, selected: :activities)) %>
+
+<span>Form goes here</span>
diff --git a/app/views/projects/settings/work_packages/show.html.erb b/app/views/projects/settings/work_packages/show.html.erb
index faf53e6873f..bafacf45d8b 100644
--- a/app/views/projects/settings/work_packages/show.html.erb
+++ b/app/views/projects/settings/work_packages/show.html.erb
@@ -26,6 +26,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
See COPYRIGHT and LICENSE files for more details.
++#%>
+
+<%
+ # this file is a fallback and in normal circunstances should never be rendered
+%>
+
<%=
render Primer::OpenProject::PageHeader.new do |header|
header.with_title { t(:label_work_package_plural) }
diff --git a/config/initializers/menus.rb b/config/initializers/menus.rb
index cfa5291483f..28e9b9c535c 100644
--- a/config/initializers/menus.rb
+++ b/config/initializers/menus.rb
@@ -653,7 +653,8 @@ Redmine::MenuManager.map :project_menu do |menu|
work_packages: {
caption: :label_work_package_plural,
if: ->(project) {
- User.current.allowed_in_project?(:manage_types, project) ||
+ User.current.allowed_in_project?(:edit_project, 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)
}
diff --git a/config/initializers/permissions.rb b/config/initializers/permissions.rb
index eda5478685c..9d32d9f7c47 100644
--- a/config/initializers/permissions.rb
+++ b/config/initializers/permissions.rb
@@ -101,6 +101,7 @@ Rails.application.reloader.to_prepare do
"projects/settings/general": %i[show],
"projects/settings/storage": %i[show],
"projects/settings/work_packages": %i[show],
+ "projects/settings/work_packages/activities": %i[show update],
"projects/templated": %i[create destroy],
"projects/identifier": %i[show update]
},
diff --git a/config/routes.rb b/config/routes.rb
index 9d448e89d0c..d15b9fed4cd 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -280,6 +280,7 @@ Rails.application.routes.draw do
get :categories, to: redirect("projects/%{project_id}/settings/work_packages/categories")
resource :work_packages, only: %i[show]
namespace :work_packages do
+ resource :activities, only: %i[show update]
resource :types, only: %i[show update]
resource :custom_fields, only: %i[show update]
resource :categories, only: %i[show update]
diff --git a/spec/features/projects/work_packages_settings_spec.rb b/spec/features/projects/work_packages_settings_spec.rb
index c3cf8bd111c..2c6060306ec 100644
--- a/spec/features/projects/work_packages_settings_spec.rb
+++ b/spec/features/projects/work_packages_settings_spec.rb
@@ -72,11 +72,23 @@ RSpec.describe "Projects", "work packages settings menu", :js do
end
end
- context "when the user does not have access to any tabs" do
+ context "when the user has access to the activities tab" do
let(:permissions) { %i(edit_project view_work_packages) }
current_user { create(:user, member_with_permissions: { project => permissions }) }
+ it "displays the custom fields tab" do
+ work_packages_settings_page.visit!
+ expect(page).to have_css(".tabnav-tab", text: "Activity")
+ expect(page).to have_css("span", text: "Form goes here")
+ end
+ end
+
+ context "when the user does not have access to any tabs" do
+ let(:permissions) { %i(view_work_packages) }
+
+ current_user { create(:user, member_with_permissions: { project => permissions }) }
+
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")
diff --git a/spec/routing/project_settings_routing_spec.rb b/spec/routing/project_settings_routing_spec.rb
index a2587c92c29..88880864c68 100644
--- a/spec/routing/project_settings_routing_spec.rb
+++ b/spec/routing/project_settings_routing_spec.rb
@@ -106,5 +106,19 @@ RSpec.describe Projects::SettingsController do
controller: "projects/settings/work_packages/types", action: "update", project_id: "123"
)
end
+
+ it do
+ expect(get("/projects/123/settings/work_packages/activities"))
+ .to route_to(
+ controller: "projects/settings/work_packages/activities", action: "show", project_id: "123"
+ )
+ end
+
+ it do
+ expect(patch("/projects/123/settings/work_packages/activities"))
+ .to route_to(
+ controller: "projects/settings/work_packages/activities", action: "update", project_id: "123"
+ )
+ end
end
end