MishkaCmsCoreWeb.Live.Admin.Dashboard.Runtime.RuntimeStatusLive (Mishka CMS Core v0.0.1)

Copy Markdown View Source

Shared expanded-row wiring for every runtime admin table (Component, Layout, ErrorPage, Page, Stylesheet, JsHook). The expanded row shows the record's real runtime status (MishkaCmsCore.Runtime.RuntimeStatus) as a live timeline that refreshes while open.

Each page keeps its own handle_info/2 and handle_async/3 clauses (so they stay grouped) and delegates the body here:

def mount(_p, _s, socket) do
  socket =
    RuntimeStatusLive.setup(socket,
      resource: MishkaCmsCore.Runtime.JsHook,
      table_id: "js-hooks-table",
      master_action: :master_get,
      tenant_action: :get_for_tenant_with_globals,
      master_load: [:site],
      tenant_load: [:site]
    )

  # ...then ActivityFeed.setup(socket, ...) — AFTER this call.
end

def handle_info({:expand_row, id}, socket),
  do: {:noreply, RuntimeStatusLive.expand(socket, id)}

def handle_async({:runtime_status_load, _id}, result, socket),
  do: {:noreply, RuntimeStatusLive.loaded(socket, result)}

setup/2 MUST run before ActivityFeed.setup/2: the feed attaches a hook that {:halt}s Oban broadcasts, and the realtime refresh here needs to see them first. tenant_action: nil omits the action: option for tenant reads (the resource's default tenant read), used by ErrorPage and Page.

Summary

Functions

Track the open row and load its status off the LiveView process.

Render the loaded record's status into the gervaz expanded row.

Re-load the open row, if any (used by realtime refresh paths).

Refresh the open row when an Ash notification targets it (instant feedback on active/precompile toggles, before the compile job's Oban event lands). Call from the page's existing resource-notification handle_info/2 clause.

Init expanded-row state and attach the realtime Oban refresh hook.

Functions

expand(socket, id)

Track the open row and load its status off the LiveView process.

loaded(socket, arg)

Render the loaded record's status into the gervaz expanded row.

refresh(socket)

Re-load the open row, if any (used by realtime refresh paths).

refresh_if_match(socket, notification)

Refresh the open row when an Ash notification targets it (instant feedback on active/precompile toggles, before the compile job's Oban event lands). Call from the page's existing resource-notification handle_info/2 clause.

setup(socket, opts)

Init expanded-row state and attach the realtime Oban refresh hook.