From 24ac7cd00dd3bf31bc4e2c79a085ea56ddfaf3b7 Mon Sep 17 00:00:00 2001 From: "Stanko K.R." Date: Tue, 23 Sep 2025 17:54:50 +0200 Subject: [PATCH] Add custom labels for Webhooks --- app/helpers/webhooks_helper.rb | 27 +++++++++++++++++++++++ app/views/webhooks/form/_actions.html.erb | 22 +++++++++--------- app/views/webhooks/show.html.erb | 2 +- 3 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 app/helpers/webhooks_helper.rb diff --git a/app/helpers/webhooks_helper.rb b/app/helpers/webhooks_helper.rb new file mode 100644 index 000000000..7fe91d8c0 --- /dev/null +++ b/app/helpers/webhooks_helper.rb @@ -0,0 +1,27 @@ +module WebhooksHelper + ACTION_LABELS = { + card_assigned: "Card assigned", + card_closed: "Card closed", + card_collection_changed: "Card collection changed", + card_due_date_added: "Card due date added", + card_due_date_changed: "Card due date changed", + card_due_date_removed: "Card due date removed", + card_published: "Card published", + card_reopened: "Card reopened", + card_staged: "Card staged", + card_title_changed: "Card title changed", + card_unassigned: "Card unassigned", + card_unstaged: "Card unstaged", + comment_created: "Comment created" + }.with_indifferent_access.freeze + + def webhook_action_options(actions = Webhook::PERMITTED_ACTIONS) + actions.each_with_object({}) do |action, hash| + hash[action.to_s] = webhook_action_label(action) + end + end + + def webhook_action_label(action) + ACTION_LABELS[action] || action.to_s.humanize + end +end diff --git a/app/views/webhooks/form/_actions.html.erb b/app/views/webhooks/form/_actions.html.erb index cd75e2dd6..a887fa644 100644 --- a/app/views/webhooks/form/_actions.html.erb +++ b/app/views/webhooks/form/_actions.html.erb @@ -1,16 +1,16 @@ diff --git a/app/views/webhooks/show.html.erb b/app/views/webhooks/show.html.erb index f4edfa392..07e5f849f 100644 --- a/app/views/webhooks/show.html.erb +++ b/app/views/webhooks/show.html.erb @@ -47,7 +47,7 @@ <% else %> <% end %>