From cc2a07d45e8621aaac886290d397968aa2bc2cb6 Mon Sep 17 00:00:00 2001 From: Mike Perham Date: Sun, 6 Nov 2022 15:04:16 -0800 Subject: [PATCH] Adjust API a bit, #5624 --- Changes.md | 1 + test/web_test.rb | 17 +++++++++++++++++ web/views/_job_info.erb | 8 ++++---- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Changes.md b/Changes.md index da2630db..998523c2 100644 --- a/Changes.md +++ b/Changes.md @@ -6,6 +6,7 @@ HEAD ---------- - Add BID link on job_info page if job is part of a Batch [#5623] +- Allow custom extensions to add rows/links within the Job Details page [#5624] 7.0.1 ---------- diff --git a/test/web_test.rb b/test/web_test.rb index 4cb2f860..c7dc7edd 100644 --- a/test/web_test.rb +++ b/test/web_test.rb @@ -12,6 +12,12 @@ class WebJob end end +class LogDisplayer + def add_pair(job) + yield "External Logs", "Logs for #{job.jid}" + end +end + describe Sidekiq::Web do include Rack::Test::Methods @@ -271,10 +277,21 @@ describe Sidekiq::Web do assert_match(/HardJob/, last_response.body) end + it "displays custom job info" do + Sidekiq::Web.custom_job_info_rows << LogDisplayer.new + params = add_retry + get "/retries/#{job_params(*params)}" + assert_equal 200, last_response.status + assert_match(/https:\/\/example.com\/logs\//, last_response.body) + ensure + Sidekiq::Web.custom_job_info_rows.clear + end + it "can display a single retry" do params = add_retry get "/retries/0-shouldntexist" assert_equal 302, last_response.status + get "/retries/#{job_params(*params)}" assert_equal 200, last_response.status assert_match(/HardJob/, last_response.body) diff --git a/web/views/_job_info.erb b/web/views/_job_info.erb index 75019f49..60032378 100644 --- a/web/views/_job_info.erb +++ b/web/views/_job_info.erb @@ -92,11 +92,11 @@ <%= relative_time(job.at) if job['retry_count'] %> <% end %> - <% Sidekiq::Web.custom_job_info_rows.each do |processor| %> - <% if processor.show_row(job) %> + <% Sidekiq::Web.custom_job_info_rows.each do |helper| %> + <% helper.add_pair(job) do |name, value| %> - <%= processor.row_name %> - <%= processor.row_contents(job) %> + <%= name %> + <%= value %> <% end %> <% end %>