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

Make the project admin life cycle settings page work.

Dombi Attila070833adca1c
diff --git a/app/components/projects/life_cycle_component.rb b/app/components/projects/life_cycle_component.rb
index d9fc12c025d..4848048c168 100644
--- a/app/components/projects/life_cycle_component.rb
+++ b/app/components/projects/life_cycle_component.rb
@@ -31,6 +31,10 @@ module Projects
class LifeCycleComponent < ApplicationComponent
include OpPrimer::ComponentHelpers
+ # TODO: This component is currently not in use! It should be a shared component
+ # between the Projects::Settings::LifeCycleSteps::StepComponent and the
+ # Settings::ProjectLifeCycleStepDefinitions::RowComponent.
+ # It should hold the icon, definition name and gate text information.
def text
if model.start_gate? && model.end_gate?
I18n.t("settings.project_phase_definitions.both_gate")
diff --git a/app/components/projects/settings/life_cycle_steps/index_component.rb b/app/components/projects/settings/life_cycle_steps/index_component.rb
index bd1c174f1cc..d747a35cfc4 100644
--- a/app/components/projects/settings/life_cycle_steps/index_component.rb
+++ b/app/components/projects/settings/life_cycle_steps/index_component.rb
@@ -40,7 +40,7 @@ module Projects
private
def life_cycle_definitions_and_step_active
- active_ids = project.life_cycle_steps.where(active: true).pluck(:definition_id).to_set
+ active_ids = project.phases.where(active: true).pluck(:definition_id).to_set
life_cycle_definitions.all.map do |definition|
[definition, definition.id.in?(active_ids)]
diff --git a/app/components/projects/settings/life_cycle_steps/index_page_header_component.html.erb b/app/components/projects/settings/life_cycle_steps/index_page_header_component.html.erb
index bce464dcb65..469b7bed2ac 100644
--- a/app/components/projects/settings/life_cycle_steps/index_page_header_component.html.erb
+++ b/app/components/projects/settings/life_cycle_steps/index_page_header_component.html.erb
@@ -5,7 +5,7 @@
t(
"projects.settings.life_cycle.header.description_html",
overview_url: project_path(project),
- admin_settings_url: admin_settings_project_life_cycle_step_definitions_path
+ admin_settings_url: admin_settings_project_phase_definitions_path
)
end
header.with_breadcrumbs(breadcrumb_items)
diff --git a/app/components/projects/settings/life_cycle_steps/step_component.html.erb b/app/components/projects/settings/life_cycle_steps/step_component.html.erb
index 492d1609532..7d777ea72c5 100644
--- a/app/components/projects/settings/life_cycle_steps/step_component.html.erb
+++ b/app/components/projects/settings/life_cycle_steps/step_component.html.erb
@@ -4,11 +4,14 @@
justify_content: :space_between
) do |step_container|
step_container.with_column(flex_layout: true, mr: 2, classes: "min-width-0") do |title_container|
- title_container.with_column(pt: 1, mr: 3, classes: "ellipsis") do
+ title_container.with_column(pt: 1, mr: 1, classes: icon_color_class) do
+ render Primer::Beta::Octicon.new(icon: icon)
+ end
+ title_container.with_column(pt: 1, mr: 2, classes: "ellipsis") do
render(Primer::Beta::Text.new(classes: "filter-target-visible-text")) { definition.name }
end
title_container.with_column(pt: 1, classes: "no-wrap") do
- render(Projects::LifeCycleComponent.new(definition))
+ render(Primer::Beta::Text.new(**gate_text_options)) { gate_info }
end
end
# py: 1 quick fix: prevents the row from bouncing as the toggle switch currently changes height while toggling
diff --git a/app/components/projects/settings/life_cycle_steps/step_component.rb b/app/components/projects/settings/life_cycle_steps/step_component.rb
index 2dd0f59b647..6691d1ef44e 100644
--- a/app/components/projects/settings/life_cycle_steps/step_component.rb
+++ b/app/components/projects/settings/life_cycle_steps/step_component.rb
@@ -37,6 +37,32 @@ module Projects
options :definition,
:active?
+ # TODO: Remove these helper methods once the Projects::LifeCycleComponent
+ # has been refactored.
+ def icon
+ :"op-phase"
+ end
+
+ def icon_color_class
+ helpers.hl_inline_class("project_phase_definition", definition)
+ end
+
+ def gate_info
+ if definition.start_gate? && model.end_gate?
+ I18n.t("settings.project_phase_definitions.both_gate")
+ elsif definition.start_gate?
+ I18n.t("settings.project_phase_definitions.start_gate")
+ elsif definition.end_gate?
+ I18n.t("settings.project_phase_definitions.end_gate")
+ else
+ I18n.t("settings.project_phase_definitions.no_gate")
+ end
+ end
+
+ def gate_text_options
+ { color: :muted, font_size: :small }.merge(options)
+ end
+
def toggle_aria_label
I18n.t("projects.settings.life_cycle.step.use_in_project", step: definition.name)
end
diff --git a/app/components/settings/project_life_cycle_step_definitions/row_component.html.erb b/app/components/settings/project_life_cycle_step_definitions/row_component.html.erb
index 78361881817..9c40ff194f1 100644
--- a/app/components/settings/project_life_cycle_step_definitions/row_component.html.erb
+++ b/app/components/settings/project_life_cycle_step_definitions/row_component.html.erb
@@ -39,6 +39,9 @@ See COPYRIGHT and LICENSE files for more details.
)
end
end
+ title_container.with_column(classes: icon_color_class) do
+ render Primer::Beta::Octicon.new(icon: icon)
+ end
title_container.with_column(classes: "ellipsis", test_selector: "project-life-cycle-step-definition-name") do
render(
if allowed_to_customize_life_cycle?
@@ -57,7 +60,7 @@ See COPYRIGHT and LICENSE files for more details.
end
end
title_container.with_column do
- render(Projects::LifeCycleComponent.new(definition))
+ render(Primer::Beta::Text.new(**gate_text_options)) { gate_info }
end
title_container.with_column(classes: "no-wrap") do
render(Primer::Beta::Text.new) { t("project.count", count: definition.project_count) }
diff --git a/app/components/settings/project_life_cycle_step_definitions/row_component.rb b/app/components/settings/project_life_cycle_step_definitions/row_component.rb
index 777fcf1b76c..f7777cb91dc 100644
--- a/app/components/settings/project_life_cycle_step_definitions/row_component.rb
+++ b/app/components/settings/project_life_cycle_step_definitions/row_component.rb
@@ -39,6 +39,32 @@ module Settings
options :first?,
:last?
+ # TODO: Remove these helper classes once the Projects::LifeCycleComponent
+ # has been refactored.
+ def icon
+ :"op-phase"
+ end
+
+ def icon_color_class
+ helpers.hl_inline_class("project_phase_definition", definition)
+ end
+
+ def gate_info
+ if definition.start_gate? && definition.end_gate?
+ I18n.t("settings.project_phase_definitions.both_gate")
+ elsif definition.start_gate?
+ I18n.t("settings.project_phase_definitions.start_gate")
+ elsif definition.end_gate?
+ I18n.t("settings.project_phase_definitions.end_gate")
+ else
+ I18n.t("settings.project_phase_definitions.no_gate")
+ end
+ end
+
+ def gate_text_options
+ { color: :muted, font_size: :small }.merge(options)
+ end
+
private
def move_action(menu:, move_to:, label:, icon:)
diff --git a/app/controllers/projects/settings/life_cycle_steps_controller.rb b/app/controllers/projects/settings/life_cycle_steps_controller.rb
index 7041ac5f6dc..a45d938a19d 100644
--- a/app/controllers/projects/settings/life_cycle_steps_controller.rb
+++ b/app/controllers/projects/settings/life_cycle_steps_controller.rb
@@ -71,8 +71,7 @@ class Projects::Settings::LifeCycleStepsController < Projects::SettingsControlle
{
project_id: @project.id,
definition_id: definition.id,
- active:,
- type: definition.step_class
+ active:
}
end,
unique_by: %i[project_id definition_id]
diff --git a/config/initializers/menus.rb b/config/initializers/menus.rb
index bc02214e87b..4faac61a3bd 100644
--- a/config/initializers/menus.rb
+++ b/config/initializers/menus.rb
@@ -643,7 +643,7 @@ Redmine::MenuManager.map :project_menu do |menu|
project_menu_items = {
general: { caption: :label_information_plural },
- life_cycles: {
+ life_cycle_steps: {
caption: :label_project_life_cycle,
action: :index,
if: ->(_) { OpenProject::FeatureDecisions.stages_and_gates_active? }