Turn anemic partial into a helper method

This commit is contained in:
David Heinemeier Hansson
2025-10-30 15:50:54 +01:00
parent 82df8fd90d
commit 288bd122e2
3 changed files with 9 additions and 5 deletions
+8
View File
@@ -21,4 +21,12 @@ module WebhooksHelper
def webhook_action_label(action)
ACTION_LABELS[action] || action.to_s.humanize
end
def link_to_webhooks(collection, &)
link_to collection_webhooks_path(collection_id: collection),
class: [ "btn", { "btn--reversed": collection.webhooks.any? } ],
data: { controller: "tooltip" } do
icon_tag("world") + tag.span("Webhooks", class: "for-screen-reader")
end
end
end
-4
View File
@@ -1,4 +0,0 @@
<%= link_to collection_webhooks_path(collection_id: collection), class: ["btn", {"btn--reversed": collection.webhooks.any?}], data: { controller: "tooltip" } do %>
<%= icon_tag "world" %>
<span class="for-screen-reader">Webhooks</span>
<% end %>
+1 -1
View File
@@ -13,7 +13,7 @@
<%= render "filters/menu" %>
<div class="header__actions header__actions--start">
<%= render "cards/webhooks", collection: @collection if Current.user.admin? %>
<%= link_to_webhooks(@collection) if Current.user.admin? %>
</div>
<h1 class="header__title divider divider--fade full-width">