@@ -270,23 +270,17 @@ func ViewProject(ctx *context.Context) {
270
270
return
271
271
}
272
272
273
- uncategorizedBoard , err := models .GetUncategorizedBoard (project .ID )
274
- uncategorizedBoard .Title = ctx .Tr ("repo.projects.type.uncategorized" )
275
- if err != nil {
276
- ctx .ServerError ("GetUncategorizedBoard" , err )
277
- return
278
- }
279
-
280
273
boards , err := models .GetProjectBoards (project .ID )
281
274
if err != nil {
282
275
ctx .ServerError ("GetProjectBoards" , err )
283
276
return
284
277
}
285
278
286
- allBoards := models.ProjectBoardList {uncategorizedBoard }
287
- allBoards = append (allBoards , boards ... )
279
+ if boards [0 ].ID == 0 {
280
+ boards [0 ].Title = ctx .Tr ("repo.projects.type.uncategorized" )
281
+ }
288
282
289
- if ctx .Data ["Issues" ], err = allBoards .LoadIssues (); err != nil {
283
+ if ctx .Data ["Issues" ], err = boards .LoadIssues (); err != nil {
290
284
ctx .ServerError ("LoadIssuesOfBoards" , err )
291
285
return
292
286
}
@@ -295,7 +289,7 @@ func ViewProject(ctx *context.Context) {
295
289
296
290
ctx .Data ["CanWriteProjects" ] = ctx .Repo .Permission .CanWrite (models .UnitTypeProjects )
297
291
ctx .Data ["Project" ] = project
298
- ctx .Data ["Boards" ] = allBoards
292
+ ctx .Data ["Boards" ] = boards
299
293
ctx .Data ["PageIsProjects" ] = true
300
294
ctx .Data ["RequiresDraggable" ] = true
301
295
@@ -416,21 +410,19 @@ func AddBoardToProjectPost(ctx *context.Context, form auth.EditProjectBoardTitle
416
410
})
417
411
}
418
412
419
- // EditProjectBoardTitle allows a project board's title to be updated
420
- func EditProjectBoardTitle (ctx * context.Context , form auth.EditProjectBoardTitleForm ) {
421
-
413
+ func checkProjectBoardChangePermissions (ctx * context.Context ) (* models.Project , * models.ProjectBoard ) {
422
414
if ctx .User == nil {
423
415
ctx .JSON (403 , map [string ]string {
424
416
"message" : "Only signed in users are allowed to perform this action." ,
425
417
})
426
- return
418
+ return nil , nil
427
419
}
428
420
429
421
if ! ctx .Repo .IsOwner () && ! ctx .Repo .IsAdmin () && ! ctx .Repo .CanAccess (models .AccessModeWrite , models .UnitTypeProjects ) {
430
422
ctx .JSON (403 , map [string ]string {
431
423
"message" : "Only authorized users are allowed to perform this action." ,
432
424
})
433
- return
425
+ return nil , nil
434
426
}
435
427
436
428
project , err := models .GetProjectByID (ctx .ParamsInt64 (":id" ))
@@ -440,25 +432,35 @@ func EditProjectBoardTitle(ctx *context.Context, form auth.EditProjectBoardTitle
440
432
} else {
441
433
ctx .ServerError ("GetProjectByID" , err )
442
434
}
443
- return
435
+ return nil , nil
444
436
}
445
437
446
438
board , err := models .GetProjectBoard (ctx .ParamsInt64 (":boardID" ))
447
439
if err != nil {
448
440
ctx .ServerError ("GetProjectBoard" , err )
449
- return
441
+ return nil , nil
450
442
}
451
443
if board .ProjectID != ctx .ParamsInt64 (":id" ) {
452
444
ctx .JSON (422 , map [string ]string {
453
445
"message" : fmt .Sprintf ("ProjectBoard[%d] is not in Project[%d] as expected" , board .ID , project .ID ),
454
446
})
455
- return
447
+ return nil , nil
456
448
}
457
449
458
450
if project .RepoID != ctx .Repo .Repository .ID {
459
451
ctx .JSON (422 , map [string ]string {
460
452
"message" : fmt .Sprintf ("ProjectBoard[%d] is not in Repository[%d] as expected" , board .ID , ctx .Repo .Repository .ID ),
461
453
})
454
+ return nil , nil
455
+ }
456
+ return project , board
457
+ }
458
+
459
+ // EditProjectBoardTitle allows a project board's title to be updated
460
+ func EditProjectBoardTitle (ctx * context.Context , form auth.EditProjectBoardTitleForm ) {
461
+
462
+ _ , board := checkProjectBoardChangePermissions (ctx )
463
+ if ctx .Written () {
462
464
return
463
465
}
464
466
@@ -476,6 +478,24 @@ func EditProjectBoardTitle(ctx *context.Context, form auth.EditProjectBoardTitle
476
478
})
477
479
}
478
480
481
+ // SetDefaultProjectBoard set default board for uncategorized issues/pulls
482
+ func SetDefaultProjectBoard (ctx * context.Context ) {
483
+
484
+ project , board := checkProjectBoardChangePermissions (ctx )
485
+ if ctx .Written () {
486
+ return
487
+ }
488
+
489
+ if err := models .SetDefaultBoard (project .ID , board .ID ); err != nil {
490
+ ctx .ServerError ("SetDefaultBoard" , err )
491
+ return
492
+ }
493
+
494
+ ctx .JSON (200 , map [string ]interface {}{
495
+ "ok" : true ,
496
+ })
497
+ }
498
+
479
499
// MoveIssueAcrossBoards move a card from one board to another in a project
480
500
func MoveIssueAcrossBoards (ctx * context.Context ) {
481
501
0 commit comments