Class: Plutonium::UI::Interaction::Async::RunProgress

Inherits:
Component::Base show all
Includes:
Phlex::Rails::Helpers::TurboFrameTag
Defined in:
lib/plutonium/ui/interaction/async/run_progress.rb

Overview

The progress panel on a run's show page — the page IS the progress page.

How it refreshes

Polling, not ActionCable: a turbo-frame the browser re-fetches on a timer works on any deployment, including ones with no cable server, and a run's progress is a handful of numbers that nobody needs sub-second. The frame is driven by the run-progress Stimulus controller, which lives INSIDE the frame — so when the run finishes, the refreshed markup no longer carries the controller and the timer stops of its own accord. A finished run is a static record; a poll that never stops is a background request per viewer, forever.

The frame's src is the run's own show URL. Turbo sends Turbo-Frame: <id> with that request, so the response must be the PANEL ALONE — Plutonium's DynaFrameContent already wraps every response in a frame named by that header, and a second tag with the same id would nest the whole page inside its own progress frame (and again on the next poll). Async::RunDefinition::ShowPage short-circuits the page for exactly this request; this class drops its own frame tag to match.

Constant Summary collapse

POLL_INTERVAL_MS =

Slow enough to be cheap for a page left open on a wall display, fast enough that a short run does not look stuck.

2_000
SWEEP_DURATION_MS =

Must match the animation in components.css. Ruby needs it because the poll restarts the animation and only the server knows how far into the sweep the bar should be — see #sweep_phase_ms.

1_400
BADGE_VARIANTS =

Semantic colour per outcome. completed_with_errors is deliberately NOT success: see Plutonium::Interaction::Async::Run#outcome.

{
  "pending" => "warning",
  "running" => "info",
  "completed" => "success",
  "completed_with_errors" => "warning",
  "failed" => "danger"
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Component::Behaviour

#around_template

Methods included from Component::Tokens

#classes, #tokens

Methods included from Component::Kit

#BuildActionButton, #BuildActionsDropdown, #BuildAvatar, #BuildBlock, #BuildBreadcrumbs, #BuildBulkActionsToolbar, #BuildColorModeSelector, #BuildDynaFrameContent, #BuildDynaFrameHost, #BuildEmptyCard, #BuildFrameNavigatorPanel, #BuildModalCentered, #BuildModalSlideover, #BuildPageHeader, #BuildPanel, #BuildRowActionsDropdown, #BuildSkeletonTable, #BuildTabList, #BuildTableFilterPills, #BuildTableInfo, #BuildTablePagination, #BuildTableScopesBar, #BuildTableScopesPills, #BuildTableSearchBar, #BuildTableToolbar, #BuildTableViewSwitcher, #method_missing, #respond_to_missing?

Constructor Details

#initialize(run) ⇒ RunProgress

Returns a new instance of RunProgress.



53
54
55
# File 'lib/plutonium/ui/interaction/async/run_progress.rb', line 53

def initialize(run)
  @run = run
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Plutonium::UI::Component::Kit

Instance Attribute Details

#runObject (readonly)

Returns the value of attribute run.



57
58
59
# File 'lib/plutonium/ui/interaction/async/run_progress.rb', line 57

def run
  @run
end

Class Method Details

.frame_id(run) ⇒ Object

Public so the page can recognise a poll of THIS panel and answer with the panel alone.



51
# File 'lib/plutonium/ui/interaction/async/run_progress.rb', line 51

def self.frame_id(run) = "pu_run_progress_#{run.id}"

Instance Method Details

#view_templateObject



59
60
61
62
63
64
65
# File 'lib/plutonium/ui/interaction/async/run_progress.rb', line 59

def view_template
  return render_panel if answering_own_frame?

  # `turbo-frame` defaults to `display: inline`, which swallows the
  # margin `sections_wrapper` needs to separate it from the card below.
  turbo_frame_tag(frame_id, class: "block") { render_panel }
end