Commit d352b61a43
Verified · cmc ci/build: success ci/quality: success ci/test: success
Layout: unified · split
Changed files (11)
- internal/httpd/mractions.go +10 −2
- internal/httpd/page.go +15 −4
- internal/httpd/web.go +30 −3
- internal/httpd/webux_test.go added +98
- internal/web/static/style.css +102
- internal/web/templates/issue.html +12 −4
- internal/web/templates/issues.html +1
- internal/web/templates/layout.html +5
- internal/web/templates/mr.html +16 −4
- internal/web/templates/mrs.html +1
- internal/web/web.go +2
internal/httpd/mractions.go +10 −2
| @@ -42,15 +42,23 @@ func mrArgs(r *http.Request, verb string, extra ...string) []string { | ||
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | func (s *Server) mrReviewSubmit(w http.ResponseWriter, r *http.Request, u store.User) { |
| 45 | verdict := r.FormValue("verdict") | |
| 45 | 46 | flag := map[string]string{ |
| 46 | 47 | "approve": "--approve", |
| 47 | 48 | "request-changes": "--request-changes", |
| 48 | 49 | "comment": "--comment", |
| 49 | }[r.FormValue("verdict")] | |
| 50 | "discard": "--discard", | |
| 51 | }[verdict] | |
| 50 | 52 | if flag == "" { |
| 51 | s.mrRedirect(w, r, "pick approve, request changes, or comment") | |
| 53 | s.mrRedirect(w, r, "pick approve, request changes, comment, or discard") | |
| 52 | 54 | return |
| 53 | 55 | } |
| 56 | if body := strings.TrimSpace(r.FormValue("body")); body != "" && verdict != "discard" { | |
| 57 | if msg, code := s.runControlStdinCode(u, mrArgs(r, "comment", "--file", "-"), body); code != 0 { | |
| 58 | s.done(w, r, code, msg, s.mrRedirect) | |
| 59 | return | |
| 60 | } | |
| 61 | } | |
| 54 | 62 | _, msg, code := s.runControlCode(u, mrArgs(r, "review", flag)) |
| 55 | 63 | s.done(w, r, code, msg, s.mrRedirect) |
| 56 | 64 | } |
internal/httpd/page.go +15 −4
| @@ -6,11 +6,17 @@ import ( | ||
| 6 | 6 | "gitbay.org/gitbay/internal/store" |
| 7 | 7 | ) |
| 8 | 8 | |
| 9 | // rail is the viewer's cross-repo state the layout needs. The rail itself | |
| 10 | // is icons only, so what is left is the unread count on its bell; the | |
| 11 | // pinned repositories it used to list are rendered by the dashboard. | |
| 9 | // railPin is one pinned repository in the rail's quick switcher. | |
| 10 | type railPin struct { | |
| 11 | Owner string | |
| 12 | Name string | |
| 13 | } | |
| 14 | ||
| 15 | // rail is the viewer's cross-repo state the layout needs: the unread count | |
| 16 | // on the bell and pinned repositories for the quick switcher. | |
| 12 | 17 | type rail struct { |
| 13 | 18 | Unread int |
| 19 | Pins []railPin | |
| 14 | 20 | } |
| 15 | 21 | |
| 16 | 22 | // basePage is what the layout needs on every page, repo or not. Page |
| @@ -62,9 +68,14 @@ func (s *Server) baseFor(viewer store.User) basePage { | ||
| 62 | 68 | return b |
| 63 | 69 | } |
| 64 | 70 | |
| 65 | // railFor collects the viewer's unread count. | |
| 71 | // railFor collects the viewer's unread count and pinned repositories. | |
| 66 | 72 | func (s *Server) railFor(viewer store.User) rail { |
| 67 | 73 | var rl rail |
| 68 | 74 | rl.Unread = s.st.UnreadNotices(viewer.ID) |
| 75 | if pinned, err := s.st.PinnedRepos(viewer.ID); err == nil { | |
| 76 | for _, r := range pinned { | |
| 77 | rl.Pins = append(rl.Pins, railPin{Owner: r.OwnerName, Name: r.Name}) | |
| 78 | } | |
| 79 | } | |
| 69 | 80 | return rl |
| 70 | 81 | } |
internal/httpd/web.go +30 −3
| @@ -2134,6 +2134,7 @@ func (s *Server) issuePage(w http.ResponseWriter, r *http.Request, previewForm s | ||
| 2134 | 2134 | } |
| 2135 | 2135 | // nil readable: the picker lists titles, never the progress counts. |
| 2136 | 2136 | milestones, _ := s.st.ListMilestones(p.Repo, "open", nil) |
| 2137 | allLabels, _ := s.st.ListLabels(p.Repo, nil) | |
| 2137 | 2138 | bars := s.reactionBars(r, "issue", iss.ID, comments, fmt.Sprintf("/%s/%s/issues/%d/react", p.Repo.OwnerName, p.Repo.Name, iss.Number)) |
| 2138 | 2139 | s.render(w, "issue.html", struct { |
| 2139 | 2140 | repoPage |
| @@ -2143,13 +2144,29 @@ func (s *Server) issuePage(w http.ResponseWriter, r *http.Request, previewForm s | ||
| 2143 | 2144 | CanEdit bool |
| 2144 | 2145 | CanWrite bool |
| 2145 | 2146 | Milestones []store.Milestone |
| 2147 | AllLabels []store.Label | |
| 2148 | People []string | |
| 2146 | 2149 | Notice string |
| 2147 | 2150 | LabelColors map[string]template.CSS |
| 2148 | 2151 | Draft *draft |
| 2149 | 2152 | Reactions map[int64]reactionBar |
| 2150 | 2153 | }{p, iss, md(iss.Body, iss.BodyFormat), renderComments(comments, md), |
| 2151 | 2154 | s.canEditItem(r, p.Repo, iss.Author), s.canWriteRepo(r, p.Repo), |
| 2152 | milestones, s.takeFlash(w, r), s.labelColors(p.Repo), d, bars}) | |
| 2155 | milestones, allLabels, s.repoPeople(p.Repo), s.takeFlash(w, r), s.labelColors(p.Repo), d, bars}) | |
| 2156 | } | |
| 2157 | ||
| 2158 | // repoPeople returns the sorted usernames of accounts with access to repo, | |
| 2159 | // for assignee and reviewer pickers. | |
| 2160 | func (s *Server) repoPeople(repo store.Repo) []string { | |
| 2161 | entries, err := s.st.EffectiveAccess(repo.ID) | |
| 2162 | if err != nil { | |
| 2163 | return nil | |
| 2164 | } | |
| 2165 | out := make([]string, 0, len(entries)) | |
| 2166 | for _, e := range entries { | |
| 2167 | out = append(out, e.Username) | |
| 2168 | } | |
| 2169 | return out | |
| 2153 | 2170 | } |
| 2154 | 2171 | |
| 2155 | 2172 | // canEditItem: the author or anyone with write access may edit. |
| @@ -2307,6 +2324,12 @@ func (s *Server) mrPage(w http.ResponseWriter, r *http.Request, previewForm stri | ||
| 2307 | 2324 | // The viewer sees their own unsubmitted review comments and nobody |
| 2308 | 2325 | // else's. |
| 2309 | 2326 | diffComments, _ := s.st.ListDiffComments(m.ID, s.webViewer(r).ID) |
| 2327 | pendingComments := 0 | |
| 2328 | for _, cm := range diffComments { | |
| 2329 | if cm.Pending { | |
| 2330 | pendingComments++ | |
| 2331 | } | |
| 2332 | } | |
| 2310 | 2333 | |
| 2311 | 2334 | headRef := fmt.Sprintf("refs/merge-requests/%d/head", m.Number) |
| 2312 | 2335 | // An admin can prune the head ref; the diff is then unavailable, not |
| @@ -2441,6 +2464,7 @@ func (s *Server) mrPage(w http.ResponseWriter, r *http.Request, previewForm stri | ||
| 2441 | 2464 | d = s.draftFor(r, p.Repo, previewForm, "body", format) |
| 2442 | 2465 | } |
| 2443 | 2466 | bars := s.reactionBars(r, "mr", m.ID, comments, fmt.Sprintf("/%s/%s/mrs/%d/react", p.Repo.OwnerName, p.Repo.Name, m.Number)) |
| 2467 | allLabels, _ := s.st.ListLabels(p.Repo, nil) | |
| 2444 | 2468 | s.render(w, "mr.html", struct { |
| 2445 | 2469 | repoPage |
| 2446 | 2470 | MR store.MR |
| @@ -2459,6 +2483,7 @@ func (s *Server) mrPage(w http.ResponseWriter, r *http.Request, previewForm stri | ||
| 2459 | 2483 | CanEdit bool |
| 2460 | 2484 | CanWrite bool |
| 2461 | 2485 | Unresolved int |
| 2486 | PendingComments int | |
| 2462 | 2487 | Revisions []store.MRHead |
| 2463 | 2488 | Notice string |
| 2464 | 2489 | DetachedThreads []diffThread |
| @@ -2471,13 +2496,15 @@ func (s *Server) mrPage(w http.ResponseWriter, r *http.Request, previewForm stri | ||
| 2471 | 2496 | HeadPruned bool |
| 2472 | 2497 | Base string |
| 2473 | 2498 | LabelColors map[string]template.CSS |
| 2499 | AllLabels []store.Label | |
| 2500 | People []string | |
| 2474 | 2501 | Draft *draft |
| 2475 | 2502 | Layout diffLayout |
| 2476 | 2503 | Reactions map[int64]reactionBar |
| 2477 | 2504 | }{p, m, view, md(m.Body, m.BodyFormat), checks, combined, renderComments(comments, md), |
| 2478 | 2505 | reviewRows, files, diffTruncated, stat, commits, commitsTotal, branches, s.canEditItem(r, p.Repo, m.Author), |
| 2479 | canWrite, unresolved, revisions, s.takeFlash(w, r), detachedThreads, stackedOn, stacked, supersedes, gates, | |
| 2480 | sourceGone(p, m), headMerged, headPruned, base, s.labelColors(p.Repo), d, layout, bars}) | |
| 2506 | canWrite, unresolved, pendingComments, revisions, s.takeFlash(w, r), detachedThreads, stackedOn, stacked, supersedes, gates, | |
| 2507 | sourceGone(p, m), headMerged, headPruned, base, s.labelColors(p.Repo), allLabels, s.repoPeople(p.Repo), d, layout, bars}) | |
| 2481 | 2508 | } |
| 2482 | 2509 | |
| 2483 | 2510 | // sourceGone reports whether an MR's source branch no longer exists: the |
internal/httpd/webux_test.go added +98
| @@ -0,0 +1,98 @@ | ||
| 1 | package httpd | |
| 2 | ||
| 3 | import ( | |
| 4 | "net/http" | |
| 5 | "net/http/httptest" | |
| 6 | "net/url" | |
| 7 | "strings" | |
| 8 | "testing" | |
| 9 | ||
| 10 | "gitbay.org/gitbay/internal/config" | |
| 11 | "gitbay.org/gitbay/internal/store" | |
| 12 | ) | |
| 13 | ||
| 14 | func TestWebUXPickersStatebarAndRailPins(t *testing.T) { | |
| 15 | st, err := store.Open(":memory:") | |
| 16 | if err != nil { | |
| 17 | t.Fatal(err) | |
| 18 | } | |
| 19 | defer st.Close() | |
| 20 | if err := st.MigrateUp(); err != nil { | |
| 21 | t.Fatal(err) | |
| 22 | } | |
| 23 | uid, err := st.CreateUser("alice", false) | |
| 24 | if err != nil { | |
| 25 | t.Fatal(err) | |
| 26 | } | |
| 27 | repoID, err := st.CreateRepo("user", uid, "app", "public") | |
| 28 | if err != nil { | |
| 29 | t.Fatal(err) | |
| 30 | } | |
| 31 | repo, err := st.RepoByID(repoID) | |
| 32 | if err != nil { | |
| 33 | t.Fatal(err) | |
| 34 | } | |
| 35 | if err := st.PinRepo(uid, repoID); err != nil { | |
| 36 | t.Fatal(err) | |
| 37 | } | |
| 38 | if err := st.SetLabel(repo, "bug", "d73a4a"); err != nil { | |
| 39 | t.Fatal(err) | |
| 40 | } | |
| 41 | if _, err := st.CreateIssue(repoID, uid, "first bug", "body", "md"); err != nil { | |
| 42 | t.Fatal(err) | |
| 43 | } | |
| 44 | ||
| 45 | var cfg config.Config | |
| 46 | cfg.Server.Root = t.TempDir() | |
| 47 | cfg.Server.SiteURL = "https://forge.test" | |
| 48 | cfg.Web.Mode = "accounts" | |
| 49 | srv := New(cfg, st, nil) | |
| 50 | cookie := sessionCookieFor(t, srv, st, uid) | |
| 51 | h := srv.Handler() | |
| 52 | ||
| 53 | // Issues list carries quick statebar and rail pinned-repo switcher. | |
| 54 | req := httptest.NewRequest("GET", "/alice/app/issues", nil) | |
| 55 | req.AddCookie(cookie) | |
| 56 | rec := httptest.NewRecorder() | |
| 57 | h.ServeHTTP(rec, req) | |
| 58 | if rec.Code != http.StatusOK { | |
| 59 | t.Fatalf("GET /alice/app/issues: %d", rec.Code) | |
| 60 | } | |
| 61 | body := rec.Body.String() | |
| 62 | for _, want := range []string{`class="statebar"`, `class="railpins"`, `href="/alice/app"`} { | |
| 63 | if !strings.Contains(body, want) { | |
| 64 | t.Errorf("issues list missing %s", want) | |
| 65 | } | |
| 66 | } | |
| 67 | ||
| 68 | // Issue detail carries clickable label & assignee pickers and datalists. | |
| 69 | req = httptest.NewRequest("GET", "/alice/app/issues/1", nil) | |
| 70 | req.AddCookie(cookie) | |
| 71 | rec = httptest.NewRecorder() | |
| 72 | h.ServeHTTP(rec, req) | |
| 73 | if rec.Code != http.StatusOK { | |
| 74 | t.Fatalf("GET /alice/app/issues/1: %d", rec.Code) | |
| 75 | } | |
| 76 | body = rec.Body.String() | |
| 77 | for _, want := range []string{`id="repo-labels"`, `id="repo-people"`, `Pick labels`, `Pick assignees`, `class="picker-btn"`} { | |
| 78 | if !strings.Contains(body, want) { | |
| 79 | t.Errorf("issue page missing %s", want) | |
| 80 | } | |
| 81 | } | |
| 82 | ||
| 83 | // Clicking a picker button applies the label. | |
| 84 | form := url.Values{"add": {"bug"}} | |
| 85 | req = httptest.NewRequest("POST", "https://forge.test/alice/app/issues/1/label", strings.NewReader(form.Encode())) | |
| 86 | req.Header.Set("Content-Type", "application/x-www-form-urlencoded") | |
| 87 | req.Header.Set("Origin", "https://forge.test") | |
| 88 | req.AddCookie(cookie) | |
| 89 | rec = httptest.NewRecorder() | |
| 90 | h.ServeHTTP(rec, req) | |
| 91 | if rec.Code != http.StatusSeeOther { | |
| 92 | t.Fatalf("POST label: %d", rec.Code) | |
| 93 | } | |
| 94 | iss, err := st.IssueByNumber(repoID, 1) | |
| 95 | if err != nil || len(iss.Labels) != 1 || iss.Labels[0] != "bug" { | |
| 96 | t.Fatalf("labels after picker click: %+v err=%v", iss.Labels, err) | |
| 97 | } | |
| 98 | } | |
internal/web/static/style.css +102
| @@ -1959,3 +1959,105 @@ button.react, span.react { | ||
| 1959 | 1959 | button.react { cursor: pointer; } |
| 1960 | 1960 | button.react:hover { background: var(--surface); } |
| 1961 | 1961 | button.react.mine { border-color: var(--accent); background: var(--surface); color: var(--fg); } |
| 1962 | ||
| 1963 | /* ---- rail pinned switcher ---- */ | |
| 1964 | .railpins { position: relative; } | |
| 1965 | .railpins > summary { list-style: none; } | |
| 1966 | .railpins > summary::-webkit-details-marker { display: none; } | |
| 1967 | .railpins .raildrop { | |
| 1968 | left: calc(100% + var(--sp-1)); | |
| 1969 | top: 0; | |
| 1970 | bottom: auto; | |
| 1971 | min-width: 14rem; | |
| 1972 | } | |
| 1973 | .railpins .raildrop .none { display: block; padding: var(--sp-2) var(--sp-3); color: var(--muted); font-size: var(--fs-1); } | |
| 1974 | ||
| 1975 | /* ---- diff file jump-list ---- */ | |
| 1976 | .difftoc { | |
| 1977 | margin: var(--sp-3) 0; | |
| 1978 | border: 1px solid var(--faint); | |
| 1979 | border-radius: var(--r-card); | |
| 1980 | background: var(--surface); | |
| 1981 | } | |
| 1982 | .difftoc > summary { | |
| 1983 | cursor: pointer; | |
| 1984 | padding: var(--sp-2) var(--sp-3); | |
| 1985 | font-size: var(--fs-1); | |
| 1986 | font-weight: 600; | |
| 1987 | color: var(--fg); | |
| 1988 | } | |
| 1989 | .difftoc-list { | |
| 1990 | list-style: none; | |
| 1991 | margin: 0; | |
| 1992 | padding: 0 var(--sp-3) var(--sp-2); | |
| 1993 | display: flex; | |
| 1994 | flex-direction: column; | |
| 1995 | gap: var(--sp-1); | |
| 1996 | font-size: var(--fs-1); | |
| 1997 | font-family: var(--mono); | |
| 1998 | } | |
| 1999 | .difftoc-list li { | |
| 2000 | display: flex; | |
| 2001 | align-items: baseline; | |
| 2002 | gap: var(--sp-2); | |
| 2003 | } | |
| 2004 | .difftoc-list a { overflow-wrap: anywhere; } | |
| 2005 | .difftoc-list .fstat { margin-left: auto; white-space: nowrap; } | |
| 2006 | ||
| 2007 | /* ---- sidebar pickers & batched review ---- */ | |
| 2008 | .review-pending { | |
| 2009 | color: var(--warn); | |
| 2010 | font-weight: 600; | |
| 2011 | font-size: var(--fs-1); | |
| 2012 | } | |
| 2013 | .picker { margin: var(--sp-2) 0; } | |
| 2014 | .picker > summary { | |
| 2015 | cursor: pointer; | |
| 2016 | font-size: var(--fs-1); | |
| 2017 | color: var(--link); | |
| 2018 | } | |
| 2019 | .picker-list { | |
| 2020 | display: flex; | |
| 2021 | flex-wrap: wrap; | |
| 2022 | gap: var(--sp-1); | |
| 2023 | margin-top: var(--sp-2); | |
| 2024 | } | |
| 2025 | .picker-btn { | |
| 2026 | font: inherit; | |
| 2027 | font-size: var(--fs-0); | |
| 2028 | padding: 2px var(--sp-2); | |
| 2029 | border: 1px solid var(--line); | |
| 2030 | border-radius: var(--r-ctl); | |
| 2031 | background: var(--canvas); | |
| 2032 | color: var(--fg); | |
| 2033 | cursor: pointer; | |
| 2034 | } | |
| 2035 | .picker-btn:hover { background: var(--hover); } | |
| 2036 | .picker-btn[aria-pressed="true"] { | |
| 2037 | border-color: var(--link); | |
| 2038 | background: var(--surface); | |
| 2039 | font-weight: 600; | |
| 2040 | } | |
| 2041 | ||
| 2042 | /* ---- list quick state bar ---- */ | |
| 2043 | .statebar { | |
| 2044 | display: flex; | |
| 2045 | flex-wrap: wrap; | |
| 2046 | gap: var(--sp-2); | |
| 2047 | margin: 0 0 var(--sp-3); | |
| 2048 | } | |
| 2049 | .statebar a { | |
| 2050 | font-size: var(--fs-1); | |
| 2051 | padding: var(--sp-1) var(--sp-3); | |
| 2052 | border: 1px solid var(--faint); | |
| 2053 | border-radius: var(--r-ctl); | |
| 2054 | color: var(--muted); | |
| 2055 | text-decoration: none; | |
| 2056 | } | |
| 2057 | .statebar a:hover { background: var(--hover); color: var(--fg); } | |
| 2058 | .statebar a[aria-current="page"] { | |
| 2059 | border-color: var(--mark); | |
| 2060 | color: var(--fg); | |
| 2061 | font-weight: 600; | |
| 2062 | background: var(--surface); | |
| 2063 | } | |
internal/web/templates/issue.html +12 −4
| @@ -57,9 +57,13 @@ | ||
| 57 | 57 | {{if .Issue.Labels}}<p class="row">{{range .Issue.Labels}}<a class="chip label" style="{{index $.LabelColors .}}" href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/issues?label={{.}}">{{.}}</a> {{end}}</p> |
| 58 | 58 | {{else}}<p class="none">none yet</p>{{end}} |
| 59 | 59 | {{if .CanWrite}} |
| 60 | {{with field . "AllLabels"}}<details class="picker"><summary>Pick labels</summary> | |
| 61 | <div class="picker-list">{{range .}}<form method="post" action="{{$base}}/label" class="inline">{{if hasStr $.Issue.Labels .Name}}<input type="hidden" name="remove" value="{{.Name}}"><button type="submit" class="picker-btn" aria-pressed="true">{{.Name}} ×</button>{{else}}<input type="hidden" name="add" value="{{.Name}}"><button type="submit" class="picker-btn" aria-pressed="false">{{.Name}}</button>{{end}}</form>{{end}}</div> | |
| 62 | </details> | |
| 63 | <datalist id="repo-labels">{{range .}}<option value="{{.Name}}"></option>{{end}}</datalist>{{end}} | |
| 60 | 64 | <form method="post" action="{{$base}}/label" class="actions"> |
| 61 | <input type="text" name="add" aria-label="Add labels" autocomplete="off" spellcheck="false" placeholder="add, space-separated"> | |
| 62 | <input type="text" name="remove" aria-label="Remove labels" autocomplete="off" spellcheck="false" placeholder="remove"> | |
| 65 | <input type="text" name="add" aria-label="Add labels" list="repo-labels" autocomplete="off" spellcheck="false" placeholder="add, space-separated"> | |
| 66 | <input type="text" name="remove" aria-label="Remove labels" list="repo-labels" autocomplete="off" spellcheck="false" placeholder="remove"> | |
| 63 | 67 | <button type="submit" class="btn">Apply</button> |
| 64 | 68 | </form> |
| 65 | 69 | {{end}} |
| @@ -69,9 +73,13 @@ | ||
| 69 | 73 | {{if .Issue.Assignees}}<p class="row">{{range .Issue.Assignees}}<a href="/{{.}}">{{.}}</a> {{end}}</p> |
| 70 | 74 | {{else}}<p class="none">nobody yet</p>{{end}} |
| 71 | 75 | {{if .CanWrite}} |
| 76 | {{with field . "People"}}<details class="picker"><summary>Pick assignees</summary> | |
| 77 | <div class="picker-list">{{range .}}<form method="post" action="{{$base}}/assign" class="inline">{{if hasStr $.Issue.Assignees .}}<input type="hidden" name="remove" value="{{.}}"><button type="submit" class="picker-btn" aria-pressed="true">{{.}} ×</button>{{else}}<input type="hidden" name="add" value="{{.}}"><button type="submit" class="picker-btn" aria-pressed="false">{{.}}</button>{{end}}</form>{{end}}</div> | |
| 78 | </details> | |
| 79 | <datalist id="repo-people">{{range .}}<option value="{{.}}"></option>{{end}}</datalist>{{end}} | |
| 72 | 80 | <form method="post" action="{{$base}}/assign" class="actions"> |
| 73 | <input type="text" name="add" aria-label="Add assignees" autocomplete="off" spellcheck="false" placeholder="add, space-separated"> | |
| 74 | <input type="text" name="remove" aria-label="Remove assignees" autocomplete="off" spellcheck="false" placeholder="remove"> | |
| 81 | <input type="text" name="add" aria-label="Add assignees" list="repo-people" autocomplete="off" spellcheck="false" placeholder="add, space-separated"> | |
| 82 | <input type="text" name="remove" aria-label="Remove assignees" list="repo-people" autocomplete="off" spellcheck="false" placeholder="remove"> | |
| 75 | 83 | <button type="submit" class="btn">Apply</button> |
| 76 | 84 | </form> |
| 77 | 85 | {{end}} |
internal/web/templates/issues.html +1
| @@ -15,6 +15,7 @@ | ||
| 15 | 15 | <span class="spacer"></span> |
| 16 | 16 | <p class="meta"><a href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/milestones">milestones</a> · <a href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/labels">labels</a>{{if .Viewer}} · <a href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/issues/new">new issue</a>{{end}}</p> |
| 17 | 17 | </div> |
| 18 | {{if .Facets}}<nav class="statebar" aria-label="State">{{range (index .Facets 0).Items}}<a{{if .Active}} aria-current="page"{{end}} href="{{.Href}}">{{.Label}}</a>{{end}}</nav>{{end}} | |
| 18 | 19 | <ul class="issuelist rows"> |
| 19 | 20 | {{range .Issues}}<li> |
| 20 | 21 | <div class="issuemain"> |
internal/web/templates/layout.html +5
| @@ -25,6 +25,7 @@ | ||
| 25 | 25 | <li>{{template "raillink" dict "Href" "/explore" "Icon" "compass" "Name" "Explore" "Current" (eq (str . "Tab") "explore")}}</li> |
| 26 | 26 | <li>{{template "raillink" dict "Href" "/search" "Icon" "search" "Name" "Search" "Current" (eq (str . "Tab") "sitesearch")}}</li> |
| 27 | 27 | {{if .Viewer}}<li>{{template "raillink" dict "Href" "/notifications" "Icon" "bell" "Name" "Notifications" "Current" (eq (str . "Tab") "notifications") "Count" .Rail.Unread}}</li> |
| 28 | <li class="railopt"><details class="railpins"><summary class="railicon" aria-label="Pinned repositories" title="Pinned repositories">{{template "icon" "bookmark"}}<span class="vh">Pinned repositories</span></summary><div class="raildrop">{{range .Rail.Pins}}<a href="/{{.Owner}}/{{.Name}}">{{.Owner}}/{{.Name}}</a>{{else}}<span class="none">No pinned repos</span>{{end}}<a href="/{{.Viewer}}/-/repositories">All repositories →</a></div></details></li> | |
| 28 | 29 | <li class="railopt">{{template "raillink" (index $items 0)}}</li>{{end}} |
| 29 | 30 | </ul> |
| 30 | 31 | <span class="railgap"></span> |
| @@ -207,6 +208,10 @@ | ||
| 207 | 208 | neither and gets the same diff without review controls. */}} |
| 208 | 209 | {{define "difffiles"}}{{$base := .Base}}{{$viewer := .Viewer}}{{$L := .L}}{{$split := false}}{{with $L}}{{$split = .Split}}{{end}} |
| 209 | 210 | {{with $L}}{{if .UnifiedURL}}<p class="layoutpick">Layout: {{if .Split}}<a href="{{.UnifiedURL}}">unified</a> · <strong aria-current="true">split</strong>{{else}}<strong aria-current="true">unified</strong> · <a href="{{.SplitURL}}">split</a>{{end}}</p>{{end}}{{end}} |
| 211 | {{if gt (len .Files) 1}}<details class="difftoc" open> | |
| 212 | <summary>Changed files ({{len .Files}})</summary> | |
| 213 | <ul class="difftoc-list">{{range $fi, $f := .Files}}<li><a href="#f{{$fi}}">{{.Path}}</a>{{if ne .Status "modified"}} <span class="chip">{{.Status}}</span>{{end}} <span class="fstat">{{if .Adds}}<span class="add">+{{.Adds}}</span>{{end}}{{if .Dels}} <span class="del">−{{.Dels}}</span>{{end}}</span></li>{{end}}</ul> | |
| 214 | </details>{{end}} | |
| 210 | 215 | {{range $fi, $f := .Files}}<details class="difffold" id="f{{$fi}}"{{if .Open}} open{{end}}> |
| 211 | 216 | <summary> |
| 212 | 217 | <span class="fpath">{{if eq .Status "renamed"}}<span class="was">{{.OldPath}} →</span> {{end}}{{.Path}}</span> |
internal/web/templates/mr.html +16 −4
| @@ -89,9 +89,13 @@ | ||
| 89 | 89 | {{if and .CanWrite (or (eq .MR.State "open") (eq .MR.State "source_gone"))}} |
| 90 | 90 | <div class="grp"> |
| 91 | 91 | <h2>Review</h2> |
| 92 | {{$pc := field . "PendingComments"}}{{if $pc}}<p class="row review-pending">{{$pc}} pending diff comment{{if ne $pc 1}}s{{end}}</p>{{end}} | |
| 92 | 93 | <form method="post" action="{{$base}}/review" class="actions"> |
| 94 | <textarea name="body" aria-label="Review note" rows="2" placeholder="Optional review note"></textarea> | |
| 93 | 95 | <button type="submit" name="verdict" value="approve" class="btn">Approve</button> |
| 94 | 96 | <button type="submit" name="verdict" value="request-changes" class="btn">Request changes</button> |
| 97 | {{if $pc}}<button type="submit" name="verdict" value="comment" class="btn">Submit comments</button> | |
| 98 | <button type="submit" name="verdict" value="discard" class="danger">Discard pending</button>{{end}} | |
| 95 | 99 | </form> |
| 96 | 100 | </div> |
| 97 | 101 | <div class="grp"> |
| @@ -161,9 +165,13 @@ | ||
| 161 | 165 | {{if .MR.ReviewRequests}}<p class="row">{{range .MR.ReviewRequests}}<a href="/{{.}}">{{.}}</a> {{end}}</p> |
| 162 | 166 | {{else}}<p class="none">no reviewers</p>{{end}} |
| 163 | 167 | {{if and .CanWrite (or (eq .MR.State "open") (eq .MR.State "source_gone"))}} |
| 168 | {{with field . "People"}}<details class="picker"><summary>Pick reviewers</summary> | |
| 169 | <div class="picker-list">{{range .}}<form method="post" action="{{$base}}/review-request" class="inline">{{if hasStr $.MR.ReviewRequests .}}<input type="hidden" name="remove" value="{{.}}"><button type="submit" class="picker-btn" aria-pressed="true">{{.}} ×</button>{{else}}<input type="hidden" name="add" value="{{.}}"><button type="submit" class="picker-btn" aria-pressed="false">{{.}}</button>{{end}}</form>{{end}}</div> | |
| 170 | </details> | |
| 171 | <datalist id="repo-people">{{range .}}<option value="{{.}}"></option>{{end}}</datalist>{{end}} | |
| 164 | 172 | <form method="post" action="{{$base}}/review-request" class="actions"> |
| 165 | <input type="text" name="add" aria-label="Add reviewers" autocomplete="off" spellcheck="false" placeholder="add, space-separated"> | |
| 166 | <input type="text" name="remove" aria-label="Remove reviewers" autocomplete="off" spellcheck="false" placeholder="remove"> | |
| 173 | <input type="text" name="add" aria-label="Add reviewers" list="repo-people" autocomplete="off" spellcheck="false" placeholder="add, space-separated"> | |
| 174 | <input type="text" name="remove" aria-label="Remove reviewers" list="repo-people" autocomplete="off" spellcheck="false" placeholder="remove"> | |
| 167 | 175 | <button type="submit" class="btn">Apply</button> |
| 168 | 176 | </form> |
| 169 | 177 | {{end}} |
| @@ -192,9 +200,13 @@ | ||
| 192 | 200 | {{if .MR.Labels}}<p class="row">{{range .MR.Labels}}<a class="chip label" style="{{index $.LabelColors .}}" href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/mrs?label={{.}}">{{.}}</a> {{end}}</p> |
| 193 | 201 | {{else}}<p class="none">{{if or (eq .MR.State "merged") (eq .MR.State "closed")}}no labels{{else}}none yet{{end}}</p>{{end}} |
| 194 | 202 | {{if .CanWrite}} |
| 203 | {{with field . "AllLabels"}}<details class="picker"><summary>Pick labels</summary> | |
| 204 | <div class="picker-list">{{range .}}<form method="post" action="{{$base}}/label" class="inline">{{if hasStr $.MR.Labels .Name}}<input type="hidden" name="remove" value="{{.Name}}"><button type="submit" class="picker-btn" aria-pressed="true">{{.Name}} ×</button>{{else}}<input type="hidden" name="add" value="{{.Name}}"><button type="submit" class="picker-btn" aria-pressed="false">{{.Name}}</button>{{end}}</form>{{end}}</div> | |
| 205 | </details> | |
| 206 | <datalist id="repo-labels">{{range .}}<option value="{{.Name}}"></option>{{end}}</datalist>{{end}} | |
| 195 | 207 | <form method="post" action="{{$base}}/label" class="actions"> |
| 196 | <input type="text" name="add" aria-label="Add labels" autocomplete="off" spellcheck="false" placeholder="add, space-separated"> | |
| 197 | <input type="text" name="remove" aria-label="Remove labels" autocomplete="off" spellcheck="false" placeholder="remove"> | |
| 208 | <input type="text" name="add" aria-label="Add labels" list="repo-labels" autocomplete="off" spellcheck="false" placeholder="add, space-separated"> | |
| 209 | <input type="text" name="remove" aria-label="Remove labels" list="repo-labels" autocomplete="off" spellcheck="false" placeholder="remove"> | |
| 198 | 210 | <button type="submit" class="btn">Apply</button> |
| 199 | 211 | </form> |
| 200 | 212 | {{end}} |
internal/web/templates/mrs.html +1
| @@ -16,6 +16,7 @@ | ||
| 16 | 16 | {{if .CanOpenMR}}<p class="meta"><a href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/mrs/new">New merge request</a></p> |
| 17 | 17 | {{else if .Viewer}}<p class="meta"><a href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/fork">Fork this repository to propose a change</a></p> |
| 18 | 18 | {{else}}<p class="meta"><a href="/login">Sign in to propose a change</a></p>{{end}} |
| 19 | {{if .Facets}}<nav class="statebar" aria-label="State">{{range (index .Facets 0).Items}}<a{{if .Active}} aria-current="page"{{end}} href="{{.Href}}">{{.Label}}</a>{{end}}</nav>{{end}} | |
| 19 | 20 | <ul class="issuelist rows"> |
| 20 | 21 | {{range .MRs}}{{$n := .Number}}<li> |
| 21 | 22 | <div class="issuemain"> |
internal/web/web.go +2
| @@ -9,6 +9,7 @@ import ( | ||
| 9 | 9 | "io" |
| 10 | 10 | "io/fs" |
| 11 | 11 | "reflect" |
| 12 | "slices" | |
| 12 | 13 | "sort" |
| 13 | 14 | "strconv" |
| 14 | 15 | "strings" |
| @@ -97,6 +98,7 @@ func railOptItems(v any) []railItem { | ||
| 97 | 98 | var funcs = template.FuncMap{ |
| 98 | 99 | "styleVersion": func() string { return StyleVersion }, |
| 99 | 100 | "join": strings.Join, |
| 101 | "hasStr": slices.Contains[[]string, string], | |
| 100 | 102 | // paragraphs splits plain text on blank lines for safe rich display. |
| 101 | 103 | "paragraphs": func(s string) []string { |
| 102 | 104 | var out []string |