Add administrative webhooks (#18510)
* Add administrative webhooks * Fix error when webhook is deleted before delivery worker runs
This commit is contained in:
11
app/views/admin/webhooks/_form.html.haml
Normal file
11
app/views/admin/webhooks/_form.html.haml
Normal file
@ -0,0 +1,11 @@
|
||||
= simple_form_for @webhook, url: @webhook.new_record? ? admin_webhooks_path : admin_webhook_path(@webhook) do |f|
|
||||
= render 'shared/error_messages', object: @webhook
|
||||
|
||||
.fields-group
|
||||
= f.input :url, wrapper: :with_block_label, input_html: { placeholder: 'https://' }
|
||||
|
||||
.fields-group
|
||||
= f.input :events, collection: Webhook::EVENTS, wrapper: :with_block_label, include_blank: false, as: :check_boxes, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li'
|
||||
|
||||
.actions
|
||||
= f.button :button, @webhook.new_record? ? t('admin.webhooks.add_new') : t('generic.save_changes'), type: :submit
|
19
app/views/admin/webhooks/_webhook.html.haml
Normal file
19
app/views/admin/webhooks/_webhook.html.haml
Normal file
@ -0,0 +1,19 @@
|
||||
.applications-list__item
|
||||
= link_to admin_webhook_path(webhook), class: 'announcements-list__item__title' do
|
||||
= fa_icon 'inbox'
|
||||
= webhook.url
|
||||
|
||||
.announcements-list__item__action-bar
|
||||
.announcements-list__item__meta
|
||||
- if webhook.enabled?
|
||||
%span.positive-hint= t('admin.webhooks.enabled')
|
||||
- else
|
||||
%span.negative-hint= t('admin.webhooks.disabled')
|
||||
|
||||
•
|
||||
|
||||
%abbr{ title: webhook.events.join(', ') }= t('admin.webhooks.enabled_events', count: webhook.events.size)
|
||||
|
||||
%div
|
||||
= table_link_to 'pencil', t('admin.webhooks.edit'), edit_admin_webhook_path(webhook) if can?(:update, webhook)
|
||||
= table_link_to 'trash', t('admin.webhooks.delete'), admin_webhook_path(webhook), method: :delete, data: { confirm: t('admin.accounts.are_you_sure') } if can?(:destroy, webhook)
|
4
app/views/admin/webhooks/edit.html.haml
Normal file
4
app/views/admin/webhooks/edit.html.haml
Normal file
@ -0,0 +1,4 @@
|
||||
- content_for :page_title do
|
||||
= t('admin.webhooks.edit')
|
||||
|
||||
= render partial: 'form'
|
18
app/views/admin/webhooks/index.html.haml
Normal file
18
app/views/admin/webhooks/index.html.haml
Normal file
@ -0,0 +1,18 @@
|
||||
- content_for :page_title do
|
||||
= t('admin.webhooks.title')
|
||||
|
||||
- content_for :heading_actions do
|
||||
= link_to t('admin.webhooks.add_new'), new_admin_webhook_path, class: 'button' if can?(:create, :webhook)
|
||||
|
||||
%p= t('admin.webhooks.description_html')
|
||||
|
||||
%hr.spacer/
|
||||
|
||||
- if @webhooks.empty?
|
||||
%div.muted-hint.center-text
|
||||
= t 'admin.webhooks.empty'
|
||||
- else
|
||||
.applications-list
|
||||
= render partial: 'webhook', collection: @webhooks
|
||||
|
||||
= paginate @webhooks
|
4
app/views/admin/webhooks/new.html.haml
Normal file
4
app/views/admin/webhooks/new.html.haml
Normal file
@ -0,0 +1,4 @@
|
||||
- content_for :page_title do
|
||||
= t('admin.webhooks.new')
|
||||
|
||||
= render partial: 'form'
|
34
app/views/admin/webhooks/show.html.haml
Normal file
34
app/views/admin/webhooks/show.html.haml
Normal file
@ -0,0 +1,34 @@
|
||||
- content_for :page_title do
|
||||
= t('admin.webhooks.title')
|
||||
|
||||
- content_for :heading do
|
||||
%h2
|
||||
%small
|
||||
= fa_icon 'inbox'
|
||||
= t('admin.webhooks.webhook')
|
||||
= @webhook.url
|
||||
|
||||
- content_for :heading_actions do
|
||||
= link_to t('admin.webhooks.edit'), edit_admin_webhook_path, class: 'button' if can?(:update, @webhook)
|
||||
|
||||
.table-wrapper
|
||||
%table.table.horizontal-table
|
||||
%tbody
|
||||
%tr
|
||||
%th= t('admin.webhooks.status')
|
||||
%td
|
||||
- if @webhook.enabled?
|
||||
%span.positive-hint= t('admin.webhooks.enabled')
|
||||
= table_link_to 'power-off', t('admin.webhooks.disable'), disable_admin_webhook_path(@webhook), method: :post if can?(:disable, @webhook)
|
||||
- else
|
||||
%span.negative-hint= t('admin.webhooks.disabled')
|
||||
= table_link_to 'power-off', t('admin.webhooks.enable'), enable_admin_webhook_path(@webhook), method: :post if can?(:enable, @webhook)
|
||||
%tr
|
||||
%th= t('admin.webhooks.events')
|
||||
%td
|
||||
%abbr{ title: @webhook.events.join(', ') }= t('admin.webhooks.enabled_events', count: @webhook.events.size)
|
||||
%tr
|
||||
%th= t('admin.webhooks.secret')
|
||||
%td
|
||||
%samp= @webhook.secret
|
||||
= table_link_to 'refresh', t('admin.webhooks.rotate_secret'), rotate_admin_webhook_secret_path(@webhook), method: :post if can?(:rotate_secret, @webhook)
|
Reference in New Issue
Block a user