Skip to content

Commit

Permalink
Extract logic to combine source and target and reuse it
Browse files Browse the repository at this point in the history
  • Loading branch information
ncounter committed Jan 27, 2025
1 parent 63c91d2 commit 107b2b8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,18 @@ def description
source_project_hash = { project: action.source_project, package: action.source_package, trim_to: nil }
target_project_hash = { project: action.target_project, package: action.target_package, trim_to: nil }

if text_only
source_and_target_component = BsRequestActionSourceAndTargetComponent.new(action.bs_request)
source_and_target_component = BsRequestActionSourceAndTargetComponent.new(action.bs_request)

if text_only
source_container = source_and_target_component.source
target_container = source_and_target_component.target
source_and_target_container = source_and_target_component.call
else
source_container = project_or_package_link(source_project_hash)
target_container = project_or_package_link(target_project_hash)
source_and_target_container = tag.span(source_container)
.concat(tag.i(nil, class: 'fas fa-long-arrow-alt-right text-info mx-2'))
.concat(tag.span(target_container))
end

source_and_target_container = source_and_target_component.combine(source_container, target_container)

description = case action.type
when 'submit'
'Submit %{source_and_target_container}' % { source_and_target_container: source_and_target_container }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@ def initialize(bs_request)
end

def call
capture do
if source.present?
concat(tag.span(source))
concat(tag.i(nil, class: 'fas fa-long-arrow-alt-right text-info mx-2'))
end
concat(tag.span(target))
end
combine(source, target)
end

def source
Expand All @@ -31,4 +25,14 @@ def target

[bs_request_action.target_project, bs_request_action.target_package].compact.join(' / ')
end

def combine(source, target)
capture do
if source.present?
concat(tag.span(source))
concat(tag.i(nil, class: 'fas fa-long-arrow-alt-right text-info mx-2'))
end
concat(tag.span(target))
end
end
end

0 comments on commit 107b2b8

Please sign in to comment.