From 7864fdbeb3af1697a7f1c6ab1a26ec324a3417da Mon Sep 17 00:00:00 2001 From: Mike Perham Date: Mon, 23 Sep 2019 14:52:15 -0700 Subject: [PATCH] Polish job tags with Sidekiq Pro filtering support --- Changes.md | 11 ++++++----- lib/sidekiq/web/helpers.rb | 6 ++++++ web/assets/stylesheets/application.css | 9 +++++++++ web/views/_job_info.erb | 8 ++------ web/views/busy.erb | 4 +--- web/views/morgue.erb | 4 +--- web/views/queue.erb | 4 +--- web/views/retries.erb | 5 ++++- web/views/scheduled.erb | 4 +--- 9 files changed, 31 insertions(+), 24 deletions(-) diff --git a/Changes.md b/Changes.md index 02c723cf..78e58bb5 100644 --- a/Changes.md +++ b/Changes.md @@ -5,14 +5,15 @@ HEAD --------- -- Support ad-hoc job tags. You can tag your jobs with, for example, subdomain, tenant, country, locale, application, - version, user/client, "alpha/beta/pro/ent", types of jobs, teams/people responsible for jobs, - additional metadata, etc. - Tags are shown on different pages with job listings [fatkodima, #4280] +- Support ad-hoc job tags. You can tag your jobs with, e.g, subdomain, tenant, country, + locale, application, version, user/client, "alpha/beta/pro/ent", types of jobs, + teams/people responsible for jobs, additional metadata, etc. + Tags are shown on different pages with job listings. Sidekiq Pro users + can filter based on them [fatkodima, #4280] ```ruby class MyWorker include Sidekiq::Worker - sidekiq_options tags: ['foo', 'bar'] + sidekiq_options tags: ['bank-ops', 'alpha'] ... end ``` diff --git a/lib/sidekiq/web/helpers.rb b/lib/sidekiq/web/helpers.rb index 5e14f075..69189f00 100644 --- a/lib/sidekiq/web/helpers.rb +++ b/lib/sidekiq/web/helpers.rb @@ -115,6 +115,12 @@ module Sidekiq end end + def display_tags(job) + job.tags.map { |tag| + "#{::Rack::Utils.escape_html(tag)}" + }.join(" ") + end + # mperham/sidekiq#3243 def unfiltered? yield unless env["PATH_INFO"].start_with?("/filter/") diff --git a/web/assets/stylesheets/application.css b/web/assets/stylesheets/application.css index 456b4437..5db6656c 100644 --- a/web/assets/stylesheets/application.css +++ b/web/assets/stylesheets/application.css @@ -201,6 +201,15 @@ td form { padding: 0; } +.jobtag a { + color: white; +} + +.jobtag a:hover { + color: white; + text-decoration: underline; +} + table .table-checkbox label { height: 100%; width: 100%; diff --git a/web/views/_job_info.erb b/web/views/_job_info.erb index ff27105b..504b3927 100644 --- a/web/views/_job_info.erb +++ b/web/views/_job_info.erb @@ -14,12 +14,8 @@ <%= t('Job') %> - - <%= job.display_class %> - <% job.tags.each do |tag| %> - <%= tag %> - <% end %> - + <%= job.display_class %> + <%= display_tags(job) %> diff --git a/web/views/busy.erb b/web/views/busy.erb index 8049eabb..e8c82b9b 100644 --- a/web/views/busy.erb +++ b/web/views/busy.erb @@ -89,9 +89,7 @@ <%= job.display_class %> - <% job.tags.each do |tag| %> - <%= tag %> - <% end %> + <%= display_tags(job, nil) %>
<%= display_args(job.display_args) %>
diff --git a/web/views/morgue.erb b/web/views/morgue.erb index 07a96f8c..f4fcce7d 100644 --- a/web/views/morgue.erb +++ b/web/views/morgue.erb @@ -44,9 +44,7 @@ <%= entry.display_class %> - <% entry.tags.each do |tag| %> - <%= tag %> - <% end %> + <%= display_tags(entry, "morgue") %>
<%= display_args(entry.display_args) %>
diff --git a/web/views/queue.erb b/web/views/queue.erb index d7eaab0f..a79f8898 100644 --- a/web/views/queue.erb +++ b/web/views/queue.erb @@ -29,9 +29,7 @@ <% end %> <%= h(msg.display_class) %> - <% msg.tags.each do |tag| %> - <%= tag %> - <% end %> + <%= display_tags(msg, nil) %> <% a = msg.display_args %> diff --git a/web/views/retries.erb b/web/views/retries.erb index 31419129..44e43f0e 100644 --- a/web/views/retries.erb +++ b/web/views/retries.erb @@ -44,7 +44,10 @@ <%= entry.queue %> - <%= entry.display_class %> + + <%= entry.display_class %> + <%= display_tags(entry, "retries") %> +
<%= display_args(entry.display_args) %>
diff --git a/web/views/scheduled.erb b/web/views/scheduled.erb index 6fadf91c..8db57626 100644 --- a/web/views/scheduled.erb +++ b/web/views/scheduled.erb @@ -40,9 +40,7 @@ <%= entry.display_class %> - <% entry.tags.each do |tag| %> - <%= tag %> - <% end %> + <%= display_tags(entry, "scheduled") %>
<%= display_args(entry.display_args) %>