From c9c426964959301b832899f369a4c7841179037e Mon Sep 17 00:00:00 2001 From: Tobias Dillmann Date: Thu, 12 Dec 2024 10:27:48 +0100 Subject: [PATCH] [#58160] refactor --- app/components/projects/row_component.rb | 3 +-- .../projects/selects/life_cycle_step.rb | 18 +++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app/components/projects/row_component.rb b/app/components/projects/row_component.rb index 4bae6784d01c..80d6e4456002 100644 --- a/app/components/projects/row_component.rb +++ b/app/components/projects/row_component.rb @@ -99,10 +99,9 @@ def custom_field_column(column) def life_cycle_step_column(column) return nil unless user_can_view_project? - # FIXME: make this efficient ls = Project::LifeCycleStep .where(active: true) - .find_by(definition_id: column.life_cycle_step.id, project:) + .find_by(definition_id: column.life_cycle.id, project:) return nil if ls.blank? diff --git a/app/models/queries/projects/selects/life_cycle_step.rb b/app/models/queries/projects/selects/life_cycle_step.rb index 7a055a7d30fe..028b9ad72c05 100644 --- a/app/models/queries/projects/selects/life_cycle_step.rb +++ b/app/models/queries/projects/selects/life_cycle_step.rb @@ -44,32 +44,32 @@ def self.all_available end def caption - life_cycle_step.name + life_cycle.name end - def life_cycle_step - return @life_cycle_step if defined?(@life_cycle_step) + def life_cycle + return @life_cycle if defined?(@life_cycle) - @life_cycle_step = Project::LifeCycleStepDefinition - .find_by(id: attribute[KEY, 1]) + @life_cycle = Project::LifeCycleStepDefinition + .find_by(id: attribute[KEY, 1]) end def available? - life_cycle_step.present? + life_cycle.present? end def action_menu_header(button) # Show the proper icon for the definition with the correct color. - icon = case life_cycle_step + icon = case life_cycle when Project::StageDefinition :"git-commit" when Project::GateDefinition :diamond else - raise "Unknown life cycle step: #{life_cycle_step}" + raise "Unknown life cycle definition for: #{life_cycle}" end - classes = helpers.hl_inline_class("life_cycle_step_definition", life_cycle_step) + classes = helpers.hl_inline_class("life_cycle_step_definition", life_cycle) button.with_leading_visual_icon(icon:, classes:) # As all other action menu headers, we will show an action icon and the caption: