Sha256: 097382e3f77814f55c107ea677566f2255114ddbb17020c04432ee9e6ecf8532
Contents?: true
Size: 1.73 KB
Versions: 1
Compression:
Stored size: 1.73 KB
Contents
# frozen_string_literal: true require "sidekiq/web/helpers" module Sidekiq module Belt module Pro module ForceBatchCallback module SidekiqForceBatchCallback def self.action_button(action) <<~ERB <form action="<%= root_path %>batches/<%= @batch.bid %>/force_callback/#{action}" method="post"> <%= csrf_tag %> <input class="btn btn-danger" type="submit" name="force_#{action}" value="<%= t('#{action.capitalize}') %>" data-confirm="Do you want to force the #{action} callback for batch <%= @batch.bid %>? <%= t('AreYouSure') %>" /> </form> ERB end def self.registered(app) app.replace_content("/batches/:bid") do |content| content.sub!(%r{(</tbody>)}) do |match| <<-HTML <tr> <th><%= t("Force Action") %></th> <td> <div style="display: flex;"> #{action_button("success")} #{action_button("complete")} #{action_button("death")} </div> </td> </tr> #{match} HTML end end app.post("/batches/:bid/force_callback/:action") do Sidekiq::Batch::Callback.perform_inline(params[:action], params[:bid]) return redirect "#{root_path}batches" end end end def self.use! require("sidekiq/web") Sidekiq::Web.register(Sidekiq::Belt::Pro::ForceBatchCallback::SidekiqForceBatchCallback) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sidekiq-belt-1.0.0 | lib/sidekiq/belt/pro/force_batch_callback.rb |