diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 96e28fe87a8..f168334d9de 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1261,6 +1261,8 @@ projects.column.new_submit = "Create Column" projects.column.new = "New Column" projects.column.set_default = "Set Default" projects.column.set_default_desc = "Set this column as default for uncategorized issues and pulls" +projects.column.unset_default = "Unset Default" +projects.column.unset_default_desc = "Unset this column as default" projects.column.delete = "Delete Column" projects.column.deletion_desc = "Deleting a project column moves all related issues to 'Uncategorized'. Continue?" projects.column.color = "Color" diff --git a/routers/web/org/projects.go b/routers/web/org/projects.go index ed6a2e645fe..37212179c95 100644 --- a/routers/web/org/projects.go +++ b/routers/web/org/projects.go @@ -610,6 +610,23 @@ func SetDefaultProjectBoard(ctx *context.Context) { }) } +// UnsetDefaultProjectBoard unset default board for uncategorized issues/pulls +func UnsetDefaultProjectBoard(ctx *context.Context) { + project, _ := CheckProjectBoardChangePermissions(ctx) + if ctx.Written() { + return + } + + if err := project_model.SetDefaultBoard(project.ID, 0); err != nil { + ctx.ServerError("SetDefaultBoard", err) + return + } + + ctx.JSON(http.StatusOK, map[string]interface{}{ + "ok": true, + }) +} + // MoveIssues moves or keeps issues in a column and sorts them inside that column func MoveIssues(ctx *context.Context) { if ctx.Doer == nil { diff --git a/routers/web/repo/projects.go b/routers/web/repo/projects.go index cef6893fbd1..72f83f8b31c 100644 --- a/routers/web/repo/projects.go +++ b/routers/web/repo/projects.go @@ -576,6 +576,23 @@ func SetDefaultProjectBoard(ctx *context.Context) { }) } +// UnSetDefaultProjectBoard unset default board for uncategorized issues/pulls +func UnSetDefaultProjectBoard(ctx *context.Context) { + project, _ := checkProjectBoardChangePermissions(ctx) + if ctx.Written() { + return + } + + if err := project_model.SetDefaultBoard(project.ID, 0); err != nil { + ctx.ServerError("SetDefaultBoard", err) + return + } + + ctx.JSON(http.StatusOK, map[string]interface{}{ + "ok": true, + }) +} + // MoveIssues moves or keeps issues in a column and sorts them inside that column func MoveIssues(ctx *context.Context) { if ctx.Doer == nil { diff --git a/routers/web/web.go b/routers/web/web.go index 30a8314691b..8f0b0b1f458 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -936,6 +936,7 @@ func RegisterRoutes(m *web.Route) { m.Put("", web.Bind(forms.EditProjectBoardForm{}), org.EditProjectBoard) m.Delete("", org.DeleteProjectBoard) m.Post("/default", org.SetDefaultProjectBoard) + m.Post("/unsetdefault", org.UnsetDefaultProjectBoard) m.Post("/move", org.MoveIssues) }) @@ -1292,6 +1293,7 @@ func RegisterRoutes(m *web.Route) { m.Put("", web.Bind(forms.EditProjectBoardForm{}), repo.EditProjectBoard) m.Delete("", repo.DeleteProjectBoard) m.Post("/default", repo.SetDefaultProjectBoard) + m.Post("/unsetdefault", repo.UnSetDefaultProjectBoard) m.Post("/move", repo.MoveIssues) }) diff --git a/templates/projects/view.tmpl b/templates/projects/view.tmpl index 41bbb83f7b1..338524d1536 100644 --- a/templates/projects/view.tmpl +++ b/templates/projects/view.tmpl @@ -95,10 +95,25 @@ {{$.locale.Tr "repo.projects.column.edit"}} {{if not .Default}} - + {{svg "octicon-pin"}} {{$.locale.Tr "repo.projects.column.set_default"}} + {{else}} + + {{svg "octicon-pin"}} + {{$.locale.Tr "repo.projects.column.unset_default"}} + {{end}} {{svg "octicon-trash"}} @@ -134,18 +149,16 @@ - -