@@ -197,7 +197,7 @@ func Milestones(ctx *context.Context) {
197
197
if issueReposQueryPattern .MatchString (reposQuery ) {
198
198
// remove "[" and "]" from string
199
199
reposQuery = reposQuery [1 : len (reposQuery )- 1 ]
200
- //for each ID (delimiter ",") add to int to repoIDs
200
+ // for each ID (delimiter ",") add to int to repoIDs
201
201
202
202
for _ , rID := range strings .Split (reposQuery , "," ) {
203
203
// Ensure nonempty string entries
@@ -350,7 +350,6 @@ func Issues(ctx *context.Context) {
350
350
var issueReposQueryPattern = regexp .MustCompile (`^\[\d+(,\d+)*,?\]$` )
351
351
352
352
func buildIssueOverview (ctx * context.Context , unitType unit.Type ) {
353
-
354
353
// ----------------------------------------------------
355
354
// Determine user; can be either user or organization.
356
355
// Return with NotFound or ServerError if unsuccessful.
@@ -364,7 +363,7 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
364
363
var (
365
364
viewType string
366
365
sortType = ctx .FormString ("sort" )
367
- filterMode = models . FilterModeAll
366
+ filterMode int
368
367
)
369
368
370
369
// --------------------------------------------------------------------------------
@@ -390,8 +389,10 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
390
389
filterMode = models .FilterModeMention
391
390
case "review_requested" :
392
391
filterMode = models .FilterModeReviewRequested
393
- case "your_repositories" : // filterMode already set to All
392
+ case "your_repositories" :
393
+ fallthrough
394
394
default :
395
+ filterMode = models .FilterModeYourRepositories
395
396
viewType = "your_repositories"
396
397
}
397
398
@@ -421,6 +422,30 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
421
422
User : ctx .User ,
422
423
}
423
424
425
+ // Search all repositories which
426
+ //
427
+ // As user:
428
+ // - Owns the repository.
429
+ // - Have collaborator permissions in repository.
430
+ //
431
+ // As org:
432
+ // - Owns the repository.
433
+ //
434
+ // As team:
435
+ // - Team org's owns the repository.
436
+ // - Team has read permission to repository.
437
+ repoOpts := & models.SearchRepoOptions {
438
+ Actor : ctx .User ,
439
+ OwnerID : ctx .User .ID ,
440
+ Private : true ,
441
+ AllPublic : false ,
442
+ AllLimited : false ,
443
+ }
444
+
445
+ if ctxUser .IsOrganization () && ctx .Org .Team != nil {
446
+ repoOpts .TeamID = ctx .Org .Team .ID
447
+ }
448
+
424
449
switch filterMode {
425
450
case models .FilterModeAll :
426
451
case models .FilterModeAssign :
@@ -431,6 +456,19 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
431
456
opts .MentionedID = ctx .User .ID
432
457
case models .FilterModeReviewRequested :
433
458
opts .ReviewRequestedID = ctx .User .ID
459
+ case models .FilterModeYourRepositories :
460
+ if ctxUser .IsOrganization () && ctx .Org .Team != nil {
461
+ // Fixes a issue whereby the user's ID would be used
462
+ // to check if it's in the team(which possible isn't the case).
463
+ opts .User = nil
464
+ }
465
+ userRepoIDs , _ , err := models .SearchRepositoryIDs (repoOpts )
466
+ if err != nil {
467
+ ctx .ServerError ("models.SearchRepositoryIDs: %v" , err )
468
+ return
469
+ }
470
+
471
+ opts .RepoIDs = userRepoIDs
434
472
}
435
473
436
474
// keyword holds the search term entered into the search field.
@@ -562,8 +600,12 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
562
600
Org : org ,
563
601
Team : team ,
564
602
}
565
- if len (repoIDs ) > 0 {
566
- statsOpts .RepoIDs = repoIDs
603
+ if filterMode == models .FilterModeYourRepositories {
604
+ statsOpts .RepoCond = models .SearchRepositoryCondition (repoOpts )
605
+ }
606
+ // Detect when we only should search by team.
607
+ if opts .User == nil {
608
+ statsOpts .UserID = 0
567
609
}
568
610
issueStats , err = models .GetUserIssueStats (statsOpts )
569
611
if err != nil {
@@ -586,8 +628,7 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
586
628
587
629
ctx .Data ["IsShowClosed" ] = isShowClosed
588
630
589
- ctx .Data ["IssueRefEndNames" ], ctx .Data ["IssueRefURLs" ] =
590
- issue_service .GetRefEndNamesAndURLs (issues , ctx .FormString ("RepoLink" ))
631
+ ctx .Data ["IssueRefEndNames" ], ctx .Data ["IssueRefURLs" ] = issue_service .GetRefEndNamesAndURLs (issues , ctx .FormString ("RepoLink" ))
591
632
592
633
ctx .Data ["Issues" ] = issues
593
634
@@ -661,7 +702,7 @@ func getRepoIDs(reposQuery string) []int64 {
661
702
var repoIDs []int64
662
703
// remove "[" and "]" from string
663
704
reposQuery = reposQuery [1 : len (reposQuery )- 1 ]
664
- //for each ID (delimiter ",") add to int to repoIDs
705
+ // for each ID (delimiter ",") add to int to repoIDs
665
706
for _ , rID := range strings .Split (reposQuery , "," ) {
666
707
// Ensure nonempty string entries
667
708
if rID != "" && rID != "0" {
@@ -693,8 +734,8 @@ func issueIDsFromSearch(ctxUser *user_model.User, keyword string, opts *models.I
693
734
}
694
735
695
736
func loadRepoByIDs (ctxUser * user_model.User , issueCountByRepo map [int64 ]int64 , unitType unit.Type ) (map [int64 ]* repo_model.Repository , error ) {
696
- var totalRes = make (map [int64 ]* repo_model.Repository , len (issueCountByRepo ))
697
- var repoIDs = make ([]int64 , 0 , 500 )
737
+ totalRes : = make (map [int64 ]* repo_model.Repository , len (issueCountByRepo ))
738
+ repoIDs : = make ([]int64 , 0 , 500 )
698
739
for id := range issueCountByRepo {
699
740
if id <= 0 {
700
741
continue
@@ -745,7 +786,7 @@ func ShowGPGKeys(ctx *context.Context, uid int64) {
745
786
if err != nil {
746
787
if asymkey_model .IsErrGPGKeyImportNotExist (err ) {
747
788
failedEntitiesID = append (failedEntitiesID , k .KeyID )
748
- continue //Skip previous import without backup of imported armored key
789
+ continue // Skip previous import without backup of imported armored key
749
790
}
750
791
ctx .ServerError ("ShowGPGKeys" , err )
751
792
return
@@ -755,12 +796,12 @@ func ShowGPGKeys(ctx *context.Context, uid int64) {
755
796
var buf bytes.Buffer
756
797
757
798
headers := make (map [string ]string )
758
- if len (failedEntitiesID ) > 0 { //If some key need re-import to be exported
799
+ if len (failedEntitiesID ) > 0 { // If some key need re-import to be exported
759
800
headers ["Note" ] = fmt .Sprintf ("The keys with the following IDs couldn't be exported and need to be reuploaded %s" , strings .Join (failedEntitiesID , ", " ))
760
801
}
761
802
writer , _ := armor .Encode (& buf , "PGP PUBLIC KEY BLOCK" , headers )
762
803
for _ , e := range entities {
763
- err = e .Serialize (writer ) //TODO find why key are exported with a different cipherTypeByte as original (should not be blocking but strange)
804
+ err = e .Serialize (writer ) // TODO find why key are exported with a different cipherTypeByte as original (should not be blocking but strange)
764
805
if err != nil {
765
806
ctx .ServerError ("ShowGPGKeys" , err )
766
807
return
0 commit comments