feat: maak de merge-requestlijst gelijk aan GitLab
Tabs met tellers, zoeken, sorteren en een rij met titel, nummer, statusbadge en bijwerktijd. De issuelijst gebruikt dezelfde opbouw. Co-authored-by: tim <tim@timfalken.com>
@@ -0,0 +1,76 @@
1
package i18n
2
3
func init() {
4
addCatalog(en, listEN)
5
addCatalog(nl, listNL)
6
addCatalog(de, listDE)
7
addCatalog(fr, listFR)
8
}
9
10
var listEN = map[string]string{
11
"list.tabs": "Status",
12
"list.search": "Search or filter results...",
13
"list.sort": "Sort",
14
"list.sort.created": "Created date",
15
"list.sort.updated": "Updated date",
16
"list.sort.asc": "Oldest first",
17
"list.sort.desc": "Newest first",
18
"list.created": "created %s",
19
"list.by": "by",
20
"list.updated": "updated %s",
21
"list.merged": "Merged",
22
"list.newMR": "New merge request",
23
"list.comment": "%d comment",
24
"list.comments": "%d comments",
25
}
26
27
var listNL = map[string]string{
28
"list.tabs": "Status",
29
"list.search": "Zoek of filter resultaten...",
30
"list.sort": "Sorteren",
31
"list.sort.created": "Aanmaakdatum",
32
"list.sort.updated": "Bijgewerkt",
33
"list.sort.asc": "Oudste eerst",
34
"list.sort.desc": "Nieuwste eerst",
35
"list.created": "aangemaakt %s",
36
"list.by": "door",
37
"list.updated": "bijgewerkt %s",
38
"list.merged": "Gemerged",
39
"list.newMR": "Nieuwe merge request",
40
"list.comment": "%d reactie",
41
"list.comments": "%d reacties",
42
}
43
44
var listDE = map[string]string{
45
"list.tabs": "Status",
46
"list.search": "Suchen oder filtern...",
47
"list.sort": "Sortieren",
48
"list.sort.created": "Erstellungsdatum",
49
"list.sort.updated": "Aktualisiert",
50
"list.sort.asc": "Älteste zuerst",
51
"list.sort.desc": "Neueste zuerst",
52
"list.created": "erstellt %s",
53
"list.by": "von",
54
"list.updated": "aktualisiert %s",
55
"list.merged": "Zusammengeführt",
56
"list.newMR": "Neue Merge Request",
57
"list.comment": "%d Kommentar",
58
"list.comments": "%d Kommentare",
59
}
60
61
var listFR = map[string]string{
62
"list.tabs": "Statut",
63
"list.search": "Rechercher ou filtrer...",
64
"list.sort": "Trier",
65
"list.sort.created": "Date de création",
66
"list.sort.updated": "Mise à jour",
67
"list.sort.asc": "Plus anciennes d'abord",
68
"list.sort.desc": "Plus récentes d'abord",
69
"list.created": "créé %s",
70
"list.by": "par",
71
"list.updated": "mise à jour %s",
72
"list.merged": "Fusionnée",
73
"list.newMR": "Nouvelle merge request",
74
"list.comment": "%d commentaire",
75
"list.comments": "%d commentaires",
76
}
@@ -0,0 +1,76 @@1
package i18n2
3
func init() {4
addCatalog(en, listEN)5
addCatalog(nl, listNL)6
addCatalog(de, listDE)7
addCatalog(fr, listFR)8
}9
10
var listEN = map[string]string{11
"list.tabs": "Status",12
"list.search": "Search or filter results...",13
"list.sort": "Sort",14
"list.sort.created": "Created date",15
"list.sort.updated": "Updated date",16
"list.sort.asc": "Oldest first",17
"list.sort.desc": "Newest first",18
"list.created": "created %s",19
"list.by": "by",20
"list.updated": "updated %s",21
"list.merged": "Merged",22
"list.newMR": "New merge request",23
"list.comment": "%d comment",24
"list.comments": "%d comments",25
}26
27
var listNL = map[string]string{28
"list.tabs": "Status",29
"list.search": "Zoek of filter resultaten...",30
"list.sort": "Sorteren",31
"list.sort.created": "Aanmaakdatum",32
"list.sort.updated": "Bijgewerkt",33
"list.sort.asc": "Oudste eerst",34
"list.sort.desc": "Nieuwste eerst",35
"list.created": "aangemaakt %s",36
"list.by": "door",37
"list.updated": "bijgewerkt %s",38
"list.merged": "Gemerged",39
"list.newMR": "Nieuwe merge request",40
"list.comment": "%d reactie",41
"list.comments": "%d reacties",42
}43
44
var listDE = map[string]string{45
"list.tabs": "Status",46
"list.search": "Suchen oder filtern...",47
"list.sort": "Sortieren",48
"list.sort.created": "Erstellungsdatum",49
"list.sort.updated": "Aktualisiert",50
"list.sort.asc": "Älteste zuerst",51
"list.sort.desc": "Neueste zuerst",52
"list.created": "erstellt %s",53
"list.by": "von",54
"list.updated": "aktualisiert %s",55
"list.merged": "Zusammengeführt",56
"list.newMR": "Neue Merge Request",57
"list.comment": "%d Kommentar",58
"list.comments": "%d Kommentare",59
}60
61
var listFR = map[string]string{62
"list.tabs": "Statut",63
"list.search": "Rechercher ou filtrer...",64
"list.sort": "Trier",65
"list.sort.created": "Date de création",66
"list.sort.updated": "Mise à jour",67
"list.sort.asc": "Plus anciennes d'abord",68
"list.sort.desc": "Plus récentes d'abord",69
"list.created": "créé %s",70
"list.by": "par",71
"list.updated": "mise à jour %s",72
"list.merged": "Fusionnée",73
"list.newMR": "Nouvelle merge request",74
"list.comment": "%d commentaire",75
"list.comments": "%d commentaires",76
}@@ -0,0 +1,391 @@
1
package server
2
3
import (
4
"net/http"
5
"net/url"
6
"sort"
7
"strconv"
8
"strings"
9
"time"
10
11
"gitlab.com/Timfa/bluegit/internal/access"
12
"gitlab.com/Timfa/bluegit/internal/i18n"
13
"gitlab.com/Timfa/bluegit/internal/store"
14
)
15
16
// FlowBoard is de lijst van merge requests of issues, in de opbouw van GitLab.
17
type FlowBoard struct {
18
Base string
19
Query string
20
Sort string
21
Dir string
22
State string
23
FlipHref string
24
CanNew bool
25
NewHref string
26
NewKey string
27
EmptyKey string
28
Filters bool
29
Label string
30
Assignee string
31
Labels []IssueChoice
32
People []IssueChoice
33
Tabs []FlowTab
34
Rows []FlowRow
35
}
36
37
// FlowTab is één statusfilter met een teller.
38
type FlowTab struct {
39
Href string
40
Key string
41
Count int
42
On bool
43
}
44
45
// FlowRow is één regel in die lijst.
46
type FlowRow struct {
47
Href string
48
Title string
49
Ref string
50
State string
51
StateLabel string
52
Created string
53
Updated string
54
Author string
55
AuthorURL string
56
Target string
57
Comments int
58
PipeStatus string
59
PipeLabel string
60
PipeHref string
61
Draft bool
62
Confidential bool
63
Labels []store.Label
64
Extra string
65
}
66
67
type flowPerson struct {
68
Name string
69
URL string
70
}
71
72
func (s *Server) flowMRs(r *http.Request, repo store.Repo, role access.Role, all []store.MergeRequest) *FlowBoard {
73
q := strings.TrimSpace(r.URL.Query().Get("q"))
74
sortKey := flowSortKey(r.URL.Query().Get("sort"))
75
dir := flowDirKey(r.URL.Query().Get("dir"))
76
state := flowStateKey(r.URL.Query().Get("state"), true)
77
base := "/" + repo.FullPath() + "/-/merge-requests"
78
people := map[string]flowPerson{}
79
80
var matched []store.MergeRequest
81
openN, mergedN, closedN := 0, 0, 0
82
for _, mr := range all {
83
name, _ := s.flowAuthor(r, mr.Author, people)
84
if !flowHit(q, mr.Title, mr.Description, strconv.FormatInt(mr.Number, 10), "!"+strconv.FormatInt(mr.Number, 10), mr.Author, name, mr.SourceBranch, mr.TargetBranch) {
85
continue
86
}
87
matched = append(matched, mr)
88
switch mr.Status {
89
case "merged":
90
mergedN++
91
case "closed":
92
closedN++
93
default:
94
openN++
95
}
96
}
97
var shown []store.MergeRequest
98
for _, mr := range matched {
99
if state == "all" || mr.Status == state || (state == "open" && mr.Status != "merged" && mr.Status != "closed") {
100
shown = append(shown, mr)
101
}
102
}
103
sortFlow(shown, sortKey, dir, func(i int) (time.Time, time.Time, int64) {
104
return shown[i].CreatedAt, shown[i].UpdatedAt, shown[i].Number
105
})
106
107
rows := make([]FlowRow, 0, len(shown))
108
for _, mr := range shown {
109
name, href := s.flowAuthor(r, mr.Author, people)
110
row := FlowRow{
111
Href: base + "/" + strconv.FormatInt(mr.Number, 10),
112
Title: mr.Title,
113
Ref: "!" + strconv.FormatInt(mr.Number, 10),
114
State: flowBadge(mr.Status),
115
StateLabel: s.flowStateLabel(r, mr.Status),
116
Created: s.ago(r, mr.CreatedAt),
117
Updated: s.ago(r, mr.UpdatedAt),
118
Author: name,
119
AuthorURL: href,
120
Draft: mr.Draft,
121
}
122
if row.State == "open" {
123
row.Target = mr.TargetBranch
124
if notes, err := s.Store.ListNotes(r.Context(), mr.ID); err == nil {
125
row.Comments = len(notes)
126
}
127
s.attachFlowPipe(r, repo, mr, &row)
128
}
129
rows = append(rows, row)
130
}
131
board := &FlowBoard{
132
Base: base, Query: q, Sort: sortKey, Dir: dir, State: state,
133
FlipHref: flowHref(base, state, q, sortKey, flipDir(dir), "", ""),
134
CanNew: role.CanWriteCode(),
135
NewHref: base + "/new",
136
NewKey: "list.newMR",
137
EmptyKey: "mr.none",
138
Rows: rows,
139
}
140
board.Tabs = []FlowTab{
141
{Href: flowHref(base, "open", q, sortKey, dir, "", ""), Key: "issue.open", Count: openN, On: state == "open"},
142
{Href: flowHref(base, "merged", q, sortKey, dir, "", ""), Key: "list.merged", Count: mergedN, On: state == "merged"},
143
{Href: flowHref(base, "closed", q, sortKey, dir, "", ""), Key: "issue.closed", Count: closedN, On: state == "closed"},
144
{Href: flowHref(base, "all", q, sortKey, dir, "", ""), Key: "issue.all", Count: openN + mergedN + closedN, On: state == "all"},
145
}
146
return board
147
}
148
149
func (s *Server) flowIssues(r *http.Request, repo store.Repo, b *IssueBoard, all []store.Issue) *FlowBoard {
150
q := b.Query
151
sortKey := flowSortKey(r.URL.Query().Get("sort"))
152
dir := flowDirKey(r.URL.Query().Get("dir"))
153
state := flowStateKey(r.URL.Query().Get("state"), false)
154
base := "/" + repo.FullPath() + "/-/issues"
155
people := map[string]flowPerson{}
156
157
var matched []store.Issue
158
openN, closedN := 0, 0
159
for _, iss := range all {
160
name, _ := s.flowAuthor(r, iss.Author, people)
161
bits := append(issueSearchBits(iss), name)
162
if !flowHit(q, bits...) {
163
continue
164
}
165
matched = append(matched, iss)
166
if iss.Status == "closed" {
167
closedN++
168
} else {
169
openN++
170
}
171
}
172
var shown []store.Issue
173
for _, iss := range matched {
174
if state == "all" || iss.Status == state || (state == "open" && iss.Status != "closed") {
175
shown = append(shown, iss)
176
}
177
}
178
sortFlow(shown, sortKey, dir, func(i int) (time.Time, time.Time, int64) {
179
return shown[i].CreatedAt, shown[i].UpdatedAt, shown[i].Number
180
})
181
182
rows := make([]FlowRow, 0, len(shown))
183
for _, iss := range shown {
184
name, href := s.flowAuthor(r, iss.Author, people)
185
extra := strings.Join(iss.Assignees, ", ")
186
if iss.Milestone != "" {
187
if extra != "" {
188
extra += " · "
189
}
190
extra += iss.Milestone
191
}
192
row := FlowRow{
193
Href: base + "/" + strconv.FormatInt(iss.Number, 10),
194
Title: iss.Title,
195
Ref: "#" + strconv.FormatInt(iss.Number, 10),
196
State: flowBadge(iss.Status),
197
StateLabel: s.flowStateLabel(r, iss.Status),
198
Created: s.ago(r, iss.CreatedAt),
199
Updated: s.ago(r, iss.UpdatedAt),
200
Author: name,
201
AuthorURL: href,
202
Confidential: iss.Confidential,
203
Labels: iss.Labels,
204
Extra: extra,
205
}
206
if row.State == "open" {
207
if notes, err := s.Store.ListIssueNotes(r.Context(), iss.ID); err == nil {
208
row.Comments = len(notes)
209
}
210
}
211
rows = append(rows, row)
212
}
213
return &FlowBoard{
214
Base: base, Query: q, Sort: sortKey, Dir: dir, State: state,
215
FlipHref: flowHref(base, state, q, sortKey, flipDir(dir), b.Label, b.Assignee),
216
CanNew: b.CanCreate,
217
NewHref: base + "/new",
218
NewKey: "issue.new",
219
EmptyKey: "issue.none",
220
Filters: true,
221
Label: b.Label,
222
Assignee: b.Assignee,
223
Labels: b.Labels,
224
People: b.People,
225
Rows: rows,
226
Tabs: []FlowTab{
227
{Href: flowHref(base, "open", q, sortKey, dir, b.Label, b.Assignee), Key: "issue.open", Count: openN, On: state == "open"},
228
{Href: flowHref(base, "closed", q, sortKey, dir, b.Label, b.Assignee), Key: "issue.closed", Count: closedN, On: state == "closed"},
229
{Href: flowHref(base, "all", q, sortKey, dir, b.Label, b.Assignee), Key: "issue.all", Count: openN + closedN, On: state == "all"},
230
},
231
}
232
}
233
234
func (s *Server) attachFlowPipe(r *http.Request, repo store.Repo, mr store.MergeRequest, row *FlowRow) {
235
p, err := s.Store.LatestMergePipeline(r.Context(), repo.ID, mr.ID)
236
if err != nil {
237
return
238
}
239
jobs, _ := s.Store.JobsByPipeline(r.Context(), p.ID)
240
st := displayStatus(p.Status, jobs)
241
row.PipeStatus = st
242
row.PipeLabel = s.tr(r, "pipe."+st)
243
row.PipeHref = "/" + repo.FullPath() + "/-/pipelines/" + strconv.FormatInt(p.ID, 10)
244
}
245
246
func (s *Server) flowAuthor(r *http.Request, username string, cache map[string]flowPerson) (string, string) {
247
username = strings.TrimSpace(username)
248
if username == "" {
249
return "", ""
250
}
251
if p, ok := cache[username]; ok {
252
return p.Name, p.URL
253
}
254
p := flowPerson{Name: username}
255
if u, err := s.Store.UserByUsername(r.Context(), username); err == nil && u.ID != 0 {
256
if name := strings.TrimSpace(u.DisplayName); name != "" {
257
p.Name = name
258
} else {
259
p.Name = u.Username
260
}
261
p.URL = "/users/" + u.Username
262
}
263
cache[username] = p
264
return p.Name, p.URL
265
}
266
267
func (s *Server) flowStateLabel(r *http.Request, status string) string {
268
switch status {
269
case "merged":
270
return s.tr(r, "list.merged")
271
case "closed":
272
return s.tr(r, "issue.closed")
273
default:
274
return s.tr(r, "issue.open")
275
}
276
}
277
278
func (s *Server) ago(r *http.Request, t time.Time) string {
279
if t.IsZero() {
280
return ""
281
}
282
return i18n.Ago(s.langOf(r), t.Unix())
283
}
284
285
func issueSearchBits(iss store.Issue) []string {
286
bits := []string{iss.Title, iss.Description, strconv.FormatInt(iss.Number, 10), "#" + strconv.FormatInt(iss.Number, 10), iss.Author, iss.Milestone}
287
bits = append(bits, iss.Assignees...)
288
for _, l := range iss.Labels {
289
bits = append(bits, l.Name)
290
}
291
return bits
292
}
293
294
func flowHit(q string, parts ...string) bool {
295
q = strings.ToLower(strings.TrimSpace(q))
296
if q == "" {
297
return true
298
}
299
q = strings.TrimPrefix(q, "!")
300
q = strings.TrimPrefix(q, "#")
301
for _, p := range parts {
302
if strings.Contains(strings.ToLower(p), q) {
303
return true
304
}
305
}
306
return false
307
}
308
309
func flowSortKey(raw string) string {
310
if raw == "updated" {
311
return "updated"
312
}
313
return "created"
314
}
315
316
func flowDirKey(raw string) string {
317
if raw == "asc" {
318
return "asc"
319
}
320
return "desc"
321
}
322
323
func flipDir(dir string) string {
324
if dir == "asc" {
325
return "desc"
326
}
327
return "asc"
328
}
329
330
func flowStateKey(raw string, merged bool) string {
331
switch raw {
332
case "closed", "all":
333
return raw
334
case "merged":
335
if merged {
336
return "merged"
337
}
338
}
339
return "open"
340
}
341
342
func flowBadge(status string) string {
343
switch status {
344
case "merged", "closed":
345
return status
346
default:
347
return "open"
348
}
349
}
350
351
func flowHref(base, state, q, sortKey, dir, label, assignee string) string {
352
v := url.Values{}
353
v.Set("state", state)
354
if strings.TrimSpace(q) != "" {
355
v.Set("q", q)
356
}
357
if sortKey == "updated" {
358
v.Set("sort", "updated")
359
}
360
if dir == "asc" {
361
v.Set("dir", "asc")
362
}
363
if label != "" {
364
v.Set("label", label)
365
}
366
if assignee != "" {
367
v.Set("assignee", assignee)
368
}
369
return base + "?" + v.Encode()
370
}
371
372
func sortFlow[T any](rows []T, sortKey, dir string, at func(i int) (created, updated time.Time, number int64)) {
373
sort.SliceStable(rows, func(i, j int) bool {
374
ac, au, an := at(i)
375
bc, bu, bn := at(j)
376
a, b := ac, bc
377
if sortKey == "updated" {
378
a, b = au, bu
379
}
380
if dir == "asc" {
381
if a.Equal(b) {
382
return an < bn
383
}
384
return a.Before(b)
385
}
386
if a.Equal(b) {
387
return an > bn
388
}
389
return a.After(b)
390
})
391
}
@@ -0,0 +1,391 @@1
package server2
3
import (4
"net/http"5
"net/url"6
"sort"7
"strconv"8
"strings"9
"time"10
11
"gitlab.com/Timfa/bluegit/internal/access"12
"gitlab.com/Timfa/bluegit/internal/i18n"13
"gitlab.com/Timfa/bluegit/internal/store"14
)15
16
// FlowBoard is de lijst van merge requests of issues, in de opbouw van GitLab.17
type FlowBoard struct {18
Base string19
Query string20
Sort string21
Dir string22
State string23
FlipHref string24
CanNew bool25
NewHref string26
NewKey string27
EmptyKey string28
Filters bool29
Label string30
Assignee string31
Labels []IssueChoice32
People []IssueChoice33
Tabs []FlowTab34
Rows []FlowRow35
}36
37
// FlowTab is één statusfilter met een teller.38
type FlowTab struct {39
Href string40
Key string41
Count int42
On bool43
}44
45
// FlowRow is één regel in die lijst.46
type FlowRow struct {47
Href string48
Title string49
Ref string50
State string51
StateLabel string52
Created string53
Updated string54
Author string55
AuthorURL string56
Target string57
Comments int58
PipeStatus string59
PipeLabel string60
PipeHref string61
Draft bool62
Confidential bool63
Labels []store.Label64
Extra string65
}66
67
type flowPerson struct {68
Name string69
URL string70
}71
72
func (s *Server) flowMRs(r *http.Request, repo store.Repo, role access.Role, all []store.MergeRequest) *FlowBoard {73
q := strings.TrimSpace(r.URL.Query().Get("q"))74
sortKey := flowSortKey(r.URL.Query().Get("sort"))75
dir := flowDirKey(r.URL.Query().Get("dir"))76
state := flowStateKey(r.URL.Query().Get("state"), true)77
base := "/" + repo.FullPath() + "/-/merge-requests"78
people := map[string]flowPerson{}79
80
var matched []store.MergeRequest81
openN, mergedN, closedN := 0, 0, 082
for _, mr := range all {83
name, _ := s.flowAuthor(r, mr.Author, people)84
if !flowHit(q, mr.Title, mr.Description, strconv.FormatInt(mr.Number, 10), "!"+strconv.FormatInt(mr.Number, 10), mr.Author, name, mr.SourceBranch, mr.TargetBranch) {85
continue86
}87
matched = append(matched, mr)88
switch mr.Status {89
case "merged":90
mergedN++91
case "closed":92
closedN++93
default:94
openN++95
}96
}97
var shown []store.MergeRequest98
for _, mr := range matched {99
if state == "all" || mr.Status == state || (state == "open" && mr.Status != "merged" && mr.Status != "closed") {100
shown = append(shown, mr)101
}102
}103
sortFlow(shown, sortKey, dir, func(i int) (time.Time, time.Time, int64) {104
return shown[i].CreatedAt, shown[i].UpdatedAt, shown[i].Number105
})106
107
rows := make([]FlowRow, 0, len(shown))108
for _, mr := range shown {109
name, href := s.flowAuthor(r, mr.Author, people)110
row := FlowRow{111
Href: base + "/" + strconv.FormatInt(mr.Number, 10),112
Title: mr.Title,113
Ref: "!" + strconv.FormatInt(mr.Number, 10),114
State: flowBadge(mr.Status),115
StateLabel: s.flowStateLabel(r, mr.Status),116
Created: s.ago(r, mr.CreatedAt),117
Updated: s.ago(r, mr.UpdatedAt),118
Author: name,119
AuthorURL: href,120
Draft: mr.Draft,121
}122
if row.State == "open" {123
row.Target = mr.TargetBranch124
if notes, err := s.Store.ListNotes(r.Context(), mr.ID); err == nil {125
row.Comments = len(notes)126
}127
s.attachFlowPipe(r, repo, mr, &row)128
}129
rows = append(rows, row)130
}131
board := &FlowBoard{132
Base: base, Query: q, Sort: sortKey, Dir: dir, State: state,133
FlipHref: flowHref(base, state, q, sortKey, flipDir(dir), "", ""),134
CanNew: role.CanWriteCode(),135
NewHref: base + "/new",136
NewKey: "list.newMR",137
EmptyKey: "mr.none",138
Rows: rows,139
}140
board.Tabs = []FlowTab{141
{Href: flowHref(base, "open", q, sortKey, dir, "", ""), Key: "issue.open", Count: openN, On: state == "open"},142
{Href: flowHref(base, "merged", q, sortKey, dir, "", ""), Key: "list.merged", Count: mergedN, On: state == "merged"},143
{Href: flowHref(base, "closed", q, sortKey, dir, "", ""), Key: "issue.closed", Count: closedN, On: state == "closed"},144
{Href: flowHref(base, "all", q, sortKey, dir, "", ""), Key: "issue.all", Count: openN + mergedN + closedN, On: state == "all"},145
}146
return board147
}148
149
func (s *Server) flowIssues(r *http.Request, repo store.Repo, b *IssueBoard, all []store.Issue) *FlowBoard {150
q := b.Query151
sortKey := flowSortKey(r.URL.Query().Get("sort"))152
dir := flowDirKey(r.URL.Query().Get("dir"))153
state := flowStateKey(r.URL.Query().Get("state"), false)154
base := "/" + repo.FullPath() + "/-/issues"155
people := map[string]flowPerson{}156
157
var matched []store.Issue158
openN, closedN := 0, 0159
for _, iss := range all {160
name, _ := s.flowAuthor(r, iss.Author, people)161
bits := append(issueSearchBits(iss), name)162
if !flowHit(q, bits...) {163
continue164
}165
matched = append(matched, iss)166
if iss.Status == "closed" {167
closedN++168
} else {169
openN++170
}171
}172
var shown []store.Issue173
for _, iss := range matched {174
if state == "all" || iss.Status == state || (state == "open" && iss.Status != "closed") {175
shown = append(shown, iss)176
}177
}178
sortFlow(shown, sortKey, dir, func(i int) (time.Time, time.Time, int64) {179
return shown[i].CreatedAt, shown[i].UpdatedAt, shown[i].Number180
})181
182
rows := make([]FlowRow, 0, len(shown))183
for _, iss := range shown {184
name, href := s.flowAuthor(r, iss.Author, people)185
extra := strings.Join(iss.Assignees, ", ")186
if iss.Milestone != "" {187
if extra != "" {188
extra += " · "189
}190
extra += iss.Milestone191
}192
row := FlowRow{193
Href: base + "/" + strconv.FormatInt(iss.Number, 10),194
Title: iss.Title,195
Ref: "#" + strconv.FormatInt(iss.Number, 10),196
State: flowBadge(iss.Status),197
StateLabel: s.flowStateLabel(r, iss.Status),198
Created: s.ago(r, iss.CreatedAt),199
Updated: s.ago(r, iss.UpdatedAt),200
Author: name,201
AuthorURL: href,202
Confidential: iss.Confidential,203
Labels: iss.Labels,204
Extra: extra,205
}206
if row.State == "open" {207
if notes, err := s.Store.ListIssueNotes(r.Context(), iss.ID); err == nil {208
row.Comments = len(notes)209
}210
}211
rows = append(rows, row)212
}213
return &FlowBoard{214
Base: base, Query: q, Sort: sortKey, Dir: dir, State: state,215
FlipHref: flowHref(base, state, q, sortKey, flipDir(dir), b.Label, b.Assignee),216
CanNew: b.CanCreate,217
NewHref: base + "/new",218
NewKey: "issue.new",219
EmptyKey: "issue.none",220
Filters: true,221
Label: b.Label,222
Assignee: b.Assignee,223
Labels: b.Labels,224
People: b.People,225
Rows: rows,226
Tabs: []FlowTab{227
{Href: flowHref(base, "open", q, sortKey, dir, b.Label, b.Assignee), Key: "issue.open", Count: openN, On: state == "open"},228
{Href: flowHref(base, "closed", q, sortKey, dir, b.Label, b.Assignee), Key: "issue.closed", Count: closedN, On: state == "closed"},229
{Href: flowHref(base, "all", q, sortKey, dir, b.Label, b.Assignee), Key: "issue.all", Count: openN + closedN, On: state == "all"},230
},231
}232
}233
234
func (s *Server) attachFlowPipe(r *http.Request, repo store.Repo, mr store.MergeRequest, row *FlowRow) {235
p, err := s.Store.LatestMergePipeline(r.Context(), repo.ID, mr.ID)236
if err != nil {237
return238
}239
jobs, _ := s.Store.JobsByPipeline(r.Context(), p.ID)240
st := displayStatus(p.Status, jobs)241
row.PipeStatus = st242
row.PipeLabel = s.tr(r, "pipe."+st)243
row.PipeHref = "/" + repo.FullPath() + "/-/pipelines/" + strconv.FormatInt(p.ID, 10)244
}245
246
func (s *Server) flowAuthor(r *http.Request, username string, cache map[string]flowPerson) (string, string) {247
username = strings.TrimSpace(username)248
if username == "" {249
return "", ""250
}251
if p, ok := cache[username]; ok {252
return p.Name, p.URL253
}254
p := flowPerson{Name: username}255
if u, err := s.Store.UserByUsername(r.Context(), username); err == nil && u.ID != 0 {256
if name := strings.TrimSpace(u.DisplayName); name != "" {257
p.Name = name258
} else {259
p.Name = u.Username260
}261
p.URL = "/users/" + u.Username262
}263
cache[username] = p264
return p.Name, p.URL265
}266
267
func (s *Server) flowStateLabel(r *http.Request, status string) string {268
switch status {269
case "merged":270
return s.tr(r, "list.merged")271
case "closed":272
return s.tr(r, "issue.closed")273
default:274
return s.tr(r, "issue.open")275
}276
}277
278
func (s *Server) ago(r *http.Request, t time.Time) string {279
if t.IsZero() {280
return ""281
}282
return i18n.Ago(s.langOf(r), t.Unix())283
}284
285
func issueSearchBits(iss store.Issue) []string {286
bits := []string{iss.Title, iss.Description, strconv.FormatInt(iss.Number, 10), "#" + strconv.FormatInt(iss.Number, 10), iss.Author, iss.Milestone}287
bits = append(bits, iss.Assignees...)288
for _, l := range iss.Labels {289
bits = append(bits, l.Name)290
}291
return bits292
}293
294
func flowHit(q string, parts ...string) bool {295
q = strings.ToLower(strings.TrimSpace(q))296
if q == "" {297
return true298
}299
q = strings.TrimPrefix(q, "!")300
q = strings.TrimPrefix(q, "#")301
for _, p := range parts {302
if strings.Contains(strings.ToLower(p), q) {303
return true304
}305
}306
return false307
}308
309
func flowSortKey(raw string) string {310
if raw == "updated" {311
return "updated"312
}313
return "created"314
}315
316
func flowDirKey(raw string) string {317
if raw == "asc" {318
return "asc"319
}320
return "desc"321
}322
323
func flipDir(dir string) string {324
if dir == "asc" {325
return "desc"326
}327
return "asc"328
}329
330
func flowStateKey(raw string, merged bool) string {331
switch raw {332
case "closed", "all":333
return raw334
case "merged":335
if merged {336
return "merged"337
}338
}339
return "open"340
}341
342
func flowBadge(status string) string {343
switch status {344
case "merged", "closed":345
return status346
default:347
return "open"348
}349
}350
351
func flowHref(base, state, q, sortKey, dir, label, assignee string) string {352
v := url.Values{}353
v.Set("state", state)354
if strings.TrimSpace(q) != "" {355
v.Set("q", q)356
}357
if sortKey == "updated" {358
v.Set("sort", "updated")359
}360
if dir == "asc" {361
v.Set("dir", "asc")362
}363
if label != "" {364
v.Set("label", label)365
}366
if assignee != "" {367
v.Set("assignee", assignee)368
}369
return base + "?" + v.Encode()370
}371
372
func sortFlow[T any](rows []T, sortKey, dir string, at func(i int) (created, updated time.Time, number int64)) {373
sort.SliceStable(rows, func(i, j int) bool {374
ac, au, an := at(i)375
bc, bu, bn := at(j)376
a, b := ac, bc377
if sortKey == "updated" {378
a, b = au, bu379
}380
if dir == "asc" {381
if a.Equal(b) {382
return an < bn383
}384
return a.Before(b)385
}386
if a.Equal(b) {387
return an > bn388
}389
return a.After(b)390
})391
}@@ -0,0 +1,154 @@
1
package server
2
3
import (
4
"context"
5
"net/http"
6
"net/http/cookiejar"
7
"net/http/httptest"
8
"net/url"
9
"path/filepath"
10
"strings"
11
"testing"
12
"time"
13
14
"gitlab.com/Timfa/bluegit/internal/auth"
15
"gitlab.com/Timfa/bluegit/internal/config"
16
"gitlab.com/Timfa/bluegit/internal/store"
17
)
18
19
func TestFlowLists(t *testing.T) {
20
storage := t.TempDir()
21
st, err := store.Open(filepath.Join(storage, "bluegit.db"), bytes32())
22
if err != nil {
23
t.Fatal(err)
24
}
25
t.Cleanup(func() { _ = st.Close() })
26
cfg := config.Config{
27
BaseURL: "http://git.example", Listen: "127.0.0.1:0", StoragePath: storage,
28
Auth: config.Auth{Mode: "dev", DevUser: "tim", DevAuthID: 1, UserAgent: "test", BaseURL: "https://auth.timfalken.com"},
29
Git: config.Git{Binary: "git", DefaultBranch: "master"},
30
}
31
srv := &Server{Cfg: cfg, Store: st, Auth: auth.Dev{Username: "tim", AuthID: 1}, Dev: true, Git: "git", HookBin: "/bin/true"}
32
ts := httptest.NewServer(srv.Handler())
33
t.Cleanup(ts.Close)
34
jar, _ := cookiejar.New(nil)
35
tim := &http.Client{Jar: jar}
36
page := read(t, mustGet(t, tim, ts.URL+"/login"))
37
page = read(t, mustPost(t, tim, ts.URL+"/new/repo", url.Values{
38
"csrf": {csrfOf(t, page)}, "name": {"lijsten"}, "visibility": {"public"},
39
}))
40
ctx := context.Background()
41
repo, err := st.RepoByPath(ctx, "tim", "lijsten")
42
if err != nil {
43
t.Fatal(err)
44
}
45
user, err := st.UserByUsername(ctx, "tim")
46
if err != nil {
47
t.Fatal(err)
48
}
49
if err := st.SetProfile(ctx, user.ID, "Tim Falken", ""); err != nil {
50
t.Fatal(err)
51
}
52
openMR, err := st.CreateMergeRequest(ctx, repo.ID, user.ID, "Alpha open", "tekst", "topic", "master")
53
if err != nil {
54
t.Fatal(err)
55
}
56
merged, err := st.CreateMergeRequest(ctx, repo.ID, user.ID, "Beta samen", "", "ander", "master")
57
if err != nil {
58
t.Fatal(err)
59
}
60
closed, err := st.CreateMergeRequest(ctx, repo.ID, user.ID, "Gamma dicht", "", "derde", "master")
61
if err != nil {
62
t.Fatal(err)
63
}
64
time.Sleep(1100 * time.Millisecond)
65
if err := st.SetMergeRequestStatus(ctx, merged.ID, "merged"); err != nil {
66
t.Fatal(err)
67
}
68
if err := st.SetMergeRequestStatus(ctx, closed.ID, "closed"); err != nil {
69
t.Fatal(err)
70
}
71
if _, err := st.AddNote(ctx, repo.ID, openMR.ID, user.ID, "een reactie"); err != nil {
72
t.Fatal(err)
73
}
74
pipeID, err := st.CreatePipeline(ctx, repo.ID, "abc", "refs/heads/topic", "push", "tim", "Alpha open", nil)
75
if err != nil {
76
t.Fatal(err)
77
}
78
if err := st.AttachPipelineMR(ctx, pipeID, openMR.ID); err != nil {
79
t.Fatal(err)
80
}
81
82
openPage := read(t, mustGet(t, tim, ts.URL+"/tim/lijsten/-/merge-requests"))
83
for _, want := range []string{
84
`class="flowtabs"`, `class="on"`, `>Open <span class="flowcount">1</span>`,
85
`>Merged <span class="flowcount">1</span>`, `>Closed <span class="flowcount">1</span>`,
86
`>All <span class="flowcount">3</span>`, `New merge request`, `/-/merge-requests/new`,
87
`<strong>Alpha open</strong>`, `!1`, `created`, `by <a href="/users/tim">Tim Falken</a>`,
88
`class="flowbadge open"`, `updated`, `class="flowtarget">master`,
89
`class="flowcomments"`, `aria-label="1 comment"`, `class="flowpipe status pending"`,
90
`name="sort"`, `Created date`, `Updated date`, `name="dir" value="desc"`,
91
} {
92
if !strings.Contains(openPage, want) {
93
t.Errorf("open lijst mist %s", want)
94
}
95
}
96
if strings.Contains(openPage, "Beta samen") || strings.Contains(openPage, "Gamma dicht") {
97
t.Fatalf("open lijst toont andere status\n%s", openPage)
98
}
99
100
mergedPage := read(t, mustGet(t, tim, ts.URL+"/tim/lijsten/-/merge-requests?state=merged"))
101
if !strings.Contains(mergedPage, `<strong>Beta samen</strong>`) || !strings.Contains(mergedPage, `class="flowbadge merged"`) || !strings.Contains(mergedPage, "!2") {
102
t.Fatalf("gemerged\n%s", mergedPage)
103
}
104
if strings.Contains(mergedPage, "flowtarget") || strings.Contains(mergedPage, "flowcomments") || strings.Contains(mergedPage, "flowpipe") {
105
t.Fatalf("gemergde rij hoort kaal te blijven\n%s", mergedPage)
106
}
107
108
found := read(t, mustGet(t, tim, ts.URL+"/tim/lijsten/-/merge-requests?state=all&q=Gamma"))
109
if !strings.Contains(found, "Gamma dicht") || strings.Contains(found, "Alpha open") || !strings.Contains(found, `flowcount">1`) {
110
t.Fatalf("zoeken\n%s", found)
111
}
112
byName := read(t, mustGet(t, tim, ts.URL+"/tim/lijsten/-/merge-requests?state=all&q=Falken"))
113
if !strings.Contains(byName, "Alpha open") || !strings.Contains(byName, `flowcount">3`) {
114
t.Fatalf("zoeken op naam\n%s", byName)
115
}
116
117
desc := read(t, mustGet(t, tim, ts.URL+"/tim/lijsten/-/merge-requests?state=all&sort=updated"))
118
if strings.Index(desc, "Beta samen") > strings.Index(desc, "Alpha open") {
119
t.Fatalf("bijgewerkt nieuwste eerst: Beta hoort vóór Alpha\n%s", desc)
120
}
121
asc := read(t, mustGet(t, tim, ts.URL+"/tim/lijsten/-/merge-requests?state=all&sort=updated&dir=asc"))
122
if !strings.Contains(asc, `name="dir" value="asc"`) || !strings.Contains(asc, `aria-label="Newest first"`) {
123
t.Fatalf("richting\n%s", asc)
124
}
125
if strings.Index(asc, "Beta samen") < strings.Index(asc, "Alpha open") {
126
t.Fatalf("bijgewerkt oudste eerst: Alpha hoort vóór Beta\n%s", asc)
127
}
128
129
openIss, err := st.CreateIssue(ctx, repo.ID, user.ID, store.NewIssue{Title: "Kaart open"})
130
if err != nil {
131
t.Fatal(err)
132
}
133
shut, err := st.CreateIssue(ctx, repo.ID, user.ID, store.NewIssue{Title: "Kaart dicht"})
134
if err != nil {
135
t.Fatal(err)
136
}
137
if _, err := st.SetIssueState(ctx, shut.ID, "closed"); err != nil {
138
t.Fatal(err)
139
}
140
_ = openIss
141
issues := read(t, mustGet(t, tim, ts.URL+"/tim/lijsten/-/issues"))
142
for _, want := range []string{`>Open <span class="flowcount">1</span>`, `>Closed <span class="flowcount">1</span>`, `>All <span class="flowcount">2</span>`, `<strong>Kaart open</strong>`, "#1", "New issue", `name="label"`, `name="assignee"`} {
143
if !strings.Contains(issues, want) {
144
t.Errorf("issues mist %s", want)
145
}
146
}
147
if strings.Contains(issues, "Kaart dicht") {
148
t.Fatalf("open issues toont gesloten\n%s", issues)
149
}
150
closedIssues := read(t, mustGet(t, tim, ts.URL+"/tim/lijsten/-/issues?state=closed"))
151
if !strings.Contains(closedIssues, "Kaart dicht") || strings.Contains(closedIssues, "Kaart open") {
152
t.Fatalf("gesloten issues\n%s", closedIssues)
153
}
154
}
@@ -0,0 +1,154 @@1
package server2
3
import (4
"context"5
"net/http"6
"net/http/cookiejar"7
"net/http/httptest"8
"net/url"9
"path/filepath"10
"strings"11
"testing"12
"time"13
14
"gitlab.com/Timfa/bluegit/internal/auth"15
"gitlab.com/Timfa/bluegit/internal/config"16
"gitlab.com/Timfa/bluegit/internal/store"17
)18
19
func TestFlowLists(t *testing.T) {20
storage := t.TempDir()21
st, err := store.Open(filepath.Join(storage, "bluegit.db"), bytes32())22
if err != nil {23
t.Fatal(err)24
}25
t.Cleanup(func() { _ = st.Close() })26
cfg := config.Config{27
BaseURL: "http://git.example", Listen: "127.0.0.1:0", StoragePath: storage,28
Auth: config.Auth{Mode: "dev", DevUser: "tim", DevAuthID: 1, UserAgent: "test", BaseURL: "https://auth.timfalken.com"},29
Git: config.Git{Binary: "git", DefaultBranch: "master"},30
}31
srv := &Server{Cfg: cfg, Store: st, Auth: auth.Dev{Username: "tim", AuthID: 1}, Dev: true, Git: "git", HookBin: "/bin/true"}32
ts := httptest.NewServer(srv.Handler())33
t.Cleanup(ts.Close)34
jar, _ := cookiejar.New(nil)35
tim := &http.Client{Jar: jar}36
page := read(t, mustGet(t, tim, ts.URL+"/login"))37
page = read(t, mustPost(t, tim, ts.URL+"/new/repo", url.Values{38
"csrf": {csrfOf(t, page)}, "name": {"lijsten"}, "visibility": {"public"},39
}))40
ctx := context.Background()41
repo, err := st.RepoByPath(ctx, "tim", "lijsten")42
if err != nil {43
t.Fatal(err)44
}45
user, err := st.UserByUsername(ctx, "tim")46
if err != nil {47
t.Fatal(err)48
}49
if err := st.SetProfile(ctx, user.ID, "Tim Falken", ""); err != nil {50
t.Fatal(err)51
}52
openMR, err := st.CreateMergeRequest(ctx, repo.ID, user.ID, "Alpha open", "tekst", "topic", "master")53
if err != nil {54
t.Fatal(err)55
}56
merged, err := st.CreateMergeRequest(ctx, repo.ID, user.ID, "Beta samen", "", "ander", "master")57
if err != nil {58
t.Fatal(err)59
}60
closed, err := st.CreateMergeRequest(ctx, repo.ID, user.ID, "Gamma dicht", "", "derde", "master")61
if err != nil {62
t.Fatal(err)63
}64
time.Sleep(1100 * time.Millisecond)65
if err := st.SetMergeRequestStatus(ctx, merged.ID, "merged"); err != nil {66
t.Fatal(err)67
}68
if err := st.SetMergeRequestStatus(ctx, closed.ID, "closed"); err != nil {69
t.Fatal(err)70
}71
if _, err := st.AddNote(ctx, repo.ID, openMR.ID, user.ID, "een reactie"); err != nil {72
t.Fatal(err)73
}74
pipeID, err := st.CreatePipeline(ctx, repo.ID, "abc", "refs/heads/topic", "push", "tim", "Alpha open", nil)75
if err != nil {76
t.Fatal(err)77
}78
if err := st.AttachPipelineMR(ctx, pipeID, openMR.ID); err != nil {79
t.Fatal(err)80
}81
82
openPage := read(t, mustGet(t, tim, ts.URL+"/tim/lijsten/-/merge-requests"))83
for _, want := range []string{84
`class="flowtabs"`, `class="on"`, `>Open <span class="flowcount">1</span>`,85
`>Merged <span class="flowcount">1</span>`, `>Closed <span class="flowcount">1</span>`,86
`>All <span class="flowcount">3</span>`, `New merge request`, `/-/merge-requests/new`,87
`<strong>Alpha open</strong>`, `!1`, `created`, `by <a href="/users/tim">Tim Falken</a>`,88
`class="flowbadge open"`, `updated`, `class="flowtarget">master`,89
`class="flowcomments"`, `aria-label="1 comment"`, `class="flowpipe status pending"`,90
`name="sort"`, `Created date`, `Updated date`, `name="dir" value="desc"`,91
} {92
if !strings.Contains(openPage, want) {93
t.Errorf("open lijst mist %s", want)94
}95
}96
if strings.Contains(openPage, "Beta samen") || strings.Contains(openPage, "Gamma dicht") {97
t.Fatalf("open lijst toont andere status\n%s", openPage)98
}99
100
mergedPage := read(t, mustGet(t, tim, ts.URL+"/tim/lijsten/-/merge-requests?state=merged"))101
if !strings.Contains(mergedPage, `<strong>Beta samen</strong>`) || !strings.Contains(mergedPage, `class="flowbadge merged"`) || !strings.Contains(mergedPage, "!2") {102
t.Fatalf("gemerged\n%s", mergedPage)103
}104
if strings.Contains(mergedPage, "flowtarget") || strings.Contains(mergedPage, "flowcomments") || strings.Contains(mergedPage, "flowpipe") {105
t.Fatalf("gemergde rij hoort kaal te blijven\n%s", mergedPage)106
}107
108
found := read(t, mustGet(t, tim, ts.URL+"/tim/lijsten/-/merge-requests?state=all&q=Gamma"))109
if !strings.Contains(found, "Gamma dicht") || strings.Contains(found, "Alpha open") || !strings.Contains(found, `flowcount">1`) {110
t.Fatalf("zoeken\n%s", found)111
}112
byName := read(t, mustGet(t, tim, ts.URL+"/tim/lijsten/-/merge-requests?state=all&q=Falken"))113
if !strings.Contains(byName, "Alpha open") || !strings.Contains(byName, `flowcount">3`) {114
t.Fatalf("zoeken op naam\n%s", byName)115
}116
117
desc := read(t, mustGet(t, tim, ts.URL+"/tim/lijsten/-/merge-requests?state=all&sort=updated"))118
if strings.Index(desc, "Beta samen") > strings.Index(desc, "Alpha open") {119
t.Fatalf("bijgewerkt nieuwste eerst: Beta hoort vóór Alpha\n%s", desc)120
}121
asc := read(t, mustGet(t, tim, ts.URL+"/tim/lijsten/-/merge-requests?state=all&sort=updated&dir=asc"))122
if !strings.Contains(asc, `name="dir" value="asc"`) || !strings.Contains(asc, `aria-label="Newest first"`) {123
t.Fatalf("richting\n%s", asc)124
}125
if strings.Index(asc, "Beta samen") < strings.Index(asc, "Alpha open") {126
t.Fatalf("bijgewerkt oudste eerst: Alpha hoort vóór Beta\n%s", asc)127
}128
129
openIss, err := st.CreateIssue(ctx, repo.ID, user.ID, store.NewIssue{Title: "Kaart open"})130
if err != nil {131
t.Fatal(err)132
}133
shut, err := st.CreateIssue(ctx, repo.ID, user.ID, store.NewIssue{Title: "Kaart dicht"})134
if err != nil {135
t.Fatal(err)136
}137
if _, err := st.SetIssueState(ctx, shut.ID, "closed"); err != nil {138
t.Fatal(err)139
}140
_ = openIss141
issues := read(t, mustGet(t, tim, ts.URL+"/tim/lijsten/-/issues"))142
for _, want := range []string{`>Open <span class="flowcount">1</span>`, `>Closed <span class="flowcount">1</span>`, `>All <span class="flowcount">2</span>`, `<strong>Kaart open</strong>`, "#1", "New issue", `name="label"`, `name="assignee"`} {143
if !strings.Contains(issues, want) {144
t.Errorf("issues mist %s", want)145
}146
}147
if strings.Contains(issues, "Kaart dicht") {148
t.Fatalf("open issues toont gesloten\n%s", issues)149
}150
closedIssues := read(t, mustGet(t, tim, ts.URL+"/tim/lijsten/-/issues?state=closed"))151
if !strings.Contains(closedIssues, "Kaart dicht") || strings.Contains(closedIssues, "Kaart open") {152
t.Fatalf("gesloten issues\n%s", closedIssues)153
}154
}@@ -93,23 +93,26 @@ func (s *Server) issuesPage(w http.ResponseWriter, r *http.Request) {
93
93
v.Page = "issues"
94
94
v.Wide = true
95
95
b := s.issueBoard(r, repo, role, u)
96
state := r.URL.Query().Get("state")
97
if state != "closed" && state != "all" {
98
state = "open"
99
}
100
b.State = state
101
96
b.Query = strings.TrimSpace(r.URL.Query().Get("q"))
102
97
b.Label = strings.TrimSpace(r.URL.Query().Get("label"))
103
98
b.Assignee = strings.TrimSpace(r.URL.Query().Get("assignee"))
104
99
list, err := s.Store.ListIssues(r.Context(), repo.ID, store.IssueFilter{
105
State: b.State, Query: b.Query, Label: b.Label, Assignee: b.Assignee,
100
State: "all", Label: b.Label, Assignee: b.Assignee,
106
101
ViewerID: u.ID, Triage: role.CanTriageIssue(),
107
102
})
108
103
if err != nil {
109
104
s.fail(w, r, err)
110
105
return
111
106
}
107
v.Flow = s.flowIssues(r, repo, b, list)
108
b.State = v.Flow.State
112
109
for _, iss := range list {
110
if iss.Status != b.State && b.State != "all" {
111
continue
112
}
113
if !flowHit(b.Query, issueSearchBits(iss)...) {
114
continue
115
}
113
116
b.List = append(b.List, s.issueRow(r, repo, iss))
114
117
}
115
118
v.Issues = b
@@ -93,23 +93,26 @@ func (s *Server) issuesPage(w http.ResponseWriter, r *http.Request) {93
v.Page = "issues"93
v.Page = "issues"94
v.Wide = true94
v.Wide = true95
b := s.issueBoard(r, repo, role, u)95
b := s.issueBoard(r, repo, role, u)96
state := r.URL.Query().Get("state")97
if state != "closed" && state != "all" {98
state = "open"99
}100
b.State = state101
b.Query = strings.TrimSpace(r.URL.Query().Get("q"))96
b.Query = strings.TrimSpace(r.URL.Query().Get("q"))102
b.Label = strings.TrimSpace(r.URL.Query().Get("label"))97
b.Label = strings.TrimSpace(r.URL.Query().Get("label"))103
b.Assignee = strings.TrimSpace(r.URL.Query().Get("assignee"))98
b.Assignee = strings.TrimSpace(r.URL.Query().Get("assignee"))104
list, err := s.Store.ListIssues(r.Context(), repo.ID, store.IssueFilter{99
list, err := s.Store.ListIssues(r.Context(), repo.ID, store.IssueFilter{105
State: b.State, Query: b.Query, Label: b.Label, Assignee: b.Assignee,100
State: "all", Label: b.Label, Assignee: b.Assignee,106
ViewerID: u.ID, Triage: role.CanTriageIssue(),101
ViewerID: u.ID, Triage: role.CanTriageIssue(),107
})102
})108
if err != nil {103
if err != nil {109
s.fail(w, r, err)104
s.fail(w, r, err)110
return105
return111
}106
}107
v.Flow = s.flowIssues(r, repo, b, list)108
b.State = v.Flow.State112
for _, iss := range list {109
for _, iss := range list {110
if iss.Status != b.State && b.State != "all" {111
continue112
}113
if !flowHit(b.Query, issueSearchBits(iss)...) {114
continue115
}113
b.List = append(b.List, s.issueRow(r, repo, iss))116
b.List = append(b.List, s.issueRow(r, repo, iss))114
}117
}115
v.Issues = b118
v.Issues = b@@ -174,12 +174,9 @@ func (s *Server) mergeRequests(w http.ResponseWriter, r *http.Request) {
174
174
s.absorbMergedMRs(r.Context(), repo)
175
175
v := s.repoView(w, r, repo, role, "title.mrs")
176
176
v.Page = "mrs"
177
v.MRs, _ = s.Store.ListMergeRequests(r.Context(), repo.ID)
178
dir := gitrepo.Dir(s.StoragePath(), repo.OwnerPath, repo.Name)
179
names, _ := gitrepo.Branches(r.Context(), s.Git, dir)
180
for _, name := range names {
181
v.Branches = append(v.Branches, BranchRow{Name: name})
182
}
177
v.Wide = true
178
all, _ := s.Store.ListMergeRequests(r.Context(), repo.ID)
179
v.Flow = s.flowMRs(r, repo, role, all)
183
180
s.render(w, "mrs", v)
184
181
}
185
182
@@ -174,12 +174,9 @@ func (s *Server) mergeRequests(w http.ResponseWriter, r *http.Request) {174
s.absorbMergedMRs(r.Context(), repo)174
s.absorbMergedMRs(r.Context(), repo)175
v := s.repoView(w, r, repo, role, "title.mrs")175
v := s.repoView(w, r, repo, role, "title.mrs")176
v.Page = "mrs"176
v.Page = "mrs"177
v.MRs, _ = s.Store.ListMergeRequests(r.Context(), repo.ID)177
v.Wide = true178
dir := gitrepo.Dir(s.StoragePath(), repo.OwnerPath, repo.Name)178
all, _ := s.Store.ListMergeRequests(r.Context(), repo.ID)179
names, _ := gitrepo.Branches(r.Context(), s.Git, dir)179
v.Flow = s.flowMRs(r, repo, role, all)180
for _, name := range names {181
v.Branches = append(v.Branches, BranchRow{Name: name})182
}183
s.render(w, "mrs", v)180
s.render(w, "mrs", v)184
}181
}185
182
@@ -524,6 +524,7 @@ type View struct {
524
524
Binary bool
525
525
Branches []BranchRow
526
526
MRs []store.MergeRequest
527
Flow *FlowBoard
527
528
MR *store.MergeRequest
528
529
MRPipe *PipeRow
529
530
MergeBlocks []string
@@ -524,6 +524,7 @@ type View struct {524
Binary bool524
Binary bool525
Branches []BranchRow525
Branches []BranchRow526
MRs []store.MergeRequest526
MRs []store.MergeRequest527
Flow *FlowBoard527
MR *store.MergeRequest528
MR *store.MergeRequest528
MRPipe *PipeRow529
MRPipe *PipeRow529
MergeBlocks []string530
MergeBlocks []string@@ -959,6 +959,77 @@ form.wh .grid-2 label { margin-top: 0; }
959
959
}
960
960
.issuelist { list-style: none; margin: 0; padding: 0; }
961
961
.issuelist > li { border-bottom: 1px solid var(--line); padding: 0.6rem 0; min-height: 2.4rem; }
962
.flowhead {
963
display: flex; align-items: center; justify-content: space-between;
964
gap: var(--sp-3); flex-wrap: wrap; margin: 0 0 var(--sp-3);
965
}
966
.flowtabs { display: flex; flex-wrap: wrap; gap: var(--sp-1); align-items: center; min-width: 0; }
967
.flowtabs a {
968
display: inline-flex; align-items: center; gap: 0.35rem;
969
text-decoration: none; color: var(--ink); font-weight: 500;
970
padding: 0.35rem 0.65rem; border: 1px solid transparent; border-radius: var(--radius);
971
}
972
.flowtabs a.on { background: #f4f7fb; border-color: var(--line); }
973
.flowcount {
974
display: inline-block; min-width: 1.15rem; padding: 0 0.35rem; text-align: center;
975
background: #eef2f6; color: var(--muted); border-radius: 999px; font-size: 0.78rem; font-weight: 650;
976
}
977
.flowtabs a.on .flowcount { background: var(--blue-soft); color: var(--blue-deep); }
978
.flowbar { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; margin: 0 0 var(--sp-2); }
979
.flowsearch {
980
position: relative;
981
flex: 1 1 16rem; display: flex; align-items: center; gap: 0.4rem; min-width: 0;
982
border: 1px solid var(--line); border-radius: var(--radius); background: white;
983
min-height: var(--control-h); padding: 0 0.35rem 0 0.55rem; color: var(--muted);
984
}
985
.flowsearch input { border: 0; min-height: 0; padding: 0; background: transparent; flex: 1; width: auto; color: var(--ink); }
986
.flowsearch input:focus { outline: none; }
987
.flowsearch:focus-within { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-soft); }
988
.flowsearch button.flowgo {
989
position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
990
clip: rect(0, 0, 0, 0); border: 0; background: transparent; color: transparent;
991
}
992
.flowbar > select { width: auto; flex: 0 1 12rem; }
993
a.flowdir { width: var(--control-h); min-width: var(--control-h); padding: 0; }
994
.flowlist { list-style: none; margin: 0; padding: 0; }
995
.flowrow {
996
display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-4);
997
padding: 0.85rem 0.15rem; border-bottom: 1px solid var(--line);
998
}
999
.flowrow:first-child { border-top: 1px solid var(--line); }
1000
.flowmain { min-width: 0; }
1001
.flowtitle { color: inherit; text-decoration: none; font-size: 1rem; line-height: 1.35; }
1002
.flowtitle strong { font-weight: 650; }
1003
.flowtitle:hover strong { text-decoration: underline; }
1004
.flowdraft { color: var(--muted); font-weight: 500; }
1005
.flowmeta {
1006
margin: 0.28rem 0 0; color: var(--muted); font-size: var(--fs-sm);
1007
display: flex; flex-wrap: wrap; gap: 0.35rem 0.45rem; align-items: center;
1008
}
1009
.flowmeta a { color: inherit; }
1010
.flowdot { color: var(--line); }
1011
.flowtarget {
1012
border: 1px solid var(--line); border-radius: 999px; padding: 0 0.4rem;
1013
background: white; color: var(--ink);
1014
}
1015
.flowcomments { display: inline-flex; align-items: center; gap: 0.2rem; }
1016
a.flowpipe { padding: 0; background: transparent; min-height: 0; line-height: 0; }
1017
a.flowpipe .mark { width: 14px; height: 14px; }
1018
a.flowpipe.passed .mark::after { left: 4px; top: 2px; width: 3px; height: 6px; }
1019
.flowside { display: flex; flex-direction: column; align-items: flex-end; gap: 0.28rem; flex: none; text-align: right; }
1020
.flowbadge {
1021
display: inline-block; border-radius: 999px; padding: 0.08rem 0.55rem;
1022
font-size: 0.78rem; font-weight: 650; background: #e5f6ec; color: #146c43;
1023
}
1024
.flowbadge.merged { background: var(--blue-soft); color: var(--blue-deep); }
1025
.flowbadge.closed { background: #fde8e8; color: var(--bad); }
1026
.flowupdated { color: var(--muted); font-size: var(--fs-sm); white-space: nowrap; }
1027
.flowempty { padding: 0.8rem 0; }
1028
@media (max-width: 800px) {
1029
.flowrow { flex-direction: column; gap: 0.4rem; }
1030
.flowside { flex-direction: row; align-items: center; }
1031
.flowbar > select { flex: 1 1 8rem; }
1032
}
962
1033
.lab { display: inline-block; color: #fff; border-radius: 999px; padding: 0.05rem 0.45rem; font-size: 0.78rem; margin: 0 0.2rem; }
963
1034
.issue-meta { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin: 0.4rem 0; }
964
1035
.checks label { display: block; margin: 0.2rem 0; }
@@ -959,6 +959,77 @@ form.wh .grid-2 label { margin-top: 0; }959
}959
}960
.issuelist { list-style: none; margin: 0; padding: 0; }960
.issuelist { list-style: none; margin: 0; padding: 0; }961
.issuelist > li { border-bottom: 1px solid var(--line); padding: 0.6rem 0; min-height: 2.4rem; }961
.issuelist > li { border-bottom: 1px solid var(--line); padding: 0.6rem 0; min-height: 2.4rem; }962
.flowhead {963
display: flex; align-items: center; justify-content: space-between;964
gap: var(--sp-3); flex-wrap: wrap; margin: 0 0 var(--sp-3);965
}966
.flowtabs { display: flex; flex-wrap: wrap; gap: var(--sp-1); align-items: center; min-width: 0; }967
.flowtabs a {968
display: inline-flex; align-items: center; gap: 0.35rem;969
text-decoration: none; color: var(--ink); font-weight: 500;970
padding: 0.35rem 0.65rem; border: 1px solid transparent; border-radius: var(--radius);971
}972
.flowtabs a.on { background: #f4f7fb; border-color: var(--line); }973
.flowcount {974
display: inline-block; min-width: 1.15rem; padding: 0 0.35rem; text-align: center;975
background: #eef2f6; color: var(--muted); border-radius: 999px; font-size: 0.78rem; font-weight: 650;976
}977
.flowtabs a.on .flowcount { background: var(--blue-soft); color: var(--blue-deep); }978
.flowbar { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; margin: 0 0 var(--sp-2); }979
.flowsearch {980
position: relative;981
flex: 1 1 16rem; display: flex; align-items: center; gap: 0.4rem; min-width: 0;982
border: 1px solid var(--line); border-radius: var(--radius); background: white;983
min-height: var(--control-h); padding: 0 0.35rem 0 0.55rem; color: var(--muted);984
}985
.flowsearch input { border: 0; min-height: 0; padding: 0; background: transparent; flex: 1; width: auto; color: var(--ink); }986
.flowsearch input:focus { outline: none; }987
.flowsearch:focus-within { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-soft); }988
.flowsearch button.flowgo {989
position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;990
clip: rect(0, 0, 0, 0); border: 0; background: transparent; color: transparent;991
}992
.flowbar > select { width: auto; flex: 0 1 12rem; }993
a.flowdir { width: var(--control-h); min-width: var(--control-h); padding: 0; }994
.flowlist { list-style: none; margin: 0; padding: 0; }995
.flowrow {996
display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-4);997
padding: 0.85rem 0.15rem; border-bottom: 1px solid var(--line);998
}999
.flowrow:first-child { border-top: 1px solid var(--line); }1000
.flowmain { min-width: 0; }1001
.flowtitle { color: inherit; text-decoration: none; font-size: 1rem; line-height: 1.35; }1002
.flowtitle strong { font-weight: 650; }1003
.flowtitle:hover strong { text-decoration: underline; }1004
.flowdraft { color: var(--muted); font-weight: 500; }1005
.flowmeta {1006
margin: 0.28rem 0 0; color: var(--muted); font-size: var(--fs-sm);1007
display: flex; flex-wrap: wrap; gap: 0.35rem 0.45rem; align-items: center;1008
}1009
.flowmeta a { color: inherit; }1010
.flowdot { color: var(--line); }1011
.flowtarget {1012
border: 1px solid var(--line); border-radius: 999px; padding: 0 0.4rem;1013
background: white; color: var(--ink);1014
}1015
.flowcomments { display: inline-flex; align-items: center; gap: 0.2rem; }1016
a.flowpipe { padding: 0; background: transparent; min-height: 0; line-height: 0; }1017
a.flowpipe .mark { width: 14px; height: 14px; }1018
a.flowpipe.passed .mark::after { left: 4px; top: 2px; width: 3px; height: 6px; }1019
.flowside { display: flex; flex-direction: column; align-items: flex-end; gap: 0.28rem; flex: none; text-align: right; }1020
.flowbadge {1021
display: inline-block; border-radius: 999px; padding: 0.08rem 0.55rem;1022
font-size: 0.78rem; font-weight: 650; background: #e5f6ec; color: #146c43;1023
}1024
.flowbadge.merged { background: var(--blue-soft); color: var(--blue-deep); }1025
.flowbadge.closed { background: #fde8e8; color: var(--bad); }1026
.flowupdated { color: var(--muted); font-size: var(--fs-sm); white-space: nowrap; }1027
.flowempty { padding: 0.8rem 0; }1028
@media (max-width: 800px) {1029
.flowrow { flex-direction: column; gap: 0.4rem; }1030
.flowside { flex-direction: row; align-items: center; }1031
.flowbar > select { flex: 1 1 8rem; }1032
}962
.lab { display: inline-block; color: #fff; border-radius: 999px; padding: 0.05rem 0.45rem; font-size: 0.78rem; margin: 0 0.2rem; }1033
.lab { display: inline-block; color: #fff; border-radius: 999px; padding: 0.05rem 0.45rem; font-size: 0.78rem; margin: 0 0.2rem; }963
.issue-meta { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin: 0.4rem 0; }1034
.issue-meta { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin: 0.4rem 0; }964
.checks label { display: block; margin: 0.2rem 0; }1035
.checks label { display: block; margin: 0.2rem 0; }@@ -8,14 +8,75 @@
8
8
9
9
{{define "mrs"}}
10
10
{{template "layout-start" .}}
11
<header class="pagehead"><h1>{{t "mr.title"}}</h1></header>
12
{{if .CanWrite}}<p class="pageacts"><a class="btn" href="/{{.Repo.FullPath}}/-/merge-requests/new">{{t "mr.create"}}</a></p>{{end}}
13
<ul class="clean">
14
{{range .MRs}}<li><a href="/{{$.Repo.FullPath}}/-/merge-requests/{{.Number}}">!{{.Number}} {{.Title}}</a> <span class="pill">{{.Status}}</span>{{if .Draft}} <span class="pill">{{t "mr.draft"}}</span>{{end}} <span class="muted">{{.SourceBranch}} → {{.TargetBranch}}</span></li>{{else}}<li class="muted">{{t "mr.none"}}</li>{{end}}
15
</ul>
11
{{template "flowlist" .Flow}}
16
12
{{template "layout-end" .}}
17
13
{{end}}
18
14
15
{{define "flowlist"}}
16
<div class="flowhead">
17
<nav class="flowtabs" aria-label="{{t "list.tabs"}}">
18
{{range .Tabs}}<a href="{{.Href}}"{{if .On}} class="on" aria-current="page"{{end}}>{{t .Key}} <span class="flowcount">{{.Count}}</span></a>{{end}}
19
</nav>
20
{{if .CanNew}}<a class="btn" href="{{.NewHref}}">{{t .NewKey}}</a>{{end}}
21
</div>
22
<form class="flowbar" method="get" action="{{.Base}}">
23
<input type="hidden" name="state" value="{{.State}}">
24
<input type="hidden" name="dir" value="{{.Dir}}">
25
<div class="flowsearch">
26
<svg class="ico" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M11.5 7a4.5 4.5 0 1 1-9 0 4.5 4.5 0 0 1 9 0zm-.9 4.3 3.4 3.4a.75.75 0 1 0 1.1-1.1l-3.4-3.4a6 6 0 1 0-1.1 1.1z"/></svg>
27
<input name="q" value="{{.Query}}" placeholder="{{t "list.search"}}" aria-label="{{t "list.search"}}">
28
<button class="flowgo" type="submit">{{t "issue.filter"}}</button>
29
</div>
30
{{if .Filters}}
31
<select name="label" aria-label="{{t "issue.labels"}}" onchange="this.form.requestSubmit()">
32
<option value="">{{t "issue.anyLabel"}}</option>
33
{{range .Labels}}<option value="{{.Name}}"{{if eq .Name $.Label}} selected{{end}}>{{.Name}}</option>{{end}}
34
</select>
35
<select name="assignee" aria-label="{{t "issue.assignees"}}" onchange="this.form.requestSubmit()">
36
<option value="">{{t "issue.anyAssignee"}}</option>
37
{{range .People}}<option value="{{.Name}}"{{if eq .Name $.Assignee}} selected{{end}}>{{.Name}}</option>{{end}}
38
</select>
39
{{end}}
40
<select name="sort" aria-label="{{t "list.sort"}}" onchange="this.form.requestSubmit()">
41
<option value="created"{{if eq .Sort "created"}} selected{{end}}>{{t "list.sort.created"}}</option>
42
<option value="updated"{{if eq .Sort "updated"}} selected{{end}}>{{t "list.sort.updated"}}</option>
43
</select>
44
<a class="btn ghost flowdir" href="{{.FlipHref}}" aria-label="{{if eq .Dir "asc"}}{{t "list.sort.desc"}}{{else}}{{t "list.sort.asc"}}{{end}}">
45
{{if eq .Dir "asc"}}
46
<svg class="ico" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M8 3.2 3.2 8.5h2.6V13h4.4V8.5h2.6L8 3.2z"/></svg>
47
{{else}}
48
<svg class="ico" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M8 12.8 12.8 7.5H10.2V3H5.8v4.5H3.2L8 12.8z"/></svg>
49
{{end}}
50
</a>
51
</form>
52
<ul class="flowlist">
53
{{range .Rows}}
54
<li class="flowrow">
55
<div class="flowmain">
56
<a class="flowtitle" href="{{.Href}}">{{if .Draft}}<span class="flowdraft">{{t "mr.draft"}}:</span> {{end}}<strong>{{.Title}}</strong></a>
57
<p class="flowmeta">
58
{{if .PipeHref}}<a class="flowpipe status {{.PipeStatus}}" href="{{.PipeHref}}" title="{{.PipeLabel}}" aria-label="{{.PipeLabel}}"><span class="mark"></span></a>{{end}}
59
<span class="flowref">{{.Ref}}</span>
60
<span class="flowdot" aria-hidden="true">·</span>
61
<span>{{t "list.created" .Created}}{{if .Author}} {{t "list.by"}} {{if .AuthorURL}}<a href="{{.AuthorURL}}">{{.Author}}</a>{{else}}{{.Author}}{{end}}{{end}}</span>
62
{{if .Comments}}<span class="flowcomments" aria-label="{{tn .Comments "list.comment" "list.comments"}}"><svg class="ico" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M2.2 2.4A1.4 1.4 0 0 1 3.6 1h8.8A1.4 1.4 0 0 1 13.8 2.4v6.4A1.4 1.4 0 0 1 12.4 10.2H8.1L4.6 13.4V10.2H3.6A1.4 1.4 0 0 1 2.2 8.8V2.4z"/></svg>{{.Comments}}</span>{{end}}
63
{{if .Target}}<span class="flowtarget">{{.Target}}</span>{{end}}
64
{{if .Confidential}}<span class="pill">{{t "issue.confidential"}}</span>{{end}}
65
{{range .Labels}}<span class="lab" style="background:{{.Color}}">{{.Name}}</span>{{end}}
66
{{if .Extra}}<span>{{.Extra}}</span>{{end}}
67
</p>
68
</div>
69
<div class="flowside">
70
<span class="flowbadge {{.State}}">{{.StateLabel}}</span>
71
{{if .Updated}}<span class="flowupdated">{{t "list.updated" .Updated}}</span>{{end}}
72
</div>
73
</li>
74
{{else}}
75
<li class="flowempty muted">{{t .EmptyKey}}</li>
76
{{end}}
77
</ul>
78
{{end}}
79
19
80
{{define "mr"}}
20
81
{{template "layout-start" .}}
21
82
<header class="pagehead"><h1>!{{.MR.Number}} {{.MR.Title}}</h1></header>
@@ -8,14 +8,75 @@8
8
9
{{define "mrs"}}9
{{define "mrs"}}10
{{template "layout-start" .}}10
{{template "layout-start" .}}11
<header class="pagehead"><h1>{{t "mr.title"}}</h1></header>11
{{template "flowlist" .Flow}}12
{{if .CanWrite}}<p class="pageacts"><a class="btn" href="/{{.Repo.FullPath}}/-/merge-requests/new">{{t "mr.create"}}</a></p>{{end}}13
<ul class="clean">14
{{range .MRs}}<li><a href="/{{$.Repo.FullPath}}/-/merge-requests/{{.Number}}">!{{.Number}} {{.Title}}</a> <span class="pill">{{.Status}}</span>{{if .Draft}} <span class="pill">{{t "mr.draft"}}</span>{{end}} <span class="muted">{{.SourceBranch}} → {{.TargetBranch}}</span></li>{{else}}<li class="muted">{{t "mr.none"}}</li>{{end}}15
</ul>16
{{template "layout-end" .}}12
{{template "layout-end" .}}17
{{end}}13
{{end}}18
14
15
{{define "flowlist"}}16
<div class="flowhead">17
<nav class="flowtabs" aria-label="{{t "list.tabs"}}">18
{{range .Tabs}}<a href="{{.Href}}"{{if .On}} class="on" aria-current="page"{{end}}>{{t .Key}} <span class="flowcount">{{.Count}}</span></a>{{end}}19
</nav>20
{{if .CanNew}}<a class="btn" href="{{.NewHref}}">{{t .NewKey}}</a>{{end}}21
</div>22
<form class="flowbar" method="get" action="{{.Base}}">23
<input type="hidden" name="state" value="{{.State}}">24
<input type="hidden" name="dir" value="{{.Dir}}">25
<div class="flowsearch">26
<svg class="ico" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M11.5 7a4.5 4.5 0 1 1-9 0 4.5 4.5 0 0 1 9 0zm-.9 4.3 3.4 3.4a.75.75 0 1 0 1.1-1.1l-3.4-3.4a6 6 0 1 0-1.1 1.1z"/></svg>27
<input name="q" value="{{.Query}}" placeholder="{{t "list.search"}}" aria-label="{{t "list.search"}}">28
<button class="flowgo" type="submit">{{t "issue.filter"}}</button>29
</div>30
{{if .Filters}}31
<select name="label" aria-label="{{t "issue.labels"}}" onchange="this.form.requestSubmit()">32
<option value="">{{t "issue.anyLabel"}}</option>33
{{range .Labels}}<option value="{{.Name}}"{{if eq .Name $.Label}} selected{{end}}>{{.Name}}</option>{{end}}34
</select>35
<select name="assignee" aria-label="{{t "issue.assignees"}}" onchange="this.form.requestSubmit()">36
<option value="">{{t "issue.anyAssignee"}}</option>37
{{range .People}}<option value="{{.Name}}"{{if eq .Name $.Assignee}} selected{{end}}>{{.Name}}</option>{{end}}38
</select>39
{{end}}40
<select name="sort" aria-label="{{t "list.sort"}}" onchange="this.form.requestSubmit()">41
<option value="created"{{if eq .Sort "created"}} selected{{end}}>{{t "list.sort.created"}}</option>42
<option value="updated"{{if eq .Sort "updated"}} selected{{end}}>{{t "list.sort.updated"}}</option>43
</select>44
<a class="btn ghost flowdir" href="{{.FlipHref}}" aria-label="{{if eq .Dir "asc"}}{{t "list.sort.desc"}}{{else}}{{t "list.sort.asc"}}{{end}}">45
{{if eq .Dir "asc"}}46
<svg class="ico" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M8 3.2 3.2 8.5h2.6V13h4.4V8.5h2.6L8 3.2z"/></svg>47
{{else}}48
<svg class="ico" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M8 12.8 12.8 7.5H10.2V3H5.8v4.5H3.2L8 12.8z"/></svg>49
{{end}}50
</a>51
</form>52
<ul class="flowlist">53
{{range .Rows}}54
<li class="flowrow">55
<div class="flowmain">56
<a class="flowtitle" href="{{.Href}}">{{if .Draft}}<span class="flowdraft">{{t "mr.draft"}}:</span> {{end}}<strong>{{.Title}}</strong></a>57
<p class="flowmeta">58
{{if .PipeHref}}<a class="flowpipe status {{.PipeStatus}}" href="{{.PipeHref}}" title="{{.PipeLabel}}" aria-label="{{.PipeLabel}}"><span class="mark"></span></a>{{end}}59
<span class="flowref">{{.Ref}}</span>60
<span class="flowdot" aria-hidden="true">·</span>61
<span>{{t "list.created" .Created}}{{if .Author}} {{t "list.by"}} {{if .AuthorURL}}<a href="{{.AuthorURL}}">{{.Author}}</a>{{else}}{{.Author}}{{end}}{{end}}</span>62
{{if .Comments}}<span class="flowcomments" aria-label="{{tn .Comments "list.comment" "list.comments"}}"><svg class="ico" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M2.2 2.4A1.4 1.4 0 0 1 3.6 1h8.8A1.4 1.4 0 0 1 13.8 2.4v6.4A1.4 1.4 0 0 1 12.4 10.2H8.1L4.6 13.4V10.2H3.6A1.4 1.4 0 0 1 2.2 8.8V2.4z"/></svg>{{.Comments}}</span>{{end}}63
{{if .Target}}<span class="flowtarget">{{.Target}}</span>{{end}}64
{{if .Confidential}}<span class="pill">{{t "issue.confidential"}}</span>{{end}}65
{{range .Labels}}<span class="lab" style="background:{{.Color}}">{{.Name}}</span>{{end}}66
{{if .Extra}}<span>{{.Extra}}</span>{{end}}67
</p>68
</div>69
<div class="flowside">70
<span class="flowbadge {{.State}}">{{.StateLabel}}</span>71
{{if .Updated}}<span class="flowupdated">{{t "list.updated" .Updated}}</span>{{end}}72
</div>73
</li>74
{{else}}75
<li class="flowempty muted">{{t .EmptyKey}}</li>76
{{end}}77
</ul>78
{{end}}79
19
{{define "mr"}}80
{{define "mr"}}20
{{template "layout-start" .}}81
{{template "layout-start" .}}21
<header class="pagehead"><h1>!{{.MR.Number}} {{.MR.Title}}</h1></header>82
<header class="pagehead"><h1>!{{.MR.Number}} {{.MR.Title}}</h1></header>@@ -1,37 +1,6 @@
1
1
{{define "issues"}}
2
2
{{template "layout-start" .}}
3
<header class="pagehead"><h1>{{t "tab.issues"}}</h1></header>
4
{{if .Issues.CanCreate}}<p><a class="btn" href="/{{.Repo.FullPath}}/-/issues/new">{{t "issue.new"}}</a></p>{{end}}
5
<form class="row" method="get" action="/{{.Repo.FullPath}}/-/issues">
6
<input name="q" value="{{.Issues.Query}}" placeholder="{{t "issue.search"}}" aria-label="{{t "issue.search"}}">
7
<select name="state">
8
<option value="open"{{if eq .Issues.State "open"}} selected{{end}}>{{t "issue.open"}}</option>
9
<option value="closed"{{if eq .Issues.State "closed"}} selected{{end}}>{{t "issue.closed"}}</option>
10
<option value="all"{{if eq .Issues.State "all"}} selected{{end}}>{{t "issue.all"}}</option>
11
</select>
12
<select name="label">
13
<option value="">{{t "issue.anyLabel"}}</option>
14
{{range .Issues.Labels}}<option value="{{.Name}}"{{if eq .Name $.Issues.Label}} selected{{end}}>{{.Name}}</option>{{end}}
15
</select>
16
<select name="assignee">
17
<option value="">{{t "issue.anyAssignee"}}</option>
18
{{range .Issues.People}}<option value="{{.Name}}"{{if eq .Name $.Issues.Assignee}} selected{{end}}>{{.Name}}</option>{{end}}
19
</select>
20
<button type="submit">{{t "issue.filter"}}</button>
21
</form>
22
<ul class="issuelist">
23
{{range .Issues.List}}
24
<li>
25
<a href="/{{$.Repo.FullPath}}/-/issues/{{.Number}}"><strong>#{{.Number}}</strong> {{.Title}}</a>
26
{{if eq .Status "closed"}}<span class="pill">{{t "issue.closed"}}</span>{{else}}<span class="pill">{{t "issue.open"}}</span>{{end}}
27
{{if .Confidential}}<span class="pill">{{t "issue.confidential"}}</span>{{end}}
28
{{range .Labels}}<span class="lab" style="background:{{.Color}}">{{.Name}}</span>{{end}}
29
<span class="muted">{{if .AuthorURL}}<a href="{{.AuthorURL}}">{{.Author}}</a>{{else}}{{.Author}}{{end}}{{if .Assignees}} · {{.Assignees}}{{end}}{{if .Milestone}} · {{.Milestone}}{{end}}{{if .Due}} · {{.Due}}{{end}}</span>
30
</li>
31
{{else}}
32
<li class="muted">{{t "issue.none"}}</li>
33
{{end}}
34
</ul>
3
{{template "flowlist" .Flow}}
35
4
{{if .CanAdmin}}
36
5
<h2>{{t "issue.addLabel"}}</h2>
37
6
<form class="row" method="post" action="/{{.Repo.FullPath}}/-/issues/labels">
@@ -1,37 +1,6 @@1
{{define "issues"}}1
{{define "issues"}}2
{{template "layout-start" .}}2
{{template "layout-start" .}}3
<header class="pagehead"><h1>{{t "tab.issues"}}</h1></header>3
{{template "flowlist" .Flow}}4
{{if .Issues.CanCreate}}<p><a class="btn" href="/{{.Repo.FullPath}}/-/issues/new">{{t "issue.new"}}</a></p>{{end}}5
<form class="row" method="get" action="/{{.Repo.FullPath}}/-/issues">6
<input name="q" value="{{.Issues.Query}}" placeholder="{{t "issue.search"}}" aria-label="{{t "issue.search"}}">7
<select name="state">8
<option value="open"{{if eq .Issues.State "open"}} selected{{end}}>{{t "issue.open"}}</option>9
<option value="closed"{{if eq .Issues.State "closed"}} selected{{end}}>{{t "issue.closed"}}</option>10
<option value="all"{{if eq .Issues.State "all"}} selected{{end}}>{{t "issue.all"}}</option>11
</select>12
<select name="label">13
<option value="">{{t "issue.anyLabel"}}</option>14
{{range .Issues.Labels}}<option value="{{.Name}}"{{if eq .Name $.Issues.Label}} selected{{end}}>{{.Name}}</option>{{end}}15
</select>16
<select name="assignee">17
<option value="">{{t "issue.anyAssignee"}}</option>18
{{range .Issues.People}}<option value="{{.Name}}"{{if eq .Name $.Issues.Assignee}} selected{{end}}>{{.Name}}</option>{{end}}19
</select>20
<button type="submit">{{t "issue.filter"}}</button>21
</form>22
<ul class="issuelist">23
{{range .Issues.List}}24
<li>25
<a href="/{{$.Repo.FullPath}}/-/issues/{{.Number}}"><strong>#{{.Number}}</strong> {{.Title}}</a>26
{{if eq .Status "closed"}}<span class="pill">{{t "issue.closed"}}</span>{{else}}<span class="pill">{{t "issue.open"}}</span>{{end}}27
{{if .Confidential}}<span class="pill">{{t "issue.confidential"}}</span>{{end}}28
{{range .Labels}}<span class="lab" style="background:{{.Color}}">{{.Name}}</span>{{end}}29
<span class="muted">{{if .AuthorURL}}<a href="{{.AuthorURL}}">{{.Author}}</a>{{else}}{{.Author}}{{end}}{{if .Assignees}} · {{.Assignees}}{{end}}{{if .Milestone}} · {{.Milestone}}{{end}}{{if .Due}} · {{.Due}}{{end}}</span>30
</li>31
{{else}}32
<li class="muted">{{t "issue.none"}}</li>33
{{end}}34
</ul>35
{{if .CanAdmin}}4
{{if .CanAdmin}}36
<h2>{{t "issue.addLabel"}}</h2>5
<h2>{{t "issue.addLabel"}}</h2>37
<form class="row" method="post" action="/{{.Repo.FullPath}}/-/issues/labels">6
<form class="row" method="post" action="/{{.Repo.FullPath}}/-/issues/labels">