Skip to content

Commit

Permalink
[#58160] refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
EinLama committed Dec 12, 2024
1 parent f88e5dc commit edb3b91
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
3 changes: 1 addition & 2 deletions app/components/projects/row_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Expand Down
18 changes: 9 additions & 9 deletions app/models/queries/projects/selects/life_cycle_step.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit edb3b91

Please sign in to comment.