@@ -362,7 +362,7 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
362
362
var (
363
363
viewType string
364
364
sortType = ctx .FormString ("sort" )
365
- filterMode = models . FilterModeAll
365
+ filterMode int
366
366
)
367
367
368
368
// --------------------------------------------------------------------------------
@@ -388,8 +388,10 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
388
388
filterMode = models .FilterModeMention
389
389
case "review_requested" :
390
390
filterMode = models .FilterModeReviewRequested
391
- case "your_repositories" : // filterMode already set to All
391
+ case "your_repositories" :
392
+ fallthrough
392
393
default :
394
+ filterMode = models .FilterModeYourRepositories
393
395
viewType = "your_repositories"
394
396
}
395
397
@@ -419,6 +421,30 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
419
421
User : ctx .Doer ,
420
422
}
421
423
424
+ // Search all repositories which
425
+ //
426
+ // As user:
427
+ // - Owns the repository.
428
+ // - Have collaborator permissions in repository.
429
+ //
430
+ // As org:
431
+ // - Owns the repository.
432
+ //
433
+ // As team:
434
+ // - Team org's owns the repository.
435
+ // - Team has read permission to repository.
436
+ repoOpts := & models.SearchRepoOptions {
437
+ Actor : ctx .Doer ,
438
+ OwnerID : ctx .Doer .ID ,
439
+ Private : true ,
440
+ AllPublic : false ,
441
+ AllLimited : false ,
442
+ }
443
+
444
+ if ctxUser .IsOrganization () && ctx .Org .Team != nil {
445
+ repoOpts .TeamID = ctx .Org .Team .ID
446
+ }
447
+
422
448
switch filterMode {
423
449
case models .FilterModeAll :
424
450
case models .FilterModeAssign :
@@ -429,6 +455,19 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
429
455
opts .MentionedID = ctx .Doer .ID
430
456
case models .FilterModeReviewRequested :
431
457
opts .ReviewRequestedID = ctx .Doer .ID
458
+ case models .FilterModeYourRepositories :
459
+ if ctxUser .IsOrganization () && ctx .Org .Team != nil {
460
+ // Fixes a issue whereby the user's ID would be used
461
+ // to check if it's in the team(which possible isn't the case).
462
+ opts .User = nil
463
+ }
464
+ userRepoIDs , _ , err := models .SearchRepositoryIDs (repoOpts )
465
+ if err != nil {
466
+ ctx .ServerError ("models.SearchRepositoryIDs: %v" , err )
467
+ return
468
+ }
469
+
470
+ opts .RepoIDs = userRepoIDs
432
471
}
433
472
434
473
// keyword holds the search term entered into the search field.
@@ -560,8 +599,12 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
560
599
Org : org ,
561
600
Team : team ,
562
601
}
563
- if len (repoIDs ) > 0 {
564
- statsOpts .RepoIDs = repoIDs
602
+ if filterMode == models .FilterModeYourRepositories {
603
+ statsOpts .RepoCond = models .SearchRepositoryCondition (repoOpts )
604
+ }
605
+ // Detect when we only should search by team.
606
+ if opts .User == nil {
607
+ statsOpts .UserID = 0
565
608
}
566
609
issueStats , err = models .GetUserIssueStats (statsOpts )
567
610
if err != nil {
0 commit comments