Skip to content

Commit 2a7a11d

Browse files
authored
Merge branch 'master' into 13682-review-requested-filter
2 parents 8820bb9 + 9cc5a89 commit 2a7a11d

File tree

4 files changed

+56
-43
lines changed

4 files changed

+56
-43
lines changed

modules/markup/html.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ var (
4343
// sha1CurrentPattern matches string that represents a commit SHA, e.g. d8a994ef243349f321568f9e36d5c3f444b99cae
4444
// Although SHA1 hashes are 40 chars long, the regex matches the hash from 7 to 40 chars in length
4545
// so that abbreviated hash links can be used as well. This matches git and github useability.
46-
sha1CurrentPattern = regexp.MustCompile(`(?:\s|^|\(|\[)([0-9a-f]{7,40})(?:\s|$|\)|\]|\.(\s|$))`)
46+
sha1CurrentPattern = regexp.MustCompile(`(?:\s|^|\(|\[)([0-9a-f]{7,40})(?:\s|$|\)|\]|[.,](\s|$))`)
4747

4848
// shortLinkPattern matches short but difficult to parse [[name|link|arg=test]] syntax
4949
shortLinkPattern = regexp.MustCompile(`\[\[(.*?)\]\](\w*)`)

modules/markup/html_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ func TestRender_Commits(t *testing.T) {
4646
test("/home/gitea/"+sha, "<p>/home/gitea/"+sha+"</p>")
4747
test("deadbeef", `<p>deadbeef</p>`)
4848
test("d27ace93", `<p>d27ace93</p>`)
49+
test(sha[:14]+".x", `<p>`+sha[:14]+`.x</p>`)
50+
51+
expected14 := `<a href="` + commit[:len(commit)-(40-14)] + `" rel="nofollow"><code>` + sha[:10] + `</code></a>`
52+
test(sha[:14]+".", `<p>`+expected14+`.</p>`)
53+
test(sha[:14]+",", `<p>`+expected14+`,</p>`)
54+
test("["+sha[:14]+"]", `<p>[`+expected14+`]</p>`)
4955
}
5056

5157
func TestRender_CrossReferences(t *testing.T) {

routers/user/home.go

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -364,23 +364,19 @@ func Issues(ctx *context.Context) {
364364
filterMode = models.FilterModeAll
365365
)
366366

367-
if ctxUser.IsOrganization() {
367+
viewType = ctx.Query("type")
368+
switch viewType {
369+
case "assigned":
370+
filterMode = models.FilterModeAssign
371+
case "created_by":
372+
filterMode = models.FilterModeCreate
373+
case "mentioned":
374+
filterMode = models.FilterModeMention
375+
case "review_requested":
376+
filterMode = models.FilterModeReviewRequested
377+
case "your_repositories": // filterMode already set to All
378+
default:
368379
viewType = "your_repositories"
369-
} else {
370-
viewType = ctx.Query("type")
371-
switch viewType {
372-
case "assigned":
373-
filterMode = models.FilterModeAssign
374-
case "created_by":
375-
filterMode = models.FilterModeCreate
376-
case "mentioned":
377-
filterMode = models.FilterModeMention
378-
case "review_requested":
379-
filterMode = models.FilterModeReviewRequested
380-
case "your_repositories": // filterMode already set to All
381-
default:
382-
viewType = "your_repositories"
383-
}
384380
}
385381

386382
page := ctx.QueryInt("page")
@@ -455,15 +451,19 @@ func Issues(ctx *context.Context) {
455451
case models.FilterModeAll:
456452
opts.RepoIDs = userRepoIDs
457453
case models.FilterModeAssign:
458-
opts.AssigneeID = ctxUser.ID
454+
opts.AssigneeID = ctx.User.ID
459455
case models.FilterModeCreate:
460-
opts.PosterID = ctxUser.ID
456+
opts.PosterID = ctx.User.ID
461457
case models.FilterModeMention:
462458
opts.MentionedID = ctxUser.ID
463459
case models.FilterModeReviewRequested:
464460
opts.ReviewRequestedID = ctxUser.ID
465461
}
466462

463+
if ctxUser.IsOrganization() {
464+
opts.RepoIDs = userRepoIDs
465+
}
466+
467467
var forceEmpty bool
468468
var issueIDsFromSearch []int64
469469
var keyword = strings.Trim(ctx.Query("q"), " ")
@@ -579,7 +579,7 @@ func Issues(ctx *context.Context) {
579579
}
580580

581581
userIssueStatsOpts := models.UserIssueStatsOptions{
582-
UserID: ctxUser.ID,
582+
UserID: ctx.User.ID,
583583
UserRepoIDs: userRepoIDs,
584584
FilterMode: filterMode,
585585
IsPull: isPullList,
@@ -589,6 +589,9 @@ func Issues(ctx *context.Context) {
589589
if len(repoIDs) > 0 {
590590
userIssueStatsOpts.UserRepoIDs = repoIDs
591591
}
592+
if ctxUser.IsOrganization() {
593+
userIssueStatsOpts.RepoIDs = userRepoIDs
594+
}
592595
userIssueStats, err := models.GetUserIssueStats(userIssueStatsOpts)
593596
if err != nil {
594597
ctx.ServerError("GetUserIssueStats User", err)
@@ -598,7 +601,7 @@ func Issues(ctx *context.Context) {
598601
var shownIssueStats *models.IssueStats
599602
if !forceEmpty {
600603
statsOpts := models.UserIssueStatsOptions{
601-
UserID: ctxUser.ID,
604+
UserID: ctx.User.ID,
602605
UserRepoIDs: userRepoIDs,
603606
FilterMode: filterMode,
604607
IsPull: isPullList,
@@ -608,6 +611,8 @@ func Issues(ctx *context.Context) {
608611
}
609612
if len(repoIDs) > 0 {
610613
statsOpts.RepoIDs = repoIDs
614+
} else if ctxUser.IsOrganization() {
615+
statsOpts.RepoIDs = userRepoIDs
611616
}
612617
shownIssueStats, err = models.GetUserIssueStats(statsOpts)
613618
if err != nil {
@@ -620,15 +625,19 @@ func Issues(ctx *context.Context) {
620625

621626
var allIssueStats *models.IssueStats
622627
if !forceEmpty {
623-
allIssueStats, err = models.GetUserIssueStats(models.UserIssueStatsOptions{
624-
UserID: ctxUser.ID,
628+
allIssueStatsOpts := models.UserIssueStatsOptions{
629+
UserID: ctx.User.ID,
625630
UserRepoIDs: userRepoIDs,
626631
FilterMode: filterMode,
627632
IsPull: isPullList,
628633
IsClosed: isShowClosed,
629634
IssueIDs: issueIDsFromSearch,
630635
LabelIDs: opts.LabelIDs,
631-
})
636+
}
637+
if ctxUser.IsOrganization() {
638+
allIssueStatsOpts.RepoIDs = userRepoIDs
639+
}
640+
allIssueStats, err = models.GetUserIssueStats(allIssueStatsOpts)
632641
if err != nil {
633642
ctx.ServerError("GetUserIssueStats All", err)
634643
return

templates/user/dashboard/issues.tmpl

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,24 @@
99
{{.i18n.Tr "home.issues.in_your_repos"}}
1010
<strong class="ui right">{{CountFmt .IssueStats.YourRepositoriesCount}}</strong>
1111
</a>
12-
{{if not .ContextUser.IsOrganization}}
13-
<a class="{{if eq .ViewType "assigned"}}ui basic blue button{{end}} item" href="{{.Link}}?type=assigned&repos=[{{range $.RepoIDs}}{{.}}%2C{{end}}]&sort={{$.SortType}}&state={{.State}}">
14-
{{.i18n.Tr "repo.issues.filter_type.assigned_to_you"}}
15-
<strong class="ui right">{{CountFmt .IssueStats.AssignCount}}</strong>
16-
</a>
17-
<a class="{{if eq .ViewType "created_by"}}ui basic blue button{{end}} item" href="{{.Link}}?type=created_by&repos=[{{range $.RepoIDs}}{{.}}%2C{{end}}]&sort={{$.SortType}}&state={{.State}}">
18-
{{.i18n.Tr "repo.issues.filter_type.created_by_you"}}
19-
<strong class="ui right">{{CountFmt .IssueStats.CreateCount}}</strong>
20-
</a>
21-
<a class="{{if eq .ViewType "mentioned"}}ui basic blue button{{end}} item" href="{{.Link}}?type=mentioned&repos=[{{range $.RepoIDs}}{{.}}%2C{{end}}]&sort={{$.SortType}}&state={{.State}}">
22-
{{.i18n.Tr "repo.issues.filter_type.mentioning_you"}}
23-
<strong class="ui right">{{CountFmt .IssueStats.MentionCount}}</strong>
12+
<a class="{{if eq .ViewType "assigned"}}ui basic blue button{{end}} item" href="{{.Link}}?type=assigned&repos=[{{range $.RepoIDs}}{{.}}%2C{{end}}]&sort={{$.SortType}}&state={{.State}}">
13+
{{.i18n.Tr "repo.issues.filter_type.assigned_to_you"}}
14+
<strong class="ui right">{{CountFmt .IssueStats.AssignCount}}</strong>
15+
</a>
16+
<a class="{{if eq .ViewType "created_by"}}ui basic blue button{{end}} item" href="{{.Link}}?type=created_by&repos=[{{range $.RepoIDs}}{{.}}%2C{{end}}]&sort={{$.SortType}}&state={{.State}}">
17+
{{.i18n.Tr "repo.issues.filter_type.created_by_you"}}
18+
<strong class="ui right">{{CountFmt .IssueStats.CreateCount}}</strong>
19+
</a>
20+
<a class="{{if eq .ViewType "mentioned"}}ui basic blue button{{end}} item" href="{{.Link}}?type=mentioned&repos=[{{range $.RepoIDs}}{{.}}%2C{{end}}]&sort={{$.SortType}}&state={{.State}}">
21+
{{.i18n.Tr "repo.issues.filter_type.mentioning_you"}}
22+
<strong class="ui right">{{CountFmt .IssueStats.MentionCount}}</strong>
23+
</a>
24+
{{if .PageIsPulls}}
25+
<a class="{{if eq .ViewType "review_requested"}}ui basic blue button{{end}} item" href="{{.Link}}?type=review_requested&repos=[{{range $.RepoIDs}}{{.}}%2C{{end}}]&sort={{$.SortType}}&state={{.State}}">
26+
{{.i18n.Tr "repo.issues.filter_type.review_requested"}}
27+
<strong class="ui right">{{CountFmt .IssueStats.ReviewRequestedCount}}</strong>
2428
</a>
25-
{{if .PageIsPulls}}
26-
<a class="{{if eq .ViewType "review_requested"}}ui basic blue button{{end}} item" href="{{.Link}}?type=review_requested&repos=[{{range $.RepoIDs}}{{.}}%2C{{end}}]&sort={{$.SortType}}&state={{.State}}">
27-
{{.i18n.Tr "repo.issues.filter_type.review_requested"}}
28-
<strong class="ui right">{{CountFmt .IssueStats.ReviewRequestedCount}}</strong>
29-
</a>
30-
{{end}}
31-
{{end}}
29+
{{end}}
3230
<div class="ui divider"></div>
3331
<a class="{{if not $.RepoIDs}}ui basic blue button{{end}} repo name item" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&q={{$.Keyword}}">
3432
<span class="text truncate">All</span>

0 commit comments

Comments
 (0)