~bigbes/sr-ht-dolt

ref: 35875ff76df1efe232d436a3041a8e621cdab418 sr-ht-dolt/web/milestones.go -rw-r--r-- 1.4 KiB
35875ff7 — Eugene Blikh web: stop printing store paths to the owner 5 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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"
)

// milestonesView groups a beads issue DB by its "milestone:<name>" labels and
// shows per-milestone progress with the issues under each. It shares the beads
// fingerprint, so it appears as a companion tab wherever the Beads view does.
// The grouping itself lives in the beads package; this type is the View adapter.
type milestonesView struct{}

func (*milestonesView) Name() string     { return "milestones" }
func (*milestonesView) Label() string    { return "Milestones" }
func (*milestonesView) Template() string { return "milestones.html" }

// Applies mirrors the beads fingerprint so Milestones and Beads pair up. A
// beads DB that happens to use no milestone labels still gets the tab; it just
// renders an empty state.
func (*milestonesView) Applies(tables []browse.TableInfo) bool { return beads.Applies(tables) }

// Build groups the issues by milestone label; the result is a
// *beads.MilestoneView, handed to milestones.html as its .Data. The view takes
// no query parameters — the board is where filtering happens.
func (*milestonesView) Build(ctx context.Context, sess BrowseSession, _ *core.Repo, ref string, _ url.Values) (any, error) {
	data, err := beads.BuildMilestones(ctx, sess, ref)
	if err != nil {
		return nil, err
	}
	return data, nil
}