Skip to content

Commit

Permalink
[#59925] refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
EinLama committed Jan 22, 2025
1 parent 0ff1060 commit cd43207
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lib/open_project/object_linking.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,7 @@ def link_to_user(user, options = {})
only_path: options.delete(:only_path) { true })
options[:title] ||= I18n.t(:label_user_named, name:)

if options.delete(:hover_card) { true }
options[:data] ||= {}
options[:data][:hover_card_url] = hover_card_user_path(user)

options[:class] = [options[:class], "op-hover-card--preview-trigger"].compact.join(" ")
end
add_hover_card_options(user, options, clazz_key: :class)

link_to(name, href, options)
else
Expand Down Expand Up @@ -150,9 +145,10 @@ def primer_link_to_user(user, options = {})

private

def add_hover_card_options(user, options)
# TODO: doc comment
def add_hover_card_options(user, options, clazz_key: :classes)
if options.delete(:hover_card) { true }
options[:classes] = [options[:classes], "op-hover-card--preview-trigger"].compact.join(" ")
options[clazz_key] = [options[clazz_key], "op-hover-card--preview-trigger"].compact.join(" ")
options[:data] ||= {}
options[:data][:hover_card_url] = hover_card_user_path(user)
end
Expand Down

0 comments on commit cd43207

Please sign in to comment.