package web
import (
"context"
"net/url"
"sourcecraft.dev/bigbes/sr-ht-dolt/beads"
"sourcecraft.dev/bigbes/sr-ht-dolt/browse"
"sourcecraft.dev/bigbes/sr-ht-dolt/core"
)
// beadsView renders a "beads" (bd) issue database as a Mardi Gras parade board:
// four lanes of cards (Rolling / Lined Up / Stalled / Past Stand) plus a
// per-issue detail pane reachable via ?issue=<id>. All data is read through the
// BrowseSession surface (Rows/Tables) — there is no SQL engine behind it.
//
// The reading itself is not here: the fingerprint, the lane bucketing, the ready
// rule and the whole view model live in the beads package, which the MCP surface
// shares. This type is only the View adapter — slug, label, template, and the
// hand-off of the request's ref and query.
type beadsView struct{}
func init() { RegisterView(&beadsView{}) }
func (*beadsView) Name() string { return "beads" }
func (*beadsView) Label() string { return "Beads" }
func (*beadsView) Template() string { return "beads.html" }
// Applies fingerprints a beads DB; see beads.Applies for the rule.
func (*beadsView) Applies(tables []browse.TableInfo) bool { return beads.Applies(tables) }
// Build reads the issue graph and produces either the board or, when ?issue=
// names an issue, that issue's detail pane. The result is a *beads.BeadsData,
// handed to beads.html as its .Data.
func (*beadsView) Build(ctx context.Context, sess BrowseSession, _ *core.Repo, ref string, query url.Values) (any, error) {
data, err := beads.Build(ctx, sess, ref, query)
if err != nil {
return nil, err
}
return data, nil
}