bullet_train-outgoing_webhooks 1.0.0 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +11 -26
  4. data/Rakefile +5 -11
  5. data/app/assets/config/bullet_train_outgoing_webhooks_manifest.js +0 -0
  6. data/app/controllers/account/webhooks/outgoing/deliveries_controller.rb +79 -0
  7. data/app/controllers/account/webhooks/outgoing/delivery_attempts_controller.rb +80 -0
  8. data/app/controllers/account/webhooks/outgoing/endpoints_controller.rb +79 -0
  9. data/app/controllers/api/v1/webhooks/outgoing/deliveries_endpoint.rb +63 -0
  10. data/app/controllers/api/v1/webhooks/outgoing/delivery_attempts_endpoint.rb +65 -0
  11. data/app/controllers/api/v1/webhooks/outgoing/endpoints_endpoint.rb +119 -0
  12. data/app/jobs/webhooks/outgoing/delivery_job.rb +7 -0
  13. data/{lib → app}/models/concerns/webhooks/outgoing/issuing_model.rb +6 -14
  14. data/{lib → app}/models/concerns/webhooks/outgoing/team_support.rb +0 -0
  15. data/{lib → app}/models/webhooks/outgoing/delivery.rb +18 -1
  16. data/{lib → app}/models/webhooks/outgoing/delivery_attempt.rb +17 -1
  17. data/{lib → app}/models/webhooks/outgoing/endpoint.rb +15 -5
  18. data/{lib → app}/models/webhooks/outgoing/event.rb +3 -3
  19. data/{lib → app}/models/webhooks/outgoing/event_type.rb +4 -6
  20. data/{lib → app}/models/webhooks/outgoing.rb +0 -3
  21. data/app/models/webhooks.rb +5 -0
  22. data/app/serializers/api/v1/webhooks/outgoing/delivery_attempt_serializer.rb +16 -0
  23. data/app/serializers/api/v1/webhooks/outgoing/delivery_serializer.rb +14 -0
  24. data/app/serializers/api/v1/webhooks/outgoing/endpoint_serializer.rb +14 -0
  25. data/app/views/account/webhooks/outgoing/deliveries/_breadcrumbs.html.erb +8 -0
  26. data/app/views/account/webhooks/outgoing/deliveries/_delivery.json.jbuilder +10 -0
  27. data/app/views/account/webhooks/outgoing/deliveries/_form.html.erb +21 -0
  28. data/app/views/account/webhooks/outgoing/deliveries/_index.html.erb +73 -0
  29. data/app/views/account/webhooks/outgoing/deliveries/_menu_item.html.erb +10 -0
  30. data/app/views/account/webhooks/outgoing/deliveries/_success_indicator.html.erb +7 -0
  31. data/app/views/account/webhooks/outgoing/deliveries/edit.html.erb +12 -0
  32. data/app/views/account/webhooks/outgoing/deliveries/index.html.erb +6 -0
  33. data/app/views/account/webhooks/outgoing/deliveries/index.json.jbuilder +1 -0
  34. data/app/views/account/webhooks/outgoing/deliveries/new.html.erb +12 -0
  35. data/app/views/account/webhooks/outgoing/deliveries/show.html.erb +37 -0
  36. data/app/views/account/webhooks/outgoing/deliveries/show.json.jbuilder +1 -0
  37. data/app/views/account/webhooks/outgoing/delivery_attempts/_breadcrumbs.html.erb +8 -0
  38. data/app/views/account/webhooks/outgoing/delivery_attempts/_delivery_attempt.json.jbuilder +12 -0
  39. data/app/views/account/webhooks/outgoing/delivery_attempts/_form.html.erb +22 -0
  40. data/app/views/account/webhooks/outgoing/delivery_attempts/_index.html.erb +69 -0
  41. data/app/views/account/webhooks/outgoing/delivery_attempts/_menu_item.html.erb +10 -0
  42. data/app/views/account/webhooks/outgoing/delivery_attempts/_success_indicator.html.erb +7 -0
  43. data/app/views/account/webhooks/outgoing/delivery_attempts/edit.html.erb +12 -0
  44. data/app/views/account/webhooks/outgoing/delivery_attempts/index.html.erb +6 -0
  45. data/app/views/account/webhooks/outgoing/delivery_attempts/index.json.jbuilder +1 -0
  46. data/app/views/account/webhooks/outgoing/delivery_attempts/new.html.erb +12 -0
  47. data/app/views/account/webhooks/outgoing/delivery_attempts/show.html.erb +32 -0
  48. data/app/views/account/webhooks/outgoing/delivery_attempts/show.json.jbuilder +1 -0
  49. data/app/views/account/webhooks/outgoing/endpoints/_breadcrumbs.html.erb +8 -0
  50. data/app/views/account/webhooks/outgoing/endpoints/_endpoint.json.jbuilder +10 -0
  51. data/app/views/account/webhooks/outgoing/endpoints/_form.html.erb +21 -0
  52. data/app/views/account/webhooks/outgoing/endpoints/_index.html.erb +62 -0
  53. data/app/views/account/webhooks/outgoing/endpoints/_menu_item.html.erb +10 -0
  54. data/app/views/account/webhooks/outgoing/endpoints/edit.html.erb +12 -0
  55. data/app/views/account/webhooks/outgoing/endpoints/index.html.erb +6 -0
  56. data/app/views/account/webhooks/outgoing/endpoints/index.json.jbuilder +1 -0
  57. data/app/views/account/webhooks/outgoing/endpoints/new.html.erb +12 -0
  58. data/app/views/account/webhooks/outgoing/endpoints/show.html.erb +42 -0
  59. data/app/views/account/webhooks/outgoing/endpoints/show.json.jbuilder +1 -0
  60. data/config/locales/en/webhooks/outgoing/deliveries.en.yml +112 -0
  61. data/config/locales/en/webhooks/outgoing/delivery_attempts.en.yml +122 -0
  62. data/config/locales/en/webhooks/outgoing/endpoints.en.yml +108 -0
  63. data/config/locales/en/webhooks/outgoing/events.en.yml +10 -0
  64. data/config/routes.rb +18 -0
  65. data/db/migrate/20180420013127_create_webhooks_outgoing_endpoints.rb +10 -0
  66. data/db/migrate/20180420013505_create_webhooks_outgoing_endpoint_event_types.rb +10 -0
  67. data/db/migrate/20180420013852_create_webhooks_outgoing_event_types.rb +9 -0
  68. data/db/migrate/20180420014623_create_webhooks_outgoing_events.rb +12 -0
  69. data/db/migrate/20180420021016_create_webhooks_outgoing_deliveries.rb +11 -0
  70. data/db/migrate/20180420022027_add_team_to_webhooks_outgoing_events.rb +5 -0
  71. data/db/migrate/20180420165345_create_webhooks_outgoing_delivery_attempts.rb +11 -0
  72. data/db/migrate/20180420172112_add_error_message_to_webhooks_outgoing_delivery_attempt.rb +6 -0
  73. data/db/migrate/20181012234232_add_name_to_webhooks_outgoing_endpoints.rb +5 -0
  74. data/db/migrate/20181013030208_add_delivered_at_to_webhooks_outgoing_deliveries.rb +5 -0
  75. data/db/migrate/20181013165056_add_uuid_to_webhooks_outgoing_events.rb +5 -0
  76. data/db/migrate/20181013174539_add_payload_to_webhooks_outgoing_events.rb +5 -0
  77. data/db/migrate/20181013192951_add_attempt_number_to_webhooks_outgoing_delivery_attempts.rb +5 -0
  78. data/db/migrate/20210805060451_change_body_to_data_on_webhooks_outgoing_events.rb +5 -0
  79. data/db/migrate/20211126230846_add_event_type_ids_to_webhooks_outgoing_endpoints.rb +5 -0
  80. data/db/migrate/20211126230847_migrate_event_type_ids_on_webhooks_outgoing_endpoints.rb +8 -0
  81. data/db/migrate/20211127013539_remove_event_type_from_webhooks_outgoing_events.rb +5 -0
  82. data/db/migrate/20211127013800_add_new_event_type_id_to_webhooks_outgoing_events.rb +5 -0
  83. data/db/migrate/20211127014001_migrate_event_types_on_webhooks_outgoing_events.rb +10 -0
  84. data/db/migrate/20211127015712_drop_webhooks_outgoing_endpoint_event_types.rb +9 -0
  85. data/db/migrate/20211127015713_drop_webhooks_outgoing_event_types.rb +9 -0
  86. data/lib/bullet_train/outgoing_webhooks/engine.rb +13 -0
  87. data/lib/bullet_train/outgoing_webhooks/version.rb +1 -3
  88. data/lib/bullet_train/outgoing_webhooks.rb +2 -17
  89. data/lib/tasks/bullet_train/outgoing_webhooks_tasks.rake +4 -0
  90. metadata +97 -60
  91. data/.standard.yml +0 -2
  92. data/CHANGELOG.md +0 -5
  93. data/CODE_OF_CONDUCT.md +0 -84
  94. data/Gemfile +0 -12
  95. data/Gemfile.lock +0 -193
  96. data/LICENSE.txt +0 -21
  97. data/bin/console +0 -15
  98. data/bin/setup +0 -8
  99. data/lib/models/concerns/webhooks/outgoing/has_uuid.rb +0 -21
  100. data/lib/models/webhooks.rb +0 -2
  101. data/sig/bullet_train/outgoing_webhooks.rbs +0 -6
@@ -1,4 +1,6 @@
1
- class Webhooks::Outgoing::Delivery < ActiveRecord::Base
1
+ class Webhooks::Outgoing::Delivery < ApplicationRecord
2
+ # 🚅 add concerns above.
3
+
2
4
  belongs_to :endpoint, class_name: "Webhooks::Outgoing::Endpoint"
3
5
  belongs_to :event, class_name: "Webhooks::Outgoing::Event"
4
6
  has_one :team, through: :endpoint
@@ -11,7 +13,20 @@ class Webhooks::Outgoing::Delivery < ActiveRecord::Base
11
13
  5 => 1.hour,
12
14
  }
13
15
 
16
+ # 🚅 add belongs_to associations above.
17
+
14
18
  has_many :delivery_attempts, class_name: "Webhooks::Outgoing::DeliveryAttempt", dependent: :destroy, foreign_key: :delivery_id
19
+ # 🚅 add has_many associations above.
20
+
21
+ # 🚅 add has_one associations above.
22
+
23
+ # 🚅 add scopes above.
24
+
25
+ # 🚅 add validations above.
26
+
27
+ # 🚅 add callbacks above.
28
+
29
+ # 🚅 add delegations above.
15
30
 
16
31
  def label_string
17
32
  event.short_uuid
@@ -59,4 +74,6 @@ class Webhooks::Outgoing::Delivery < ActiveRecord::Base
59
74
  def max_attempts
60
75
  ATTEMPT_SCHEDULE.keys.max
61
76
  end
77
+
78
+ # 🚅 add methods above.
62
79
  end
@@ -1,4 +1,6 @@
1
- class Webhooks::Outgoing::DeliveryAttempt < ActiveRecord::Base
1
+ class Webhooks::Outgoing::DeliveryAttempt < ApplicationRecord
2
+ # 🚅 add concerns above.
3
+
2
4
  belongs_to :delivery
3
5
  has_one :team, through: :delivery
4
6
  scope :successful, -> { where(response_code: 200) }
@@ -44,6 +46,20 @@ class Webhooks::Outgoing::DeliveryAttempt < ActiveRecord::Base
44
46
  def label_string
45
47
  "#{attempt_number.ordinalize} Attempt"
46
48
  end
49
+ # 🚅 add belongs_to associations above.
50
+
51
+ # 🚅 add has_many associations above.
52
+
53
+ # 🚅 add has_one associations above.
54
+
55
+ # 🚅 add scopes above.
47
56
 
48
57
  validates :response_code, presence: true
58
+ # 🚅 add validations above.
59
+
60
+ # 🚅 add callbacks above.
61
+
62
+ # 🚅 add delegations above.
63
+
64
+ # 🚅 add methods above.
49
65
  end
@@ -1,12 +1,24 @@
1
- class Webhooks::Outgoing::Endpoint < ActiveRecord::Base
2
- belongs_to :team, class_name: Webhooks::Outgoing.team_model
1
+ class Webhooks::Outgoing::Endpoint < ApplicationRecord
2
+ # 🚅 add concerns above.
3
+
4
+ belongs_to :team
5
+ # 🚅 add belongs_to associations above.
3
6
 
4
7
  has_many :deliveries, class_name: "Webhooks::Outgoing::Delivery", dependent: :destroy, foreign_key: :endpoint_id
5
8
  has_many :events, -> { distinct }, through: :deliveries
9
+ # 🚅 add has_many associations above.
10
+
11
+ # 🚅 add has_one associations above.
6
12
 
7
13
  scope :listening_for_event_type_id, ->(event_type_id) { where("event_type_ids @> ? OR event_type_ids = '[]'::jsonb", "\"#{event_type_id}\"") }
14
+ # 🚅 add scopes above.
8
15
 
9
16
  validates :name, presence: true
17
+ # 🚅 add validations above.
18
+
19
+ # 🚅 add callbacks above.
20
+
21
+ # 🚅 add delegations above.
10
22
 
11
23
  def valid_event_types
12
24
  Webhooks::Outgoing::EventType.all
@@ -16,7 +28,5 @@ class Webhooks::Outgoing::Endpoint < ActiveRecord::Base
16
28
  event_type_ids.map { |id| Webhooks::Outgoing::EventType.find(id) }
17
29
  end
18
30
 
19
- def label_string
20
- name
21
- end
31
+ # 🚅 add methods above.
22
32
  end
@@ -1,6 +1,6 @@
1
- class Webhooks::Outgoing::Event < ActiveRecord::Base
2
- include Webhooks::Outgoing::HasUuid
3
- belongs_to :team, class_name: Webhooks::Outgoing.team_model
1
+ class Webhooks::Outgoing::Event < ApplicationRecord
2
+ include HasUuid
3
+ belongs_to :team
4
4
  belongs_to :event_type, class_name: "Webhooks::Outgoing::EventType"
5
5
  belongs_to :subject, polymorphic: true
6
6
  has_many :deliveries, dependent: :destroy
@@ -1,15 +1,13 @@
1
- class Webhooks::Outgoing::EventType < ActiveHash::Base
2
- include ActiveHash::Associations
3
-
1
+ class Webhooks::Outgoing::EventType < ApplicationHash
4
2
  self.data = YAML.load_file("config/models/webhooks/outgoing/event_types.yml").map do |topic, events|
5
3
  events.map { |event| event == "crud" ? ["created", "updated", "deleted"] : event }.flatten.map { |event| {id: "#{topic}.#{event}"} }
6
4
  end.flatten
7
5
 
8
- def name
9
- id
6
+ def label_string
7
+ name
10
8
  end
11
9
 
12
- def label_string
10
+ def name
13
11
  id
14
12
  end
15
13
  end
@@ -2,7 +2,4 @@ module Webhooks::Outgoing
2
2
  def self.table_name_prefix
3
3
  "webhooks_outgoing_"
4
4
  end
5
-
6
- mattr_accessor :team_model
7
- @@team_model = "Team"
8
5
  end
@@ -0,0 +1,5 @@
1
+ module Webhooks
2
+ def self.table_name_prefix
3
+ "webhooks_"
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ class Api::V1::Webhooks::Outgoing::DeliveryAttemptSerializer < Api::V1::ApplicationSerializer
2
+ set_type "webhooks/outgoing/delivery_attempt"
3
+
4
+ attributes :id,
5
+ :delivery_id,
6
+ :response_code,
7
+ :response_body,
8
+ :response_message,
9
+ :error_message,
10
+ :attempt_number,
11
+ # 🚅 super scaffolding will insert new fields above this line.
12
+ :created_at,
13
+ :updated_at
14
+
15
+ belongs_to :delivery, serializer: Api::V1::Webhooks::Outgoing::DeliverySerializer
16
+ end
@@ -0,0 +1,14 @@
1
+ class Api::V1::Webhooks::Outgoing::DeliverySerializer < Api::V1::ApplicationSerializer
2
+ set_type "webhooks/outgoing/delivery"
3
+
4
+ attributes :id,
5
+ :endpoint_id,
6
+ :event_id,
7
+ :endpoint_url,
8
+ :delivered_at,
9
+ # 🚅 super scaffolding will insert new fields above this line.
10
+ :created_at,
11
+ :updated_at
12
+
13
+ belongs_to :endpoint, serializer: Api::V1::Webhooks::Outgoing::EndpointSerializer
14
+ end
@@ -0,0 +1,14 @@
1
+ class Api::V1::Webhooks::Outgoing::EndpointSerializer < Api::V1::ApplicationSerializer
2
+ set_type "webhooks/outgoing/endpoint"
3
+
4
+ attributes :id,
5
+ :team_id,
6
+ :name,
7
+ :url,
8
+ :event_type_ids,
9
+ # 🚅 super scaffolding will insert new fields above this line.
10
+ :created_at,
11
+ :updated_at
12
+
13
+ belongs_to :team, serializer: Api::V1::TeamSerializer
14
+ end
@@ -0,0 +1,8 @@
1
+ <% delivery ||= @delivery %>
2
+ <% endpoint ||= @endpoint || delivery&.endpoint %>
3
+ <%= render 'account/webhooks/outgoing/endpoints/breadcrumbs', endpoint: endpoint %>
4
+ <%= render 'account/shared/breadcrumb', label: t('.label'), url: [:account, endpoint, :deliveries] %>
5
+ <% if delivery&.persisted? %>
6
+ <%= render 'account/shared/breadcrumb', label: delivery.label_string, url: [:account, delivery] %>
7
+ <% end %>
8
+ <%= render 'account/shared/breadcrumbs/actions', only_for: 'webhooks/outgoing/deliveries' %>
@@ -0,0 +1,10 @@
1
+ json.extract! delivery,
2
+ :id,
3
+ :endpoint_id,
4
+ :event_id,
5
+ :endpoint_url,
6
+ :delivered_at,
7
+ # 🚅 super scaffolding will insert new fields above this line.
8
+ :created_at,
9
+ :updated_at
10
+ json.url account_webhooks_outgoing_delivery_url(delivery, format: :json)
@@ -0,0 +1,21 @@
1
+ <%= form_with model: delivery, url: (delivery.persisted? ? [:account, delivery] : [:account, @endpoint, :deliveries]), local: true, class: 'form' do |form| %>
2
+ <%= render 'account/shared/forms/errors', form: form %>
3
+
4
+ <% with_field_settings form: form do %>
5
+ <%= render 'shared/fields/super_select', method: :event_id, options: {autofocus: true, include_blank: t('.fields.event_id.placeholder')},
6
+ choices: @delivery.valid_events.map { |event| [event.label_string, event.id] } %>
7
+ <%= render 'shared/fields/text_field', method: :endpoint_url %>
8
+ <%= render 'shared/fields/date_and_time_field', method: :delivered_at %>
9
+ <%# 🚅 super scaffolding will insert new fields above this line. %>
10
+ <% end %>
11
+
12
+ <div class="buttons">
13
+ <%= form.submit (form.object.persisted? ? t('.buttons.update') : t('.buttons.create')), class: "button" %>
14
+ <% if form.object.persisted? %>
15
+ <%= link_to t('global.buttons.cancel'), [:account, delivery], class: "button-secondary" %>
16
+ <% else %>
17
+ <%= link_to t('global.buttons.cancel'), [:account, @endpoint, :deliveries], class: "button-secondary" %>
18
+ <% end %>
19
+ </div>
20
+
21
+ <% end %>
@@ -0,0 +1,73 @@
1
+ <% endpoint = @endpoint || @endpoint %>
2
+ <% context ||= endpoint %>
3
+ <% collection ||= :deliveries %>
4
+ <% hide_actions ||= false %>
5
+ <% hide_back ||= false %>
6
+
7
+ <%= render 'account/shared/box' do |p| %>
8
+ <% p.content_for :title, t(".contexts.#{context.class.name.underscore}.header") %>
9
+ <% p.content_for :description do %>
10
+ <%= t(".contexts.#{context.class.name.underscore}.description") %>
11
+ <% end %>
12
+
13
+ <% p.content_for :table do %>
14
+ <% if deliveries.any? %>
15
+ <table class="table">
16
+ <thead>
17
+ <tr>
18
+ <th><%= t('webhooks/outgoing/events.fields.short_uuid.heading') %></th>
19
+ <th><%= t('webhooks/outgoing/events.fields.event_type_name.heading') %></th>
20
+ <th><%= t('.fields.endpoint_url.heading') %></th>
21
+ <th class="text-center"><%= t('.fields.delivered_at.heading') %></th>
22
+ <%# 🚅 super scaffolding will insert new field headers above this line. %>
23
+ <th><%= t('.fields.created_at.heading') %></th>
24
+ <th class="text-right"></th>
25
+ </tr>
26
+ </thead>
27
+ <tbody>
28
+ <% deliveries.each do |delivery| %>
29
+ <% with_attribute_settings object: delivery do %>
30
+ <tr data-id="<%= delivery.id %>">
31
+ <% with_attribute_settings object: delivery.event do %>
32
+ <td><%= render 'shared/attributes/code', attribute: :short_uuid, url: [:account, delivery] %></td>
33
+ <td><%= render 'shared/attributes/code', attribute: :event_type_name %></td>
34
+ <% end %>
35
+ <td><%= render 'shared/attributes/code', attribute: :endpoint_url %></td>
36
+ <td class="text-center"><%= render 'shared/attributes/attempt', attribute: :status, success_method: :delivered?, attempting_method: :still_attempting?, failure_method: :failed? %></td>
37
+ <%# 🚅 super scaffolding will insert new fields above this line. %>
38
+ <td><%= render 'shared/attributes/date_and_time', attribute: :created_at %></td>
39
+ <td class="buttons">
40
+ <% unless hide_actions %>
41
+ <% if can? :show, delivery %>
42
+ <%= link_to t('.buttons.shorthand.show'), [:account, delivery], class: 'button-secondary button-smaller' %>
43
+ <% end %>
44
+ <% if can? :edit, delivery %>
45
+ <%= link_to t('.buttons.shorthand.edit'), [:edit, :account, delivery], class: 'button-secondary button-smaller' %>
46
+ <% end %>
47
+ <% if can? :destroy, delivery %>
48
+ <%= button_to t('.buttons.shorthand.destroy'), [:account, delivery], method: :delete, data: { confirm: t('.buttons.confirmations.destroy', model_locales(delivery)) }, class: 'button-secondary button-smaller' %>
49
+ <% end %>
50
+ <% end %>
51
+ </td>
52
+ </tr>
53
+ <% end %>
54
+ <% end %>
55
+ </tbody>
56
+ </table>
57
+ <% end %>
58
+ <% end %>
59
+
60
+ <% p.content_for :actions do %>
61
+ <% unless hide_actions %>
62
+ <% if context == endpoint %>
63
+ <% if can? :create, Webhooks::Outgoing::Delivery.new(endpoint: endpoint) %>
64
+ <%= link_to t('.buttons.new'), [:new, :account, endpoint, :delivery], class: "#{first_button_primary(:delivery)} new" %>
65
+ <% end %>
66
+ <% end %>
67
+
68
+ <% unless hide_back %>
69
+ <%= link_to t('global.buttons.back'), [:account, context], class: "#{first_button_primary(:delivery)} back" %>
70
+ <% end %>
71
+ <% end %>
72
+ <% end %>
73
+ <% end %>
@@ -0,0 +1,10 @@
1
+ <% if can? :read, Webhooks::Outgoing::Delivery.new(team: current_team) %>
2
+ <%= render 'account/shared/menu/item', {
3
+ url: main_app.polymorphic_path([:account, current_team, :webhooks_outgoing_deliveries]),
4
+ label: t('webhooks/outgoing/deliveries.navigation.label'),
5
+ } do |p| %>
6
+ <% p.content_for :icon do %>
7
+ <i class="<%= t('webhooks/outgoing/deliveries.navigation.icon') %>"></i>
8
+ <% end %>
9
+ <% end %>
10
+ <% end %>
@@ -0,0 +1,7 @@
1
+ <% if delivery.delivered? %>
2
+ <div class="square-icon text-success"><i class="ti-check"></i></div>
3
+ <% elsif delivery.still_attempting? %>
4
+ <div class="square-icon"><i class="ti-reload rotating"></i></div>
5
+ <% else %>
6
+ <div class="square-icon text-danger"><i class="ti-close"></i></div>
7
+ <% end %>
@@ -0,0 +1,12 @@
1
+ <%= render 'account/shared/page' do |p| %>
2
+ <% p.content_for :title, t('.section') %>
3
+ <% p.content_for :body do %>
4
+ <%= render 'account/shared/box', divider: true do |p| %>
5
+ <% p.content_for :title, t('.header') %>
6
+ <% p.content_for :description, t('.description') %>
7
+ <% p.content_for :body do %>
8
+ <%= render 'form', delivery: @delivery %>
9
+ <% end %>
10
+ <% end %>
11
+ <% end %>
12
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <%= render 'account/shared/page' do |p| %>
2
+ <% p.content_for :title, t('.section') %>
3
+ <% p.content_for :body do %>
4
+ <%= render 'index', deliveries: @deliveries %>
5
+ <% end %>
6
+ <% end %>
@@ -0,0 +1 @@
1
+ json.array! @deliveries, partial: "webhooks/outgoing/deliveries/delivery", as: :delivery
@@ -0,0 +1,12 @@
1
+ <%= render 'account/shared/page' do |p| %>
2
+ <% p.content_for :title, t('.section') %>
3
+ <% p.content_for :body do %>
4
+ <%= render 'account/shared/box', divider: true do |p| %>
5
+ <% p.content_for :title, t('.header') %>
6
+ <% p.content_for :description, t('.description') %>
7
+ <% p.content_for :body do %>
8
+ <%= render 'form', delivery: @delivery %>
9
+ <% end %>
10
+ <% end %>
11
+ <% end %>
12
+ <% end %>
@@ -0,0 +1,37 @@
1
+ <%= render 'account/shared/page' do |p| %>
2
+ <% p.content_for :title, t('.section').html_safe %>
3
+ <% p.content_for :body do %>
4
+ <%= render 'account/shared/box', divider: true do |p| %>
5
+ <% p.content_for :title, t('.header') %>
6
+ <% p.content_for :description do %>
7
+ <%= t('.description').html_safe %>
8
+ <%= t('.manage_description') if can? :manage, @delivery %>
9
+ <% end %>
10
+
11
+ <% p.content_for :body do %>
12
+ <% with_attribute_settings object: @delivery, strategy: :label do %>
13
+ <% with_attribute_settings object: @delivery.event do %>
14
+ <%= render 'shared/attributes/code', attribute: :uuid %>
15
+ <%= render 'shared/attributes/code', attribute: :event_type_name %>
16
+ <%= render 'shared/attributes/attribute', attribute: :payload do %>
17
+ <pre><%= JSON.pretty_generate(@delivery.event.payload) %></pre>
18
+ <% end %>
19
+ <% end %>
20
+ <%= render 'shared/attributes/attempt', attribute: :status, success_method: :delivered?, attempting_method: :still_attempting?, failure_method: :failed? %>
21
+ <%= render 'shared/attributes/code', attribute: :endpoint_url %>
22
+ <%= render 'shared/attributes/date_and_time', attribute: :delivered_at %>
23
+ <%# 🚅 super scaffolding will insert new fields above this line. %>
24
+ <% end %>
25
+ <% end %>
26
+
27
+ <% p.content_for :actions do %>
28
+ <%= link_to t('.buttons.edit'), [:edit, :account, @delivery], class: first_button_primary if can? :edit, @delivery %>
29
+ <%= button_to t('.buttons.destroy'), [:account, @delivery], method: :delete, class: first_button_primary, data: { confirm: t('.buttons.confirmations.destroy', model_locales(@delivery)) } if can? :destroy, @delivery %>
30
+ <%= link_to t('global.buttons.back'), [:account, @endpoint, :deliveries], class: first_button_primary %>
31
+ <% end %>
32
+ <% end %>
33
+
34
+ <%= render 'account/webhooks/outgoing/delivery_attempts/index', delivery_attempts: @delivery.delivery_attempts, hide_back: true %>
35
+ <%# 🚅 super scaffolding will insert new children above this line. %>
36
+ <% end %>
37
+ <% end %>
@@ -0,0 +1 @@
1
+ json.partial! "webhooks/outgoing/deliveries/delivery", delivery: @delivery
@@ -0,0 +1,8 @@
1
+ <% delivery_attempt ||= @delivery_attempt %>
2
+ <% delivery ||= @delivery || delivery_attempt&.delivery %>
3
+ <%= render 'account/webhooks/outgoing/deliveries/breadcrumbs', delivery: delivery %>
4
+ <%= render 'account/shared/breadcrumb', label: t('.label'), url: [:account, delivery, :delivery_attempts] %>
5
+ <% if delivery_attempt&.persisted? %>
6
+ <%= render 'account/shared/breadcrumb', label: delivery_attempt.label_string, url: [:account, delivery_attempt] %>
7
+ <% end %>
8
+ <%= render 'account/shared/breadcrumbs/actions', only_for: 'webhooks/outgoing/delivery_attempts' %>
@@ -0,0 +1,12 @@
1
+ json.extract! delivery_attempt,
2
+ :id,
3
+ :delivery_id,
4
+ :response_code,
5
+ :response_body,
6
+ :response_message,
7
+ :error_message,
8
+ :attempt_number,
9
+ # 🚅 super scaffolding will insert new fields above this line.
10
+ :created_at,
11
+ :updated_at
12
+ json.url account_webhooks_outgoing_delivery_attempt_url(delivery_attempt, format: :json)
@@ -0,0 +1,22 @@
1
+ <%= form_with model: delivery_attempt, url: (delivery_attempt.persisted? ? [:account, delivery_attempt] : [:account, @delivery, :delivery_attempts]), local: true, class: 'form' do |form| %>
2
+ <%= render 'account/shared/forms/errors', form: form %>
3
+
4
+ <% with_field_settings form: form do %>
5
+ <%= render 'shared/fields/text_field', method: :response_code, options: {autofocus: true} %>
6
+ <%= render 'shared/fields/text_area', method: :response_body %>
7
+ <%= render 'shared/fields/text_area', method: :response_message %>
8
+ <%= render 'shared/fields/text_area', method: :error_message %>
9
+ <%= render 'shared/fields/text_field', method: :attempt_number %>
10
+ <%# 🚅 super scaffolding will insert new fields above this line. %>
11
+ <% end %>
12
+
13
+ <div class="buttons">
14
+ <%= form.submit (form.object.persisted? ? t('.buttons.update') : t('.buttons.create')), class: "button" %>
15
+ <% if form.object.persisted? %>
16
+ <%= link_to t('global.buttons.cancel'), [:account, delivery_attempt], class: "button-secondary" %>
17
+ <% else %>
18
+ <%= link_to t('global.buttons.cancel'), [:account, @delivery, :delivery_attempts], class: "button-secondary" %>
19
+ <% end %>
20
+ </div>
21
+
22
+ <% end %>
@@ -0,0 +1,69 @@
1
+ <% delivery = @delivery || @delivery %>
2
+ <% context ||= delivery %>
3
+ <% collection ||= :delivery_attempts %>
4
+ <% hide_actions ||= false %>
5
+ <% hide_back ||= false %>
6
+
7
+ <%= render 'account/shared/box' do |p| %>
8
+ <% p.content_for :title, t(".contexts.#{context.class.name.underscore}.header") %>
9
+ <% p.content_for :description do %>
10
+ <%= t(".contexts.#{context.class.name.underscore}.description") %>
11
+ <% end %>
12
+
13
+ <% p.content_for :table do %>
14
+ <% if delivery_attempts.any? %>
15
+ <table class="table">
16
+ <thead>
17
+ <tr>
18
+ <th><%= t('.fields.attempt_number.heading') %></th>
19
+ <th><%= t('.fields.created_at.heading') %></th>
20
+ <th class="text-center"><%= t('.fields.status.heading') %></th>
21
+ <th class="text-center"><%= t('.fields.response_code.heading') %></th>
22
+ <%# 🚅 super scaffolding will insert new field headers above this line. %>
23
+ <th class="text-right"></th>
24
+ </tr>
25
+ </thead>
26
+ <tbody>
27
+ <% delivery_attempts.each do |delivery_attempt| %>
28
+ <% with_attribute_settings object: delivery_attempt do %>
29
+ <tr data-id="<%= delivery_attempt.id %>">
30
+ <td><%= render 'shared/attributes/text', attribute: :attempt_number, url: [:account, delivery_attempt] %></td>
31
+ <td><%= render 'shared/attributes/date_and_time', attribute: :created_at %></td>
32
+ <td class="text-center"><%= render 'shared/attributes/attempt', attribute: :status, success_method: :successful?, attempting_method: :still_attempting?, failure_method: :failed? %></td>
33
+ <td class="text-center"><%= render 'shared/attributes/code', attribute: :response_code %></td>
34
+ <%# 🚅 super scaffolding will insert new fields above this line. %>
35
+ <td class="buttons">
36
+ <% unless hide_actions %>
37
+ <% if can? :show, delivery_attempt %>
38
+ <%= link_to t('.buttons.shorthand.show'), [:account, delivery_attempt], class: 'button-secondary button-smaller' %>
39
+ <% end %>
40
+ <% if can? :edit, delivery_attempt %>
41
+ <%= link_to t('.buttons.shorthand.edit'), [:edit, :account, delivery_attempt], class: 'button-secondary button-smaller' %>
42
+ <% end %>
43
+ <% if can? :destroy, delivery_attempt %>
44
+ <%= button_to t('.buttons.shorthand.destroy'), [:account, delivery_attempt], method: :delete, data: { confirm: t('.buttons.confirmations.destroy', model_locales(delivery_attempt)) }, class: 'button-secondary button-smaller' %>
45
+ <% end %>
46
+ <% end %>
47
+ </td>
48
+ </tr>
49
+ <% end %>
50
+ <% end %>
51
+ </tbody>
52
+ </table>
53
+ <% end %>
54
+ <% end %>
55
+
56
+ <% p.content_for :actions do %>
57
+ <% unless hide_actions %>
58
+ <% if context == delivery %>
59
+ <% if can? :create, Webhooks::Outgoing::DeliveryAttempt.new(delivery: delivery) %>
60
+ <%= link_to t('.buttons.new'), [:new, :account, delivery, :delivery_attempt], class: "#{first_button_primary(:delivery_attempt)} new" %>
61
+ <% end %>
62
+ <% end %>
63
+
64
+ <% unless hide_back %>
65
+ <%= link_to t('global.buttons.back'), [:account, context], class: "#{first_button_primary(:delivery_attempt)} back" %>
66
+ <% end %>
67
+ <% end %>
68
+ <% end %>
69
+ <% end %>
@@ -0,0 +1,10 @@
1
+ <% if can? :read, Webhooks::Outgoing::DeliveryAttempt.new(team: current_team) %>
2
+ <%= render 'account/shared/menu/item', {
3
+ url: main_app.polymorphic_path([:account, current_team, :webhooks_outgoing_delivery_attempts]),
4
+ label: t('webhooks/outgoing/delivery_attempts.navigation.label'),
5
+ } do |p| %>
6
+ <% p.content_for :icon do %>
7
+ <i class="<%= t('webhooks/outgoing/delivery_attempts.navigation.icon') %>"></i>
8
+ <% end %>
9
+ <% end %>
10
+ <% end %>
@@ -0,0 +1,7 @@
1
+ <% if delivery_attempt.successful? %>
2
+ <div class="square-icon text-success"><i class="ti-check"></i></div>
3
+ <% elsif delivery_attempt.still_attempting? %>
4
+ <div class="square-icon"><i class="ti-reload rotating"></i></div>
5
+ <% else %>
6
+ <div class="square-icon text-danger"><i class="ti-close"></i></div>
7
+ <% end %>
@@ -0,0 +1,12 @@
1
+ <%= render 'account/shared/page' do |p| %>
2
+ <% p.content_for :title, t('.section') %>
3
+ <% p.content_for :body do %>
4
+ <%= render 'account/shared/box', divider: true do |p| %>
5
+ <% p.content_for :title, t('.header') %>
6
+ <% p.content_for :description, t('.description') %>
7
+ <% p.content_for :body do %>
8
+ <%= render 'form', delivery_attempt: @delivery_attempt %>
9
+ <% end %>
10
+ <% end %>
11
+ <% end %>
12
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <%= render 'account/shared/page' do |p| %>
2
+ <% p.content_for :title, t('.section') %>
3
+ <% p.content_for :body do %>
4
+ <%= render 'index', delivery_attempts: @delivery_attempts %>
5
+ <% end %>
6
+ <% end %>
@@ -0,0 +1 @@
1
+ json.array! @delivery_attempts, partial: "webhooks/outgoing/delivery_attempts/delivery_attempt", as: :delivery_attempt
@@ -0,0 +1,12 @@
1
+ <%= render 'account/shared/page' do |p| %>
2
+ <% p.content_for :title, t('.section') %>
3
+ <% p.content_for :body do %>
4
+ <%= render 'account/shared/box', divider: true do |p| %>
5
+ <% p.content_for :title, t('.header') %>
6
+ <% p.content_for :description, t('.description') %>
7
+ <% p.content_for :body do %>
8
+ <%= render 'form', delivery_attempt: @delivery_attempt %>
9
+ <% end %>
10
+ <% end %>
11
+ <% end %>
12
+ <% end %>
@@ -0,0 +1,32 @@
1
+ <%= render 'account/shared/page' do |p| %>
2
+ <% p.content_for :title, t('.section').html_safe %>
3
+ <% p.content_for :body do %>
4
+ <%= render 'account/shared/box', divider: true do |p| %>
5
+ <% p.content_for :title, t('.header') %>
6
+ <% p.content_for :description do %>
7
+ <%= t('.description') %>
8
+ <%= t('.manage_description') if can? :manage, @delivery_attempt %>
9
+ <% end %>
10
+
11
+ <% p.content_for :body do %>
12
+ <% with_attribute_settings object: @delivery_attempt, strategy: :label do %>
13
+ <%= render 'shared/attributes/text', attribute: :attempt_number %>
14
+ <%= render 'shared/attributes/attempt', attribute: :status, success_method: :successful?, attempting_method: :still_attempting?, failure_method: :failed? %>
15
+ <%= render 'shared/attributes/code', attribute: :response_code %>
16
+ <%= render 'shared/attributes/code', attribute: :response_message %>
17
+ <%= render 'shared/attributes/block', attribute: :response_body %>
18
+ <%= render 'shared/attributes/code', attribute: :error_message %>
19
+ <%# 🚅 super scaffolding will insert new fields above this line. %>
20
+ <% end %>
21
+ <% end %>
22
+
23
+ <% p.content_for :actions do %>
24
+ <%= link_to t('.buttons.edit'), [:edit, :account, @delivery_attempt], class: first_button_primary if can? :edit, @delivery_attempt %>
25
+ <%= button_to t('.buttons.destroy'), [:account, @delivery_attempt], method: :delete, class: first_button_primary, data: { confirm: t('.buttons.confirmations.destroy', model_locales(@delivery_attempt)) } if can? :destroy, @delivery_attempt %>
26
+ <%= link_to t('global.buttons.back'), [:account, @delivery, :delivery_attempts], class: first_button_primary %>
27
+ <% end %>
28
+ <% end %>
29
+
30
+ <%# 🚅 super scaffolding will insert new children above this line. %>
31
+ <% end %>
32
+ <% end %>
@@ -0,0 +1 @@
1
+ json.partial! "webhooks/outgoing/delivery_attempts/delivery_attempt", delivery_attempt: @delivery_attempt
@@ -0,0 +1,8 @@
1
+ <% endpoint ||= @endpoint %>
2
+ <% team ||= @team || endpoint&.team %>
3
+ <%= render 'account/teams/breadcrumbs', team: team %>
4
+ <%= render 'account/shared/breadcrumb', label: t('.label'), url: [:account, team, :webhooks_outgoing_endpoints] %>
5
+ <% if endpoint&.persisted? %>
6
+ <%= render 'account/shared/breadcrumb', label: endpoint.label_string, url: [:account, endpoint] %>
7
+ <% end %>
8
+ <%= render 'account/shared/breadcrumbs/actions', only_for: 'webhooks/outgoing/endpoints' %>