From 288bd122e2d4cca3f70058bca8a7862bff9d7166 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 30 Oct 2025 15:50:54 +0100 Subject: [PATCH] Turn anemic partial into a helper method --- app/helpers/webhooks_helper.rb | 8 ++++++++ app/views/cards/_webhooks.html.erb | 4 ---- app/views/collections/show.html.erb | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) delete mode 100644 app/views/cards/_webhooks.html.erb diff --git a/app/helpers/webhooks_helper.rb b/app/helpers/webhooks_helper.rb index 7853a8ac5..c809ac6ef 100644 --- a/app/helpers/webhooks_helper.rb +++ b/app/helpers/webhooks_helper.rb @@ -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 diff --git a/app/views/cards/_webhooks.html.erb b/app/views/cards/_webhooks.html.erb deleted file mode 100644 index 4ed058479..000000000 --- a/app/views/cards/_webhooks.html.erb +++ /dev/null @@ -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" %> - Webhooks -<% end %> diff --git a/app/views/collections/show.html.erb b/app/views/collections/show.html.erb index c89e70976..4a03d7b2c 100644 --- a/app/views/collections/show.html.erb +++ b/app/views/collections/show.html.erb @@ -13,7 +13,7 @@ <%= render "filters/menu" %>
- <%= render "cards/webhooks", collection: @collection if Current.user.admin? %> + <%= link_to_webhooks(@collection) if Current.user.admin? %>