@@ -389,8 +389,10 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
389
389
filterMode = models .FilterModeMention
390
390
case "review_requested" :
391
391
filterMode = models .FilterModeReviewRequested
392
- case "your_repositories" : // filterMode already set to All
392
+ case "your_repositories" :
393
+ fallthrough
393
394
default :
395
+ filterMode = models .FilterModeYourRepositories
394
396
viewType = "your_repositories"
395
397
}
396
398
@@ -420,6 +422,26 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
420
422
User : ctx .User ,
421
423
}
422
424
425
+ // Search all repositories which the given user or team
426
+ // has write permissions.
427
+ repoOpts := & models.SearchRepoOptions {
428
+ Actor : ctx .User ,
429
+ OwnerID : ctx .User .ID ,
430
+ Private : true ,
431
+ AllPublic : false ,
432
+ AllLimited : false ,
433
+ }
434
+
435
+ if ctxUser .IsOrganization () && ctx .Org .Team != nil {
436
+ repoOpts .TeamID = ctx .Org .Team .ID
437
+ }
438
+
439
+ userRepoIDs , _ , err := models .SearchRepositoryIDs (repoOpts )
440
+ if err != nil {
441
+ ctx .ServerError ("models.SearchRepositoryIDs: %v" , err )
442
+ return
443
+ }
444
+
423
445
switch filterMode {
424
446
case models .FilterModeAll :
425
447
case models .FilterModeAssign :
@@ -430,6 +452,13 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
430
452
opts .MentionedID = ctx .User .ID
431
453
case models .FilterModeReviewRequested :
432
454
opts .ReviewRequestedID = ctx .User .ID
455
+ case models .FilterModeYourRepositories :
456
+ if ctxUser .IsOrganization () && ctx .Org .Team != nil {
457
+ // Fixes a issue whereby the user's ID would be used
458
+ // to check if it's in the team(which possible isn't the case).
459
+ opts .User = nil
460
+ }
461
+ opts .RepoIDs = userRepoIDs
433
462
}
434
463
435
464
// keyword holds the search term entered into the search field.
@@ -553,6 +582,7 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
553
582
statsOpts := models.UserIssueStatsOptions {
554
583
UserID : ctx .User .ID ,
555
584
FilterMode : filterMode ,
585
+ RepoIDs : userRepoIDs ,
556
586
IsPull : isPullList ,
557
587
IsClosed : isShowClosed ,
558
588
IssueIDs : issueIDsFromSearch ,
@@ -564,6 +594,10 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
564
594
if len (repoIDs ) > 0 {
565
595
statsOpts .RepoIDs = repoIDs
566
596
}
597
+ // Detect when we only should search by team.
598
+ if opts .User == nil {
599
+ statsOpts .UserID = 0
600
+ }
567
601
issueStats , err = models .GetUserIssueStats (statsOpts )
568
602
if err != nil {
569
603
ctx .ServerError ("GetUserIssueStats Shown" , err )
0 commit comments