Sha256: fbc7ccd53e3f705ee6fbd7d234c54ed662a31fe5d806706570b93d071f7d35d0

Contents?: true

Size: 1.31 KB

Versions: 7

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

require "sidekiq/web/helpers"

module Sidekiq
  module Belt
    module Pro
      module FailedBatchRemove
        module SidekiqFailedBatchRemove
          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

          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(params[:bid]).delete

              return redirect "#{root_path}batches"
            end
          end
        end

        def self.use!
          require("sidekiq/web")

          Sidekiq::Web.register(Sidekiq::Belt::Pro::FailedBatchRemove::SidekiqFailedBatchRemove)
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sidekiq-belt-0.3.7 lib/sidekiq/belt/pro/failed_batch_remove.rb
sidekiq-belt-0.3.6 lib/sidekiq/belt/pro/failed_batch_remove.rb
sidekiq-belt-0.3.5 lib/sidekiq/belt/pro/failed_batch_remove.rb
sidekiq-belt-0.3.4 lib/sidekiq/belt/pro/failed_batch_remove.rb
sidekiq-belt-0.3.2 lib/sidekiq/belt/pro/failed_batch_remove.rb
sidekiq-belt-0.3.1 lib/sidekiq/belt/pro/failed_batch_remove.rb
sidekiq-belt-0.3.0 lib/sidekiq/belt/pro/failed_batch_remove.rb