@@ -270,23 +270,17 @@ func ViewProject(ctx *context.Context) {
270270 return
271271 }
272272
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-
280273 boards , err := models .GetProjectBoards (project .ID )
281274 if err != nil {
282275 ctx .ServerError ("GetProjectBoards" , err )
283276 return
284277 }
285278
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+ }
288282
289- if ctx .Data ["Issues" ], err = allBoards .LoadIssues (); err != nil {
283+ if ctx .Data ["Issues" ], err = boards .LoadIssues (); err != nil {
290284 ctx .ServerError ("LoadIssuesOfBoards" , err )
291285 return
292286 }
@@ -295,7 +289,7 @@ func ViewProject(ctx *context.Context) {
295289
296290 ctx .Data ["CanWriteProjects" ] = ctx .Repo .Permission .CanWrite (models .UnitTypeProjects )
297291 ctx .Data ["Project" ] = project
298- ctx .Data ["Boards" ] = allBoards
292+ ctx .Data ["Boards" ] = boards
299293 ctx .Data ["PageIsProjects" ] = true
300294 ctx .Data ["RequiresDraggable" ] = true
301295
@@ -416,21 +410,19 @@ func AddBoardToProjectPost(ctx *context.Context, form auth.EditProjectBoardTitle
416410 })
417411}
418412
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 ) {
422414 if ctx .User == nil {
423415 ctx .JSON (403 , map [string ]string {
424416 "message" : "Only signed in users are allowed to perform this action." ,
425417 })
426- return
418+ return nil , nil
427419 }
428420
429421 if ! ctx .Repo .IsOwner () && ! ctx .Repo .IsAdmin () && ! ctx .Repo .CanAccess (models .AccessModeWrite , models .UnitTypeProjects ) {
430422 ctx .JSON (403 , map [string ]string {
431423 "message" : "Only authorized users are allowed to perform this action." ,
432424 })
433- return
425+ return nil , nil
434426 }
435427
436428 project , err := models .GetProjectByID (ctx .ParamsInt64 (":id" ))
@@ -440,25 +432,35 @@ func EditProjectBoardTitle(ctx *context.Context, form auth.EditProjectBoardTitle
440432 } else {
441433 ctx .ServerError ("GetProjectByID" , err )
442434 }
443- return
435+ return nil , nil
444436 }
445437
446438 board , err := models .GetProjectBoard (ctx .ParamsInt64 (":boardID" ))
447439 if err != nil {
448440 ctx .ServerError ("GetProjectBoard" , err )
449- return
441+ return nil , nil
450442 }
451443 if board .ProjectID != ctx .ParamsInt64 (":id" ) {
452444 ctx .JSON (422 , map [string ]string {
453445 "message" : fmt .Sprintf ("ProjectBoard[%d] is not in Project[%d] as expected" , board .ID , project .ID ),
454446 })
455- return
447+ return nil , nil
456448 }
457449
458450 if project .RepoID != ctx .Repo .Repository .ID {
459451 ctx .JSON (422 , map [string ]string {
460452 "message" : fmt .Sprintf ("ProjectBoard[%d] is not in Repository[%d] as expected" , board .ID , ctx .Repo .Repository .ID ),
461453 })
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 () {
462464 return
463465 }
464466
@@ -476,6 +478,24 @@ func EditProjectBoardTitle(ctx *context.Context, form auth.EditProjectBoardTitle
476478 })
477479}
478480
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+
479499// MoveIssueAcrossBoards move a card from one board to another in a project
480500func MoveIssueAcrossBoards (ctx * context.Context ) {
481501
0 commit comments