@@ -31,6 +31,7 @@ import (
31
31
"code.gitea.io/gitea/modules/markup/markdown"
32
32
"code.gitea.io/gitea/modules/optional"
33
33
"code.gitea.io/gitea/modules/setting"
34
+ "code.gitea.io/gitea/modules/util"
34
35
"code.gitea.io/gitea/routers/web/feed"
35
36
"code.gitea.io/gitea/services/context"
36
37
feed_service "code.gitea.io/gitea/services/feed"
@@ -375,16 +376,8 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
375
376
return
376
377
}
377
378
378
- var (
379
- viewType string
380
- sortType = ctx .FormString ("sort" )
381
- filterMode int
382
- )
383
-
384
379
// Default to recently updated, unlike repository issues list
385
- if sortType == "" {
386
- sortType = "recentupdate"
387
- }
380
+ sortType := util .IfZero (ctx .FormString ("sort" ), "recentupdate" )
388
381
389
382
// --------------------------------------------------------------------------------
390
383
// Distinguish User from Organization.
@@ -399,7 +392,8 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
399
392
400
393
// TODO: distinguish during routing
401
394
402
- viewType = ctx .FormString ("type" )
395
+ viewType := ctx .FormString ("type" )
396
+ var filterMode int
403
397
switch viewType {
404
398
case "assigned" :
405
399
filterMode = issues_model .FilterModeAssign
@@ -443,6 +437,12 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
443
437
Team : team ,
444
438
User : ctx .Doer ,
445
439
}
440
+ // Get filter by author id & assignee id
441
+ // FIXME: this feature doesn't work at the moment, because frontend can't use a "user-remote-search" dropdown directly
442
+ // the existing "/posters" handlers doesn't work for this case, it is unable to list the related users correctly.
443
+ // In the future, we need something like github: "author:user1" to accept usernames directly.
444
+ opts .PosterID , _ = strconv .ParseInt (ctx .FormString ("poster" ), 10 , 64 )
445
+ opts .AssigneeID , _ = strconv .ParseInt (ctx .FormString ("assignee" ), 10 , 64 )
446
446
447
447
isFuzzy := ctx .FormBool ("fuzzy" )
448
448
@@ -573,8 +573,21 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
573
573
// -------------------------------
574
574
// Fill stats to post to ctx.Data.
575
575
// -------------------------------
576
- issueStats , err := getUserIssueStats (ctx , ctxUser , filterMode , issue_indexer .ToSearchOptions (keyword , opts ).Copy (
577
- func (o * issue_indexer.SearchOptions ) { o .IsFuzzyKeyword = isFuzzy },
576
+ issueStats , err := getUserIssueStats (ctx , filterMode , issue_indexer .ToSearchOptions (keyword , opts ).Copy (
577
+ func (o * issue_indexer.SearchOptions ) {
578
+ o .IsFuzzyKeyword = isFuzzy
579
+ // If the doer is the same as the context user, which means the doer is viewing his own dashboard,
580
+ // it's not enough to show the repos that the doer owns or has been explicitly granted access to,
581
+ // because the doer may create issues or be mentioned in any public repo.
582
+ // So we need search issues in all public repos.
583
+ o .AllPublic = ctx .Doer .ID == ctxUser .ID
584
+ // TODO: to make it work with poster/assignee filter
585
+ o .AssigneeID = nil
586
+ o .PosterID = nil
587
+ o .MentionID = nil
588
+ o .ReviewRequestedID = nil
589
+ o .ReviewedID = nil
590
+ },
578
591
))
579
592
if err != nil {
580
593
ctx .ServerError ("getUserIssueStats" , err )
@@ -630,6 +643,8 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
630
643
ctx .Data ["IsShowClosed" ] = isShowClosed
631
644
ctx .Data ["SelectLabels" ] = selectedLabels
632
645
ctx .Data ["IsFuzzy" ] = isFuzzy
646
+ ctx .Data ["SearchFilterPosterID" ] = util .Iif [any ](opts .PosterID != 0 , opts .PosterID , nil )
647
+ ctx .Data ["SearchFilterAssigneeID" ] = util .Iif [any ](opts .AssigneeID != 0 , opts .AssigneeID , nil )
633
648
634
649
if isShowClosed {
635
650
ctx .Data ["State" ] = "closed"
@@ -643,7 +658,13 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
643
658
pager .AddParamString ("sort" , sortType )
644
659
pager .AddParamString ("state" , fmt .Sprint (ctx .Data ["State" ]))
645
660
pager .AddParamString ("labels" , selectedLabels )
646
- pager .AddParamString ("fuzzy" , fmt .Sprintf ("%v" , isFuzzy ))
661
+ pager .AddParamString ("fuzzy" , fmt .Sprint (isFuzzy ))
662
+ if opts .PosterID != 0 {
663
+ pager .AddParamString ("poster" , fmt .Sprint (opts .PosterID ))
664
+ }
665
+ if opts .AssigneeID != 0 {
666
+ pager .AddParamString ("assignee" , fmt .Sprint (opts .AssigneeID ))
667
+ }
647
668
ctx .Data ["Page" ] = pager
648
669
649
670
ctx .HTML (http .StatusOK , tplIssues )
@@ -768,27 +789,10 @@ func UsernameSubRoute(ctx *context.Context) {
768
789
}
769
790
}
770
791
771
- func getUserIssueStats (ctx * context.Context , ctxUser * user_model.User , filterMode int , opts * issue_indexer.SearchOptions ) (* issues_model.IssueStats , error ) {
792
+ func getUserIssueStats (ctx * context.Context , filterMode int , opts * issue_indexer.SearchOptions ) (ret * issues_model.IssueStats , err error ) {
793
+ ret = & issues_model.IssueStats {}
772
794
doerID := ctx .Doer .ID
773
795
774
- opts = opts .Copy (func (o * issue_indexer.SearchOptions ) {
775
- // If the doer is the same as the context user, which means the doer is viewing his own dashboard,
776
- // it's not enough to show the repos that the doer owns or has been explicitly granted access to,
777
- // because the doer may create issues or be mentioned in any public repo.
778
- // So we need search issues in all public repos.
779
- o .AllPublic = doerID == ctxUser .ID
780
- o .AssigneeID = nil
781
- o .PosterID = nil
782
- o .MentionID = nil
783
- o .ReviewRequestedID = nil
784
- o .ReviewedID = nil
785
- })
786
-
787
- var (
788
- err error
789
- ret = & issues_model.IssueStats {}
790
- )
791
-
792
796
{
793
797
openClosedOpts := opts .Copy ()
794
798
switch filterMode {
0 commit comments