Module: Sidekiq::Belt::Pro::FailedBatchRemove::SidekiqFailedBatchRemove

Defined in:
lib/sidekiq/belt/pro/failed_batch_remove.rb

Constant Summary collapse

REMOVE_BUTTON =
<<~ERB
  <form action="<%= root_path %>batches/<%= bid %>/remove" method="post">
    <%= csrf_tag %>
    <input class="btn btn-danger" type="submit" name="remove" value="<%= t('Remove') %>"
      data-confirm="Do you want to remove batch <%= bid %>? <%= t('AreYouSure') %>" />
  </form>
ERB

Class Method Summary collapse

Class Method Details

.registered(app) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/sidekiq/belt/pro/failed_batch_remove.rb', line 18

def self.registered(app)
  app.replace_content("/batches") do |content|
    content.gsub!("</th>\n    <%", "</th><th><%= t('Delete') %></th>\n      <%")

    content.gsub!(
      "</td>\n      </tr>\n    <% end %>",
      "</td>\n<td>#{REMOVE_BUTTON}</td>\n        </tr>\n      <% end %>"
    )
  end

  app.post("/batches/:bid/remove") do
    Sidekiq::Batch::Status.new(route_params(:bid)).delete

    return redirect "#{root_path}batches"
  end
end