Cleanup single reaction template (#15207)

* Cleanup single reaction template

extract the title: link_to() target conditional outside the call to
translate

add missing closing paren for t()

remove comment (probably could stay if it's useful - explains why we
have a conditional at all)

* Fix indentation and ensure link has correct class

* Fix indentation and ensure links have a path

* Remove class from translate template

This was left from shuffling arguments to function calls
This commit is contained in:
Daniel Uber 2021-10-26 17:35:12 -04:00 committed by GitHub
parent 2395693809
commit 10832a426f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,20 +4,26 @@
<% end %>
<div class="notification__content">
<% category = notification.json_data["reaction"]["category"] %>
<% if notification.json_data["reaction"]["reactable"]["title"].blank? %>
<% title_link = link_to(
t("views.notifications.reacted.your.#{notification.json_data['reaction']['reactable_type'].downcase}"),
notification.json_data["reaction"]["reactable"]["path"],
class: "crayons-link fw-bold",
) %>
<% else %>
<% title_link = link_to(
sanitize(notification.json_data["reaction"]["reactable"]["title"]),
notification.json_data["reaction"]["reactable"]["path"],
class: "crayons-link fw-bold",
) %>
<% end %>
<%= t("views.notifications.reacted.verb_html",
count: 1,
start: "",
actors: link_to(notification.json_data["user"]["name"], notification.json_data["user"]["path"], class: "crayons-link fw-bold"),
# title is blank when it's a comment with only an image, for example
title: link_to(
if notification.json_data["reaction"]["reactable"]["title"].blank?
t("views.notifications.reacted.your.#{notification.json_data["reaction"]["reactable_type"].downcase}")
else
sanitize(notification.json_data["reaction"]["reactable"]["title"]), notification.json_data["reaction"]["reactable"]["path"]
end,
class: "crayons-link fw-bold",
),
title: title_link,
end: "",
reactions: tag.span(inline_svg_tag(reaction_image(category), class: "crayons-icon reaction-image mx-1 reaction-icon--#{category}", title: t("views.reactions.category.#{category.to_s}"))) %>
reactions: tag.span(inline_svg_tag(reaction_image(category), class: "crayons-icon reaction-image mx-1 reaction-icon--#{category}", title: t("views.reactions.category.#{category}")))) %>
</div>
</div>