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

list all existing life cycle elements

ulferts7eb0e4f86169
diff --git a/app/components/projects/settings/life_cycles/element_component.html.erb b/app/components/projects/settings/life_cycles/element_component.html.erb
new file mode 100644
index 00000000000..f5a249fb1ff
--- /dev/null
+++ b/app/components/projects/settings/life_cycles/element_component.html.erb
@@ -0,0 +1,12 @@
+<%=
+ component_wrapper do
+ flex_layout(align_items: :center,
+ justify_content: :space_between) do |element_container|
+ element_container.with_column(flex_layout: true) do |title_container|
+ title_container.with_column(pt: 1, mr: 2) do
+ render(Primer::Beta::Text.new) { element.name }
+ end
+ end
+ end
+ end
+%>
diff --git a/app/components/projects/settings/life_cycles/element_component.rb b/app/components/projects/settings/life_cycles/element_component.rb
new file mode 100644
index 00000000000..39d1f5ac39e
--- /dev/null
+++ b/app/components/projects/settings/life_cycles/element_component.rb
@@ -0,0 +1,53 @@
+# -- 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.
+# ++
+
+module Projects
+ module Settings
+ module LifeCycles
+ class ElementComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpPrimer::ComponentHelpers
+ include OpTurbo::Streamable
+
+ attr_reader :element
+
+ def initialize(life_cycle_element)
+ super
+
+ @element = life_cycle_element
+ end
+
+ private
+
+ def wrapper_uniq_by
+ element.id
+ end
+ end
+ end
+ end
+end
diff --git a/app/components/projects/settings/life_cycles/index_component.html.erb b/app/components/projects/settings/life_cycles/index_component.html.erb
new file mode 100644
index 00000000000..2cb0c2a50af
--- /dev/null
+++ b/app/components/projects/settings/life_cycles/index_component.html.erb
@@ -0,0 +1,29 @@
+<%=
+ component_wrapper do
+ render(border_box_container(mb: 3, data: { test_selector: "project-life-cycle-administration" })) do |component|
+ component.with_header(font_weight: :bold, py: 2) do
+ flex_layout(justify_content: :space_between, align_items: :center) do |header_container|
+ header_container.with_column(py: 2) do
+ # adding py: 2 here to match the padding of the actions_container
+ # otherwise the header height changes when the actions gets hidden when filtering
+ render(Primer::Beta::Text.new(font_weight: :bold)) do
+ I18n.t('projects.settings.life_cycle.header.title')
+ end
+ end
+ end
+ end
+ if life_cycle_elements.empty?
+ component.with_row do
+ render(Primer::Beta::Text.new(color: :subtle)) { t("projects.settings.life_cycle.non_defined") }
+ end
+ else
+ life_cycle_elements.each do |life_cycle_element|
+ component.with_row(data: { 'projects--settings--project-custom-fields-mapping-filter-target': 'searchItem' },
+ test_selector: "project-life-cycle-element-#{life_cycle_element.id}") do
+ render(Projects::Settings::LifeCycles::ElementComponent.new(life_cycle_element))
+ end
+ end
+ end
+ end
+ end
+%>
diff --git a/app/components/projects/settings/life_cycles/index_component.rb b/app/components/projects/settings/life_cycles/index_component.rb
new file mode 100644
index 00000000000..55261db5c05
--- /dev/null
+++ b/app/components/projects/settings/life_cycles/index_component.rb
@@ -0,0 +1,56 @@
+# -- 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.
+# ++
+
+module Projects
+ module Settings
+ module LifeCycles
+ class IndexComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpPrimer::ComponentHelpers
+ include OpTurbo::Streamable
+
+ attr_reader :project,
+ :life_cycle_elements
+
+ def initialize(project:, life_cycle_elements:)
+ super
+
+ @project = project
+ @life_cycle_elements = life_cycle_elements
+ end
+
+ private
+
+ # TODO: Check if this is necessary
+ def wrapper_uniq_by
+ @project.id
+ end
+ end
+ end
+ end
+end
diff --git a/app/controllers/projects/settings/life_cycles_controller.rb b/app/controllers/projects/settings/life_cycles_controller.rb
index e3b63a75e7c..6ac4af23cad 100644
--- a/app/controllers/projects/settings/life_cycles_controller.rb
+++ b/app/controllers/projects/settings/life_cycles_controller.rb
@@ -29,7 +29,15 @@
class Projects::Settings::LifeCyclesController < Projects::SettingsController
include OpTurbo::ComponentStream
+ before_action :load_life_cycle_elements, only: %i[show]
+
menu_item :settings_life_cycles
def show; end
+
+ private
+
+ def load_life_cycle_elements
+ @life_cycle_elements = LifeCycle.all
+ end
end
diff --git a/app/views/projects/settings/life_cycles/show.html.erb b/app/views/projects/settings/life_cycles/show.html.erb
index a57319a2026..b90027e4078 100644
--- a/app/views/projects/settings/life_cycles/show.html.erb
+++ b/app/views/projects/settings/life_cycles/show.html.erb
@@ -29,8 +29,5 @@ See COPYRIGHT and LICENSE files for more details.
<div data-turbo="true">
<%= render Projects::Settings::LifeCycles::ShowPageHeaderComponent.new(project: @project) %>
- <%#= render(Projects::Settings::ProjectCustomFieldSections::IndexComponent.new(
- project: @project,
- project_custom_field_sections: @project_custom_field_sections,
- )) %>
+ <%= render(Projects::Settings::LifeCycles::IndexComponent.new( project: @project, life_cycle_elements: @life_cycle_elements)) %>
</div>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index c9af4de7824..b164afc1622 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -392,6 +392,7 @@ en:
header:
title: "Project lifecycle"
description: 'These project stages and gates in the project lifecycle will be displayed in your <a href=%{overview_url} target="_blank">project overview page</a> and are defined in the <a href=%{admin_settings_url} target="_blank">administration settings</a> by the administrator of the instance. You can enable or disable individual attributes.'
+ non_defined: "Neither stages nor gates are currently defined."
project_custom_fields:
header:
title: "Project attributes"
diff --git a/spec/features/projects/life_cycle/active_in_project_spec.rb b/spec/features/projects/life_cycle/active_in_project_spec.rb
index d055f3ffe36..94009b45dfa 100644
--- a/spec/features/projects/life_cycle/active_in_project_spec.rb
+++ b/spec/features/projects/life_cycle/active_in_project_spec.rb
@@ -34,8 +34,7 @@ RSpec.describe "Projects life cycle settings", :js, :with_cuprite do
shared_let(:user_with_permission) do
create(:user,
member_with_permissions: {
- # TODO: change to specific permission
- project: %w[
+ project => %w[
select_project_life_cycle
]
})
@@ -54,6 +53,12 @@ RSpec.describe "Projects life cycle settings", :js, :with_cuprite do
it "allows toggling the active/inactive state of lifecycle elements" do
project_lifecycle_page.visit!
+
+ project_lifecycle_page.expect_listed(initiating_stage,
+ read_to_execute_gate,
+ executing_stage,
+ read_to_close_gate,
+ closing_stage)
end
end
end
diff --git a/spec/support/pages/projects/settings/life_cycle.rb b/spec/support/pages/projects/settings/life_cycle.rb
index 0348a9c8c1f..63e08eac7fe 100644
--- a/spec/support/pages/projects/settings/life_cycle.rb
+++ b/spec/support/pages/projects/settings/life_cycle.rb
@@ -44,6 +44,18 @@ module Pages
def path
"/projects/#{project.identifier}/settings/life_cycle"
end
+
+ def expect_listed(*life_cycle_elements)
+ raise "Currently depends on checking for at least two life cycle events" if life_cycle_elements.size < 2
+
+ life_cycle_elements.each_cons(2) do |predecessor, successor|
+ expect(page).to have_css("#{life_cycle_test_selector(predecessor)} + #{life_cycle_test_selector(successor)}")
+ end
+ end
+
+ def life_cycle_test_selector(element)
+ test_selector("project-life-cycle-element-#{element.id}")
+ end
end
end
end