diff --git a/app/assets/javascripts/admin/addon/components/webhook-events.js b/app/assets/javascripts/admin/addon/components/webhook-events.js index 63a031014d1..a171f71fb09 100644 --- a/app/assets/javascripts/admin/addon/components/webhook-events.js +++ b/app/assets/javascripts/admin/addon/components/webhook-events.js @@ -129,6 +129,11 @@ export default class WebhookEvents extends Component { this.eventIds = this.events.content.map((event) => event.id); this.count = this.events.length; + if (this.count === 0) { + this.dialog.alert("No events to redeliver."); + return; + } + return this.dialog.yesNoConfirm({ message: I18n.t("admin.web_hooks.events.bulk_redeliver_confirm", { count: this.count, @@ -139,7 +144,11 @@ export default class WebhookEvents extends Component { `/admin/api/web_hooks/${this.args.webhookId}/events/bulk_redeliver`, { type: "POST", data: { event_ids: this.eventIds } } ); - this.args.event.setProperties(json.web_hook_event); + if (json.web_hook_event && json.web_hook_event.length > 0) { + this.args.event.setProperties(json.web_hook_event); + } else { + this.dialog.alert("No events to redeliver."); + } } catch (e) { popupAjaxError(e); } diff --git a/app/controllers/admin/web_hooks_controller.rb b/app/controllers/admin/web_hooks_controller.rb index 64945205f92..1ce3b0ec2b6 100644 --- a/app/controllers/admin/web_hooks_controller.rb +++ b/app/controllers/admin/web_hooks_controller.rb @@ -138,7 +138,7 @@ class Admin::WebHooksController < Admin::AdminController def bulk_redeliver_events limit = 50 offset = params[:offset].to_i - failed_events = @web_hook.web_hook_events.failed.limit(limit).offset(offset) + failed_events = @web_hook&.web_hook_events&.failed&.limit(limit)&.offset(offset) render_serialized(failed_events, AdminWebHookEventSerializer, root: "web_hook_event") end