@@ -26,7 +26,6 @@ import (
26
26
"code.gitea.io/gitea/modules/container"
27
27
"code.gitea.io/gitea/modules/context"
28
28
issue_indexer "code.gitea.io/gitea/modules/indexer/issues"
29
- "code.gitea.io/gitea/modules/json"
30
29
"code.gitea.io/gitea/modules/log"
31
30
"code.gitea.io/gitea/modules/markup"
32
31
"code.gitea.io/gitea/modules/markup/markdown"
@@ -350,7 +349,6 @@ func Pulls(ctx *context.Context) {
350
349
351
350
ctx .Data ["Title" ] = ctx .Tr ("pull_requests" )
352
351
ctx .Data ["PageIsPulls" ] = true
353
- ctx .Data ["SingleRepoAction" ] = "pull"
354
352
buildIssueOverview (ctx , unit .TypePullRequests )
355
353
}
356
354
@@ -364,7 +362,6 @@ func Issues(ctx *context.Context) {
364
362
365
363
ctx .Data ["Title" ] = ctx .Tr ("issues" )
366
364
ctx .Data ["PageIsIssues" ] = true
367
- ctx .Data ["SingleRepoAction" ] = "issue"
368
365
buildIssueOverview (ctx , unit .TypeIssues )
369
366
}
370
367
@@ -490,6 +487,13 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
490
487
opts .RepoIDs = []int64 {0 }
491
488
}
492
489
}
490
+ if ctx .Doer .ID == ctxUser .ID && filterMode != issues_model .FilterModeYourRepositories {
491
+ // If the doer is the same as the context user, which means the doer is viewing his own dashboard,
492
+ // it's not enough to show the repos that the doer owns or has been explicitly granted access to,
493
+ // because the doer may create issues or be mentioned in any public repo.
494
+ // So we need search issues in all public repos.
495
+ opts .AllPublic = true
496
+ }
493
497
494
498
switch filterMode {
495
499
case issues_model .FilterModeAll :
@@ -514,14 +518,6 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
514
518
isShowClosed := ctx .FormString ("state" ) == "closed"
515
519
opts .IsClosed = util .OptionalBoolOf (isShowClosed )
516
520
517
- // Filter repos and count issues in them. Count will be used later.
518
- // USING NON-FINAL STATE OF opts FOR A QUERY.
519
- issueCountByRepo , err := issue_indexer .CountIssuesByRepo (ctx , issue_indexer .ToSearchOptions (keyword , opts ))
520
- if err != nil {
521
- ctx .ServerError ("CountIssuesByRepo" , err )
522
- return
523
- }
524
-
525
521
// Make sure page number is at least 1. Will be posted to ctx.Data.
526
522
page := ctx .FormInt ("page" )
527
523
if page <= 1 {
@@ -546,17 +542,6 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
546
542
}
547
543
opts .LabelIDs = labelIDs
548
544
549
- // Parse ctx.FormString("repos") and remember matched repo IDs for later.
550
- // Gets set when clicking filters on the issues overview page.
551
- selectedRepoIDs := getRepoIDs (ctx .FormString ("repos" ))
552
- // Remove repo IDs that are not accessible to the user.
553
- selectedRepoIDs = slices .DeleteFunc (selectedRepoIDs , func (v int64 ) bool {
554
- return ! accessibleRepos .Contains (v )
555
- })
556
- if len (selectedRepoIDs ) > 0 {
557
- opts .RepoIDs = selectedRepoIDs
558
- }
559
-
560
545
// ------------------------------
561
546
// Get issues as defined by opts.
562
547
// ------------------------------
@@ -577,41 +562,6 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
577
562
}
578
563
}
579
564
580
- // ----------------------------------
581
- // Add repository pointers to Issues.
582
- // ----------------------------------
583
-
584
- // Remove repositories that should not be shown,
585
- // which are repositories that have no issues and are not selected by the user.
586
- selectedRepos := container .SetOf (selectedRepoIDs ... )
587
- for k , v := range issueCountByRepo {
588
- if v == 0 && ! selectedRepos .Contains (k ) {
589
- delete (issueCountByRepo , k )
590
- }
591
- }
592
-
593
- // showReposMap maps repository IDs to their Repository pointers.
594
- showReposMap , err := loadRepoByIDs (ctx , ctxUser , issueCountByRepo , unitType )
595
- if err != nil {
596
- if repo_model .IsErrRepoNotExist (err ) {
597
- ctx .NotFound ("GetRepositoryByID" , err )
598
- return
599
- }
600
- ctx .ServerError ("loadRepoByIDs" , err )
601
- return
602
- }
603
-
604
- // a RepositoryList
605
- showRepos := repo_model .RepositoryListOfMap (showReposMap )
606
- sort .Sort (showRepos )
607
-
608
- // maps pull request IDs to their CommitStatus. Will be posted to ctx.Data.
609
- for _ , issue := range issues {
610
- if issue .Repo == nil {
611
- issue .Repo = showReposMap [issue .RepoID ]
612
- }
613
- }
614
-
615
565
commitStatuses , lastStatus , err := pull_service .GetIssuesAllCommitStatus (ctx , issues )
616
566
if err != nil {
617
567
ctx .ServerError ("GetIssuesLastCommitStatus" , err )
@@ -621,7 +571,7 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
621
571
// -------------------------------
622
572
// Fill stats to post to ctx.Data.
623
573
// -------------------------------
624
- issueStats , err := getUserIssueStats (ctx , filterMode , issue_indexer .ToSearchOptions (keyword , opts ), ctx . Doer . ID )
574
+ issueStats , err := getUserIssueStats (ctx , ctxUser , filterMode , issue_indexer .ToSearchOptions (keyword , opts ))
625
575
if err != nil {
626
576
ctx .ServerError ("getUserIssueStats" , err )
627
577
return
@@ -634,25 +584,6 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
634
584
} else {
635
585
shownIssues = int (issueStats .ClosedCount )
636
586
}
637
- if len (opts .RepoIDs ) != 0 {
638
- shownIssues = 0
639
- for _ , repoID := range opts .RepoIDs {
640
- shownIssues += int (issueCountByRepo [repoID ])
641
- }
642
- }
643
-
644
- var allIssueCount int64
645
- for _ , issueCount := range issueCountByRepo {
646
- allIssueCount += issueCount
647
- }
648
- ctx .Data ["TotalIssueCount" ] = allIssueCount
649
-
650
- if len (opts .RepoIDs ) == 1 {
651
- repo := showReposMap [opts .RepoIDs [0 ]]
652
- if repo != nil {
653
- ctx .Data ["SingleRepoLink" ] = repo .Link ()
654
- }
655
- }
656
587
657
588
ctx .Data ["IsShowClosed" ] = isShowClosed
658
589
@@ -689,12 +620,9 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
689
620
}
690
621
ctx .Data ["CommitLastStatus" ] = lastStatus
691
622
ctx .Data ["CommitStatuses" ] = commitStatuses
692
- ctx .Data ["Repos" ] = showRepos
693
- ctx .Data ["Counts" ] = issueCountByRepo
694
623
ctx .Data ["IssueStats" ] = issueStats
695
624
ctx .Data ["ViewType" ] = viewType
696
625
ctx .Data ["SortType" ] = sortType
697
- ctx .Data ["RepoIDs" ] = selectedRepoIDs
698
626
ctx .Data ["IsShowClosed" ] = isShowClosed
699
627
ctx .Data ["SelectLabels" ] = selectedLabels
700
628
@@ -704,15 +632,9 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
704
632
ctx .Data ["State" ] = "open"
705
633
}
706
634
707
- // Convert []int64 to string
708
- reposParam , _ := json .Marshal (opts .RepoIDs )
709
-
710
- ctx .Data ["ReposParam" ] = string (reposParam )
711
-
712
635
pager := context .NewPagination (shownIssues , setting .UI .IssuePagingNum , page , 5 )
713
636
pager .AddParam (ctx , "q" , "Keyword" )
714
637
pager .AddParam (ctx , "type" , "ViewType" )
715
- pager .AddParam (ctx , "repos" , "ReposParam" )
716
638
pager .AddParam (ctx , "sort" , "SortType" )
717
639
pager .AddParam (ctx , "state" , "State" )
718
640
pager .AddParam (ctx , "labels" , "SelectLabels" )
@@ -723,55 +645,6 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
723
645
ctx .HTML (http .StatusOK , tplIssues )
724
646
}
725
647
726
- func getRepoIDs (reposQuery string ) []int64 {
727
- if len (reposQuery ) == 0 || reposQuery == "[]" {
728
- return []int64 {}
729
- }
730
- if ! issueReposQueryPattern .MatchString (reposQuery ) {
731
- log .Warn ("issueReposQueryPattern does not match query: %q" , reposQuery )
732
- return []int64 {}
733
- }
734
-
735
- var repoIDs []int64
736
- // remove "[" and "]" from string
737
- reposQuery = reposQuery [1 : len (reposQuery )- 1 ]
738
- // for each ID (delimiter ",") add to int to repoIDs
739
- for _ , rID := range strings .Split (reposQuery , "," ) {
740
- // Ensure nonempty string entries
741
- if rID != "" && rID != "0" {
742
- rIDint64 , err := strconv .ParseInt (rID , 10 , 64 )
743
- if err == nil {
744
- repoIDs = append (repoIDs , rIDint64 )
745
- }
746
- }
747
- }
748
-
749
- return repoIDs
750
- }
751
-
752
- func loadRepoByIDs (ctx * context.Context , ctxUser * user_model.User , issueCountByRepo map [int64 ]int64 , unitType unit.Type ) (map [int64 ]* repo_model.Repository , error ) {
753
- totalRes := make (map [int64 ]* repo_model.Repository , len (issueCountByRepo ))
754
- repoIDs := make ([]int64 , 0 , 500 )
755
- for id := range issueCountByRepo {
756
- if id <= 0 {
757
- continue
758
- }
759
- repoIDs = append (repoIDs , id )
760
- if len (repoIDs ) == 500 {
761
- if err := repo_model .FindReposMapByIDs (ctx , repoIDs , totalRes ); err != nil {
762
- return nil , err
763
- }
764
- repoIDs = repoIDs [:0 ]
765
- }
766
- }
767
- if len (repoIDs ) > 0 {
768
- if err := repo_model .FindReposMapByIDs (ctx , repoIDs , totalRes ); err != nil {
769
- return nil , err
770
- }
771
- }
772
- return totalRes , nil
773
- }
774
-
775
648
// ShowSSHKeys output all the ssh keys of user by uid
776
649
func ShowSSHKeys (ctx * context.Context ) {
777
650
keys , err := db .Find [asymkey_model.PublicKey ](ctx , asymkey_model.FindPublicKeyOptions {
@@ -888,8 +761,15 @@ func UsernameSubRoute(ctx *context.Context) {
888
761
}
889
762
}
890
763
891
- func getUserIssueStats (ctx * context.Context , filterMode int , opts * issue_indexer.SearchOptions , doerID int64 ) (* issues_model.IssueStats , error ) {
764
+ func getUserIssueStats (ctx * context.Context , ctxUser * user_model.User , filterMode int , opts * issue_indexer.SearchOptions ) (* issues_model.IssueStats , error ) {
765
+ doerID := ctx .Doer .ID
766
+
892
767
opts = opts .Copy (func (o * issue_indexer.SearchOptions ) {
768
+ // If the doer is the same as the context user, which means the doer is viewing his own dashboard,
769
+ // it's not enough to show the repos that the doer owns or has been explicitly granted access to,
770
+ // because the doer may create issues or be mentioned in any public repo.
771
+ // So we need search issues in all public repos.
772
+ o .AllPublic = doerID == ctxUser .ID
893
773
o .AssigneeID = nil
894
774
o .PosterID = nil
895
775
o .MentionID = nil
@@ -905,7 +785,10 @@ func getUserIssueStats(ctx *context.Context, filterMode int, opts *issue_indexer
905
785
{
906
786
openClosedOpts := opts .Copy ()
907
787
switch filterMode {
908
- case issues_model .FilterModeAll , issues_model .FilterModeYourRepositories :
788
+ case issues_model .FilterModeAll :
789
+ // no-op
790
+ case issues_model .FilterModeYourRepositories :
791
+ openClosedOpts .AllPublic = false
909
792
case issues_model .FilterModeAssign :
910
793
openClosedOpts .AssigneeID = & doerID
911
794
case issues_model .FilterModeCreate :
@@ -929,7 +812,7 @@ func getUserIssueStats(ctx *context.Context, filterMode int, opts *issue_indexer
929
812
}
930
813
}
931
814
932
- ret .YourRepositoriesCount , err = issue_indexer .CountIssues (ctx , opts )
815
+ ret .YourRepositoriesCount , err = issue_indexer .CountIssues (ctx , opts . Copy ( func ( o * issue_indexer. SearchOptions ) { o . AllPublic = false }) )
933
816
if err != nil {
934
817
return nil , err
935
818
}
0 commit comments