Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add support for custom tabs to Sidekiq::Web #346

  • Loading branch information...
commit 4e2dae3c249f673e633623b320a7a1df8bc941ea 1 parent b05be26
Marcelo Silveira authored
8 lib/sidekiq/web.rb
@@ -111,6 +111,10 @@ def relative_time(time)
111 111 def display_args(args, count=100)
112 112 args.map { |arg| a = arg.inspect; a.size > count ? "#{a[0..count]}..." : a }.join(", ")
113 113 end
  114 +
  115 + def tabs
  116 + Sidekiq::Web.tabs
  117 + end
114 118 end
115 119
116 120 get "/" do
@@ -223,6 +227,10 @@ def process_score(set, score, operation)
223 227 end
224 228 end
225 229
  230 + def self.tabs
  231 + @tabs ||= ["Queues", "Retries", "Scheduled"]
  232 + end
  233 +
226 234 end
227 235
228 236 end
9 test/test_web.rb
@@ -148,6 +148,15 @@ def perform(a, b)
148 148 assert_match /#{msg['args'][2]}/, last_response.body
149 149 end
150 150
  151 + it 'can show user defined tab' do
  152 + Sidekiq::Web.tabs << 'Custom Tab'
  153 +
  154 + get '/'
  155 + assert_match 'Custom Tab', last_response.body
  156 +
  157 + Sidekiq::Web.tabs.delete 'Custom Tab'
  158 + end
  159 +
151 160 def add_scheduled
152 161 msg = { 'class' => 'HardWorker',
153 162 'args' => ['bob', 1, Time.now.to_f],
10 web/views/layout.slim
@@ -17,12 +17,10 @@ html
17 17 ul.nav
18 18 li
19 19 a href='#{{root_path}}' Home
20   - li
21   - a href='#{{root_path}}queues' Queues
22   - li
23   - a href='#{{root_path}}retries' Retries
24   - li
25   - a href='#{{root_path}}scheduled' Scheduled
  20 + - tabs.each do |tab|
  21 + li
  22 + a href='#{{root_path}}#{{tab.downcase}}': #{tab}
  23 +
26 24 ul.nav.pull-right
27 25 li
28 26 a Redis: #{location}

0 comments on commit 4e2dae3

Please sign in to comment.
Something went wrong with that request. Please try again.