Class: SolidQueueTui::Views::FailedView
- Inherits:
-
Object
- Object
- SolidQueueTui::Views::FailedView
- Defined in:
- lib/solid_queue_tui/views/failed_view.rb
Instance Method Summary collapse
- #bindings ⇒ Object
- #breadcrumb ⇒ Object
- #capturing_input? ⇒ Boolean
- #filter ⇒ Object
- #handle_input(event) ⇒ Object
-
#initialize(tui) ⇒ FailedView
constructor
A new instance of FailedView.
- #render(frame, area) ⇒ Object
- #selected_item ⇒ Object
- #update(failed_jobs:) ⇒ Object
Constructor Details
#initialize(tui) ⇒ FailedView
Returns a new instance of FailedView.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/solid_queue_tui/views/failed_view.rb', line 6 def initialize(tui) @tui = tui @table_state = RatatuiRuby::TableState.new(nil) @table_state.select(0) @selected_row = 0 @failed_jobs = [] @filter = nil @filter_mode = false @filter_input = "" @confirm_action = nil end |
Instance Method Details
#bindings ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/solid_queue_tui/views/failed_view.rb', line 69 def bindings if @confirm_action [ { key: "y", action: "Confirm" }, { key: "n/Esc", action: "Cancel" } ] elsif @filter_mode [ { key: "Enter", action: "Apply" }, { key: "Esc", action: "Cancel" } ] else [ { key: "j/k", action: "Navigate" }, { key: "Enter", action: "Detail" }, { key: "R", action: "Retry" }, { key: "D", action: "Discard" }, { key: "A", action: "Retry All" }, { key: "/", action: "Filter" } ] end end |
#breadcrumb ⇒ Object
96 97 98 |
# File 'lib/solid_queue_tui/views/failed_view.rb', line 96 def @filter ? "failed:#{@filter}" : "failed" end |
#capturing_input? ⇒ Boolean
92 93 94 |
# File 'lib/solid_queue_tui/views/failed_view.rb', line 92 def capturing_input? @filter_mode || @confirm_action end |
#filter ⇒ Object
67 |
# File 'lib/solid_queue_tui/views/failed_view.rb', line 67 def filter = @filter |
#handle_input(event) ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/solid_queue_tui/views/failed_view.rb', line 52 def handle_input(event) if @confirm_action handle_confirm_input(event) elsif @filter_mode handle_filter_input(event) else handle_normal_input(event) end end |
#render(frame, area) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/solid_queue_tui/views/failed_view.rb', line 24 def render(frame, area) if @confirm_action content_area, confirm_area = @tui.layout_split( area, direction: :vertical, constraints: [ @tui.constraint_fill(1), @tui.constraint_length(3) ] ) render_failed_table(frame, content_area) render_confirm(frame, confirm_area) elsif @filter_mode content_area, filter_area = @tui.layout_split( area, direction: :vertical, constraints: [ @tui.constraint_fill(1), @tui.constraint_length(3) ] ) render_failed_table(frame, content_area) render_filter_input(frame, filter_area) else render_failed_table(frame, area) end end |
#selected_item ⇒ Object
62 63 64 65 |
# File 'lib/solid_queue_tui/views/failed_view.rb', line 62 def selected_item return nil if @failed_jobs.empty? || @selected_row >= @failed_jobs.size @failed_jobs[@selected_row] end |
#update(failed_jobs:) ⇒ Object
18 19 20 21 22 |
# File 'lib/solid_queue_tui/views/failed_view.rb', line 18 def update(failed_jobs:) @failed_jobs = failed_jobs @selected_row = @selected_row.clamp(0, [@failed_jobs.size - 1, 0].max) @table_state.select(@selected_row) end |