Files
fizzy/app/helpers/webhooks_helper.rb
T
2025-11-05 13:31:54 +01:00

33 lines
1.1 KiB
Ruby

module WebhooksHelper
ACTION_LABELS = {
card_published: "Card added",
card_title_changed: "Card title changed",
card_board_changed: "Card board changed",
comment_created: "Comment added",
card_assigned: "Card assigned",
card_unassigned: "Card unassigned",
card_triaged: "Card column changed",
card_closed: "Card moved to “Done”",
card_reopened: "Card reopened",
card_postponed: "Card moved to “Not Now”",
card_auto_postponed: "Card auto-closed as “Not Now”",
card_sent_back_to_triage: "Card moved back to “Maybe?”"
}.with_indifferent_access.freeze
def webhook_action_options(actions = Webhook::PERMITTED_ACTIONS)
ACTION_LABELS.select { |key, _| actions.include?(key.to_s) }
end
def webhook_action_label(action)
ACTION_LABELS[action] || action.to_s.humanize
end
def link_to_webhooks(board, &)
link_to board_webhooks_path(board_id: board),
class: [ "btn", { "btn--reversed": board.webhooks.any? } ],
data: { controller: "tooltip" } do
icon_tag("world") + tag.span("Webhooks", class: "for-screen-reader")
end
end
end