@@ -31,6 +31,7 @@ import (
3131 "code.gitea.io/gitea/modules/markup/markdown"
3232 "code.gitea.io/gitea/modules/optional"
3333 "code.gitea.io/gitea/modules/setting"
34+ "code.gitea.io/gitea/modules/util"
3435 "code.gitea.io/gitea/routers/web/feed"
3536 "code.gitea.io/gitea/services/context"
3637 feed_service "code.gitea.io/gitea/services/feed"
@@ -375,16 +376,8 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
375376 return
376377 }
377378
378- var (
379- viewType string
380- sortType = ctx .FormString ("sort" )
381- filterMode int
382- )
383-
384379 // Default to recently updated, unlike repository issues list
385- if sortType == "" {
386- sortType = "recentupdate"
387- }
380+ sortType := util .IfZero (ctx .FormString ("sort" ), "recentupdate" )
388381
389382 // --------------------------------------------------------------------------------
390383 // Distinguish User from Organization.
@@ -399,7 +392,8 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
399392
400393 // TODO: distinguish during routing
401394
402- viewType = ctx .FormString ("type" )
395+ viewType := ctx .FormString ("type" )
396+ var filterMode int
403397 switch viewType {
404398 case "assigned" :
405399 filterMode = issues_model .FilterModeAssign
@@ -443,6 +437,12 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
443437 Team : team ,
444438 User : ctx .Doer ,
445439 }
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 )
446446
447447 isFuzzy := ctx .FormBool ("fuzzy" )
448448
@@ -573,8 +573,21 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
573573 // -------------------------------
574574 // Fill stats to post to ctx.Data.
575575 // -------------------------------
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+ },
578591 ))
579592 if err != nil {
580593 ctx .ServerError ("getUserIssueStats" , err )
@@ -630,6 +643,8 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
630643 ctx .Data ["IsShowClosed" ] = isShowClosed
631644 ctx .Data ["SelectLabels" ] = selectedLabels
632645 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 )
633648
634649 if isShowClosed {
635650 ctx .Data ["State" ] = "closed"
@@ -643,7 +658,13 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
643658 pager .AddParamString ("sort" , sortType )
644659 pager .AddParamString ("state" , fmt .Sprint (ctx .Data ["State" ]))
645660 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+ }
647668 ctx .Data ["Page" ] = pager
648669
649670 ctx .HTML (http .StatusOK , tplIssues )
@@ -768,27 +789,10 @@ func UsernameSubRoute(ctx *context.Context) {
768789 }
769790}
770791
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 {}
772794 doerID := ctx .Doer .ID
773795
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-
792796 {
793797 openClosedOpts := opts .Copy ()
794798 switch filterMode {
0 commit comments