Merge pull request #1161 from basecamp/custom-labels-for-webhook-actions
Add custom labels for Webhooks
This commit is contained in:
@@ -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
|
||||
@@ -1,16 +1,16 @@
|
||||
<ul class="flex flex-column align-start gap-half margin-none unpad">
|
||||
<%= form.collection_check_boxes \
|
||||
:subscribed_actions,
|
||||
Webhook::PERMITTED_ACTIONS,
|
||||
:itself,
|
||||
:humanize do |item| %>
|
||||
<li class="list-style-none margin-none flex align-center gap">
|
||||
<label class="switch toggler__visible-when-off flex-item-no-shrink txt-x-small">
|
||||
<%= item.check_box(class: "switch__input") %>
|
||||
<span class="switch__btn round"></span>
|
||||
<span class="for-screen-reader"><%= item.text %></span>
|
||||
</label>
|
||||
<span><%= item.text %></span>
|
||||
</li>
|
||||
webhook_action_options,
|
||||
:first,
|
||||
:last do |item| %>
|
||||
<li class="list-style-none margin-none flex align-center gap">
|
||||
<label class="switch toggler__visible-when-off flex-item-no-shrink txt-x-small">
|
||||
<%= item.check_box(class: "switch__input") %>
|
||||
<span class="switch__btn round"></span>
|
||||
<span class="for-screen-reader"><%= item.text %></span>
|
||||
</label>
|
||||
<span><%= item.text %></span>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
<% else %>
|
||||
<ul class="margin-none unpad-block">
|
||||
<% @webhook.subscribed_actions.each do |action| %>
|
||||
<li><%= action.humanize %></li>
|
||||
<li><%= webhook_action_label(action) %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user