rename more board -> column

This commit is contained in:
Lunny Xiao 2024-03-30 10:46:18 +08:00
parent 43729085ac
commit 49fce5de0b
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
19 changed files with 113 additions and 117 deletions

View File

@ -100,8 +100,8 @@ const (
CommentTypeMergePull // 28 merge pull request
CommentTypePullRequestPush // 29 push to PR head branch
CommentTypeProject // 30 Project changed
CommentTypeProjectBoard // 31 Project board changed
CommentTypeProject // 30 Project changed
CommentTypeProjectColumn // 31 Project column changed
CommentTypeDismissReview // 32 Dismiss Review

View File

@ -47,7 +47,7 @@ func (issue *Issue) ProjectColumnID(ctx context.Context) int64 {
return ip.ProjectColumnID
}
// LoadIssuesFromColumn load issues assigned to this board
// LoadIssuesFromColumn load issues assigned to this column
func LoadIssuesFromColumn(ctx context.Context, b *project_model.Column) (IssueList, error) {
issueList, err := Issues(ctx, &IssuesOptions{
ProjectColumnID: b.ID,
@ -77,7 +77,7 @@ func LoadIssuesFromColumn(ctx context.Context, b *project_model.Column) (IssueLi
return issueList, nil
}
// LoadIssuesFromColumnList load issues assigned to the boards
// LoadIssuesFromColumnList load issues assigned to the columns
func LoadIssuesFromColumnList(ctx context.Context, bs project_model.ColumnList) (map[int64]IssueList, error) {
issuesMap := make(map[int64]IssueList, len(bs))
for i := range bs {

View File

@ -15,13 +15,13 @@ type (
)
const (
// BoardViewTypeNone is a project board type that has no predefined columns
// BoardViewTypeNone is a project board view type that has no predefined columns
BoardViewTypeNone BoardViewType = iota
// BoardViewTypeBasicKanban is a project board type that has basic predefined columns
// BoardViewTypeBasicKanban is a project board view type that has basic predefined columns
BoardViewTypeBasicKanban
// BoardViewTypeBugTriage is a project board type that has predefined columns suited to hunting down bugs
// BoardViewTypeBugTriage is a project board view type that has predefined columns suited to hunting down bugs
BoardViewTypeBugTriage
)

View File

@ -137,7 +137,7 @@ func NewColumn(ctx context.Context, column *Column) error {
return err
}
// DeleteColumnByID removes all issues references to the project board.
// DeleteColumnByID removes all issues references to the project column.
func DeleteColumnByID(ctx context.Context, columnID int64) error {
return db.WithTx(ctx, func(ctx context.Context) error {
return deleteColumnByID(ctx, columnID)
@ -155,7 +155,7 @@ func deleteColumnByID(ctx context.Context, columnID int64) error {
}
if column.Default {
return fmt.Errorf("deleteBoardByID: cannot delete default board")
return fmt.Errorf("deleteBoardByID: cannot delete default column")
}
if err = column.removeIssues(ctx); err != nil {
@ -173,17 +173,17 @@ func deleteColumnByProjectID(ctx context.Context, projectID int64) error {
return err
}
// GetColumn fetches the current board of a project
// GetColumn fetches the current column of a project
func GetColumn(ctx context.Context, columnID int64) (*Column, error) {
board := new(Column)
has, err := db.GetEngine(ctx).ID(columnID).Get(board)
column := new(Column)
has, err := db.GetEngine(ctx).ID(columnID).Get(column)
if err != nil {
return nil, err
} else if !has {
return nil, ErrProjectColumnNotExist{ColumnID: columnID}
}
return board, nil
return column, nil
}
// UpdateColumn updates a project column

View File

@ -76,7 +76,7 @@ func (p *Project) NumOpenIssues(ctx context.Context) int {
}
// MoveIssuesOnProjectColumn moves or keeps issues in a column and sorts them inside that column
func MoveIssuesOnProjectColumn(ctx context.Context, board *Column, sortedIssueIDs map[int64]int64) error {
func MoveIssuesOnProjectColumn(ctx context.Context, column *Column, sortedIssueIDs map[int64]int64) error {
return db.WithTx(ctx, func(ctx context.Context) error {
sess := db.GetEngine(ctx)
@ -84,7 +84,7 @@ func MoveIssuesOnProjectColumn(ctx context.Context, board *Column, sortedIssueID
for _, issueID := range sortedIssueIDs {
issueIDs = append(issueIDs, issueID)
}
count, err := sess.Table(new(ProjectIssue)).Where("project_id=?", board.ProjectID).In("issue_id", issueIDs).Count()
count, err := sess.Table(new(ProjectIssue)).Where("project_id=?", column.ProjectID).In("issue_id", issueIDs).Count()
if err != nil {
return err
}
@ -93,7 +93,7 @@ func MoveIssuesOnProjectColumn(ctx context.Context, board *Column, sortedIssueID
}
for sorting, issueID := range sortedIssueIDs {
_, err = sess.Exec("UPDATE `project_issue` SET project_board_id=?, sorting=? WHERE issue_id=?", board.ID, sorting, issueID)
_, err = sess.Exec("UPDATE `project_issue` SET project_board_id=?, sorting=? WHERE issue_id=?", column.ID, sorting, issueID)
if err != nil {
return err
}

View File

@ -21,7 +21,7 @@ import (
)
type (
// CardConfig is used to identify the type of board card that is being used
// CardConfig is used to identify the type of column card that is being used
CardConfig struct {
CardType CardType
Translation string
@ -32,7 +32,7 @@ type (
)
const (
// TypeIndividual is a type of project board that is owned by an individual
// TypeIndividual is a type of project column that is owned by an individual
TypeIndividual Type = iota + 1
// TypeRepository is a project that is tied to a repository
@ -62,12 +62,12 @@ func (err ErrProjectNotExist) Unwrap() error {
return util.ErrNotExist
}
// ErrProjectColumnNotExist represents a "ProjectBoardNotExist" kind of error.
// ErrProjectColumnNotExist represents a "ErrProjectColumnNotExist" kind of error.
type ErrProjectColumnNotExist struct {
ColumnID int64
}
// IsErrProjectColumnNotExist checks if an error is a ErrProjectBoardNotExist
// IsErrProjectColumnNotExist checks if an error is a ErrProjectColumnNotExist
func IsErrProjectColumnNotExist(err error) bool {
_, ok := err.(ErrProjectColumnNotExist)
return ok
@ -81,7 +81,7 @@ func (err ErrProjectColumnNotExist) Unwrap() error {
return util.ErrNotExist
}
// Project represents a project board
// Project represents a project
type Project struct {
ID int64 `xorm:"pk autoincr"`
Title string `xorm:"INDEX NOT NULL"`
@ -159,7 +159,7 @@ func init() {
db.RegisterModel(new(Project))
}
// GetCardConfig retrieves the types of configurations project board cards could have
// GetCardConfig retrieves the types of configurations project column cards could have
func GetCardConfig() []CardConfig {
return []CardConfig{
{CardTypeTextOnly, "repo.projects.card_type.text_only"},

View File

@ -27,7 +27,7 @@ const (
TypeWiki // 5 Wiki
TypeExternalWiki // 6 ExternalWiki
TypeExternalTracker // 7 ExternalTracker
TypeProjects // 8 Kanban board
TypeProjects // 8 Projects
TypePackages // 9 Packages
TypeActions // 10 Actions
)

View File

@ -375,7 +375,7 @@ func searchIssueInProject(t *testing.T) {
},
{
SearchOptions{
ProjectColumnID: optional.Some(int64(0)), // issue with in default board
ProjectColumnID: optional.Some(int64(0)), // issue with in default column
},
[]int64{2},
},

View File

@ -27,7 +27,7 @@ type IndexerData struct {
NoLabel bool `json:"no_label"` // True if LabelIDs is empty
MilestoneID int64 `json:"milestone_id"`
ProjectID int64 `json:"project_id"`
ProjectBoardID int64 `json:"project_board_id"`
ProjectColumnID int64 `json:"project_board_id"` // the key should be kept as project_board_id to keep compatible
PosterID int64 `json:"poster_id"`
AssigneeID int64 `json:"assignee_id"`
MentionIDs []int64 `json:"mention_ids"`

View File

@ -338,7 +338,7 @@ var cases = []*testIndexerCase{
},
},
{
Name: "ProjectBoardID",
Name: "ProjectColumnID",
SearchOptions: &internal.SearchOptions{
Paginator: &db.ListOptions{
PageSize: 5,
@ -348,15 +348,15 @@ var cases = []*testIndexerCase{
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
assert.Equal(t, 5, len(result.Hits))
for _, v := range result.Hits {
assert.Equal(t, int64(1), data[v.ID].ProjectBoardID)
assert.Equal(t, int64(1), data[v.ID].ProjectColumnID)
}
assert.Equal(t, countIndexerData(data, func(v *internal.IndexerData) bool {
return v.ProjectBoardID == 1
return v.ProjectColumnID == 1
}), result.Total)
},
},
{
Name: "no ProjectBoardID",
Name: "no ProjectColumnID",
SearchOptions: &internal.SearchOptions{
Paginator: &db.ListOptions{
PageSize: 5,
@ -366,10 +366,10 @@ var cases = []*testIndexerCase{
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
assert.Equal(t, 5, len(result.Hits))
for _, v := range result.Hits {
assert.Equal(t, int64(0), data[v.ID].ProjectBoardID)
assert.Equal(t, int64(0), data[v.ID].ProjectColumnID)
}
assert.Equal(t, countIndexerData(data, func(v *internal.IndexerData) bool {
return v.ProjectBoardID == 0
return v.ProjectColumnID == 0
}), result.Total)
},
},
@ -706,7 +706,7 @@ func generateDefaultIndexerData() []*internal.IndexerData {
NoLabel: len(labelIDs) == 0,
MilestoneID: issueIndex % 4,
ProjectID: issueIndex % 5,
ProjectBoardID: issueIndex % 6,
ProjectColumnID: issueIndex % 6,
PosterID: id%10 + 1, // PosterID should not be 0
AssigneeID: issueIndex % 10,
MentionIDs: mentionIDs,

View File

@ -105,7 +105,7 @@ func getIssueIndexerData(ctx context.Context, issueID int64) (*internal.IndexerD
NoLabel: len(labels) == 0,
MilestoneID: issue.MilestoneID,
ProjectID: projectID,
ProjectBoardID: issue.ProjectColumnID(ctx),
ProjectColumnID: issue.ProjectColumnID(ctx),
PosterID: issue.PosterID,
AssigneeID: issue.AssigneeID,
MentionIDs: mentionIDs,

View File

@ -36,7 +36,7 @@ type Collector struct {
Oauths *prometheus.Desc
Organizations *prometheus.Desc
Projects *prometheus.Desc
ProjectBoards *prometheus.Desc
ProjectColumns *prometheus.Desc
PublicKeys *prometheus.Desc
Releases *prometheus.Desc
Repositories *prometheus.Desc
@ -146,7 +146,7 @@ func NewCollector() Collector {
"Number of projects",
nil, nil,
),
ProjectBoards: prometheus.NewDesc(
ProjectColumns: prometheus.NewDesc(
namespace+"projects_boards",
"Number of project boards",
nil, nil,
@ -219,7 +219,7 @@ func (c Collector) Describe(ch chan<- *prometheus.Desc) {
ch <- c.Oauths
ch <- c.Organizations
ch <- c.Projects
ch <- c.ProjectBoards
ch <- c.ProjectColumns
ch <- c.PublicKeys
ch <- c.Releases
ch <- c.Repositories
@ -336,7 +336,7 @@ func (c Collector) Collect(ch chan<- prometheus.Metric) {
float64(stats.Counter.Project),
)
ch <- prometheus.MustNewConstMetric(
c.ProjectBoards,
c.ProjectColumns,
prometheus.GaugeValue,
float64(stats.Counter.ProjectColumn),
)

View File

@ -315,7 +315,7 @@ func EditProjectPost(ctx *context.Context) {
}
}
// ViewProject renders the project board for a project
// ViewProject renders the project with board view for a project
func ViewProject(ctx *context.Context) {
project, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id"))
if err != nil {
@ -329,7 +329,7 @@ func ViewProject(ctx *context.Context) {
boards, err := project.GetColumns(ctx)
if err != nil {
ctx.ServerError("GetProjectBoards", err)
ctx.ServerError("GetProjectColumns", err)
return
}
@ -458,7 +458,7 @@ func UpdateIssueProject(ctx *context.Context) {
ctx.JSONOK()
}
// DeleteProjectColumn allows for the deletion of a project board
// DeleteProjectColumn allows for the deletion of a project column
func DeleteProjectColumn(ctx *context.Context) {
if ctx.Doer == nil {
ctx.JSON(http.StatusForbidden, map[string]string{
@ -475,32 +475,32 @@ func DeleteProjectColumn(ctx *context.Context) {
pb, err := project_model.GetColumn(ctx, ctx.ParamsInt64(":boardID"))
if err != nil {
ctx.ServerError("GetProjectBoard", err)
ctx.ServerError("GetProjectColumn", err)
return
}
if pb.ProjectID != ctx.ParamsInt64(":id") {
ctx.JSON(http.StatusUnprocessableEntity, map[string]string{
"message": fmt.Sprintf("ProjectBoard[%d] is not in Project[%d] as expected", pb.ID, project.ID),
"message": fmt.Sprintf("ProjectColumn[%d] is not in Project[%d] as expected", pb.ID, project.ID),
})
return
}
if project.OwnerID != ctx.ContextUser.ID {
ctx.JSON(http.StatusUnprocessableEntity, map[string]string{
"message": fmt.Sprintf("ProjectBoard[%d] is not in Owner[%d] as expected", pb.ID, ctx.ContextUser.ID),
"message": fmt.Sprintf("ProjectColumn[%d] is not in Owner[%d] as expected", pb.ID, ctx.ContextUser.ID),
})
return
}
if err := project_model.DeleteColumnByID(ctx, ctx.ParamsInt64(":boardID")); err != nil {
ctx.ServerError("DeleteProjectBoardByID", err)
ctx.ServerError("DeleteProjectColumnByID", err)
return
}
ctx.JSONOK()
}
// AddColumnToProjectPost allows a new board to be added to a project.
// AddColumnToProjectPost allows a new column to be added to a project.
func AddColumnToProjectPost(ctx *context.Context) {
form := web.GetForm(ctx).(*forms.EditProjectColumnForm)
@ -516,15 +516,15 @@ func AddColumnToProjectPost(ctx *context.Context) {
Color: form.Color,
CreatorID: ctx.Doer.ID,
}); err != nil {
ctx.ServerError("NewProjectBoard", err)
ctx.ServerError("NewProjectColumn", err)
return
}
ctx.JSONOK()
}
// CheckProjectBoardChangePermissions check permission
func CheckProjectBoardChangePermissions(ctx *context.Context) (*project_model.Project, *project_model.Column) {
// CheckProjectColumnChangePermissions check permission
func CheckProjectColumnChangePermissions(ctx *context.Context) (*project_model.Project, *project_model.Column) {
if ctx.Doer == nil {
ctx.JSON(http.StatusForbidden, map[string]string{
"message": "Only signed in users are allowed to perform this action.",
@ -538,62 +538,60 @@ func CheckProjectBoardChangePermissions(ctx *context.Context) (*project_model.Pr
return nil, nil
}
board, err := project_model.GetColumn(ctx, ctx.ParamsInt64(":boardID"))
column, err := project_model.GetColumn(ctx, ctx.ParamsInt64(":boardID"))
if err != nil {
ctx.ServerError("GetProjectBoard", err)
ctx.ServerError("GetProjectColumn", err)
return nil, nil
}
if board.ProjectID != ctx.ParamsInt64(":id") {
if column.ProjectID != ctx.ParamsInt64(":id") {
ctx.JSON(http.StatusUnprocessableEntity, map[string]string{
"message": fmt.Sprintf("ProjectBoard[%d] is not in Project[%d] as expected", board.ID, project.ID),
"message": fmt.Sprintf("ProjectColumn[%d] is not in Project[%d] as expected", column.ID, project.ID),
})
return nil, nil
}
if project.OwnerID != ctx.ContextUser.ID {
ctx.JSON(http.StatusUnprocessableEntity, map[string]string{
"message": fmt.Sprintf("ProjectBoard[%d] is not in Repository[%d] as expected", board.ID, project.ID),
"message": fmt.Sprintf("ProjectColumn[%d] is not in Repository[%d] as expected", column.ID, project.ID),
})
return nil, nil
}
return project, board
return project, column
}
// EditProjectColumn allows a project board's to be updated
// EditProjectColumn allows a project column's to be updated
func EditProjectColumn(ctx *context.Context) {
form := web.GetForm(ctx).(*forms.EditProjectColumnForm)
_, board := CheckProjectBoardChangePermissions(ctx)
_, column := CheckProjectColumnChangePermissions(ctx)
if ctx.Written() {
return
}
if form.Title != "" {
board.Title = form.Title
column.Title = form.Title
}
board.Color = form.Color
column.Color = form.Color
if form.Sorting != 0 {
board.Sorting = form.Sorting
column.Sorting = form.Sorting
}
if err := project_model.UpdateColumn(ctx, board); err != nil {
ctx.ServerError("UpdateProjectBoard", err)
if err := project_model.UpdateColumn(ctx, column); err != nil {
ctx.ServerError("UpdateProjectColumn", err)
return
}
ctx.JSONOK()
}
// SetDefaultProjectBoard set default board for uncategorized issues/pulls
func SetDefaultProjectBoard(ctx *context.Context) {
project, board := CheckProjectBoardChangePermissions(ctx)
// SetDefaultProjectColumn set default column for uncategorized issues/pulls
func SetDefaultProjectColumn(ctx *context.Context) {
project, column := CheckProjectColumnChangePermissions(ctx)
if ctx.Written() {
return
}
if err := project_model.SetDefaultColumn(ctx, project.ID, board.ID); err != nil {
ctx.ServerError("SetDefaultBoard", err)
if err := project_model.SetDefaultColumn(ctx, project.ID, column.ID); err != nil {
ctx.ServerError("SetDefaultColumn", err)
return
}
@ -619,13 +617,13 @@ func MoveIssues(ctx *context.Context) {
return
}
board, err := project_model.GetColumn(ctx, ctx.ParamsInt64(":boardID"))
column, err := project_model.GetColumn(ctx, ctx.ParamsInt64(":boardID"))
if err != nil {
ctx.NotFoundOrServerError("GetProjectBoard", project_model.IsErrProjectColumnNotExist, err)
ctx.NotFoundOrServerError("GetProjectColumn", project_model.IsErrProjectColumnNotExist, err)
return
}
if board.ProjectID != project.ID {
if column.ProjectID != project.ID {
ctx.NotFound("BoardNotInProject", nil)
return
}
@ -671,8 +669,8 @@ func MoveIssues(ctx *context.Context) {
}
}
if err = project_model.MoveIssuesOnProjectColumn(ctx, board, sortedIssueIDs); err != nil {
ctx.ServerError("MoveIssuesOnProjectBoard", err)
if err = project_model.MoveIssuesOnProjectColumn(ctx, column, sortedIssueIDs); err != nil {
ctx.ServerError("MoveIssuesOnProjectColumn", err)
return
}

View File

@ -13,7 +13,7 @@ import (
"github.com/stretchr/testify/assert"
)
func TestCheckProjectBoardChangePermissions(t *testing.T) {
func TestCheckProjectColumnChangePermissions(t *testing.T) {
unittest.PrepareTestEnv(t)
ctx, _ := contexttest.MockContext(t, "user2/-/projects/4/4")
contexttest.LoadUser(t, ctx, 2)
@ -21,8 +21,8 @@ func TestCheckProjectBoardChangePermissions(t *testing.T) {
ctx.SetParams(":id", "4")
ctx.SetParams(":boardID", "4")
project, board := org.CheckProjectBoardChangePermissions(ctx)
project, column := org.CheckProjectColumnChangePermissions(ctx)
assert.NotNil(t, project)
assert.NotNil(t, board)
assert.NotNil(t, column)
assert.False(t, ctx.Written())
}

View File

@ -293,7 +293,7 @@ func EditProjectPost(ctx *context.Context) {
}
}
// ViewProject renders the project board for a project
// ViewProject renders the project with board view
func ViewProject(ctx *context.Context) {
project, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id"))
if err != nil {
@ -311,7 +311,7 @@ func ViewProject(ctx *context.Context) {
boards, err := project.GetColumns(ctx)
if err != nil {
ctx.ServerError("GetProjectBoards", err)
ctx.ServerError("GetProjectColumns", err)
return
}
@ -406,8 +406,8 @@ func UpdateIssueProject(ctx *context.Context) {
ctx.JSONOK()
}
// DeleteProjectBoard allows for the deletion of a project board
func DeleteProjectBoard(ctx *context.Context) {
// DeleteProjectColumn allows for the deletion of a project column
func DeleteProjectColumn(ctx *context.Context) {
if ctx.Doer == nil {
ctx.JSON(http.StatusForbidden, map[string]string{
"message": "Only signed in users are allowed to perform this action.",
@ -434,33 +434,33 @@ func DeleteProjectBoard(ctx *context.Context) {
pb, err := project_model.GetColumn(ctx, ctx.ParamsInt64(":boardID"))
if err != nil {
ctx.ServerError("GetProjectBoard", err)
ctx.ServerError("GetProjectColumn", err)
return
}
if pb.ProjectID != ctx.ParamsInt64(":id") {
ctx.JSON(http.StatusUnprocessableEntity, map[string]string{
"message": fmt.Sprintf("ProjectBoard[%d] is not in Project[%d] as expected", pb.ID, project.ID),
"message": fmt.Sprintf("ProjectColumn[%d] is not in Project[%d] as expected", pb.ID, project.ID),
})
return
}
if project.RepoID != ctx.Repo.Repository.ID {
ctx.JSON(http.StatusUnprocessableEntity, map[string]string{
"message": fmt.Sprintf("ProjectBoard[%d] is not in Repository[%d] as expected", pb.ID, ctx.Repo.Repository.ID),
"message": fmt.Sprintf("ProjectColumn[%d] is not in Repository[%d] as expected", pb.ID, ctx.Repo.Repository.ID),
})
return
}
if err := project_model.DeleteColumnByID(ctx, ctx.ParamsInt64(":boardID")); err != nil {
ctx.ServerError("DeleteProjectBoardByID", err)
ctx.ServerError("DeleteProjectColumnByID", err)
return
}
ctx.JSONOK()
}
// AddBoardToProjectPost allows a new board to be added to a project.
func AddBoardToProjectPost(ctx *context.Context) {
// AddColumnToProjectPost allows a new column to be added to a project.
func AddColumnToProjectPost(ctx *context.Context) {
form := web.GetForm(ctx).(*forms.EditProjectColumnForm)
if !ctx.Repo.IsOwner() && !ctx.Repo.IsAdmin() && !ctx.Repo.CanAccess(perm.AccessModeWrite, unit.TypeProjects) {
ctx.JSON(http.StatusForbidden, map[string]string{
@ -485,14 +485,14 @@ func AddBoardToProjectPost(ctx *context.Context) {
Color: form.Color,
CreatorID: ctx.Doer.ID,
}); err != nil {
ctx.ServerError("NewProjectBoard", err)
ctx.ServerError("NewProjectColumn", err)
return
}
ctx.JSONOK()
}
func checkProjectBoardChangePermissions(ctx *context.Context) (*project_model.Project, *project_model.Column) {
func checkProjectColumnChangePermissions(ctx *context.Context) (*project_model.Project, *project_model.Column) {
if ctx.Doer == nil {
ctx.JSON(http.StatusForbidden, map[string]string{
"message": "Only signed in users are allowed to perform this action.",
@ -517,61 +517,59 @@ func checkProjectBoardChangePermissions(ctx *context.Context) (*project_model.Pr
return nil, nil
}
board, err := project_model.GetColumn(ctx, ctx.ParamsInt64(":boardID"))
column, err := project_model.GetColumn(ctx, ctx.ParamsInt64(":boardID"))
if err != nil {
ctx.ServerError("GetProjectBoard", err)
ctx.ServerError("GetProjectColumn", err)
return nil, nil
}
if board.ProjectID != ctx.ParamsInt64(":id") {
if column.ProjectID != ctx.ParamsInt64(":id") {
ctx.JSON(http.StatusUnprocessableEntity, map[string]string{
"message": fmt.Sprintf("ProjectBoard[%d] is not in Project[%d] as expected", board.ID, project.ID),
"message": fmt.Sprintf("ProjectColumn[%d] is not in Project[%d] as expected", column.ID, project.ID),
})
return nil, nil
}
if project.RepoID != ctx.Repo.Repository.ID {
ctx.JSON(http.StatusUnprocessableEntity, map[string]string{
"message": fmt.Sprintf("ProjectBoard[%d] is not in Repository[%d] as expected", board.ID, ctx.Repo.Repository.ID),
"message": fmt.Sprintf("ProjectColumn[%d] is not in Repository[%d] as expected", column.ID, ctx.Repo.Repository.ID),
})
return nil, nil
}
return project, board
return project, column
}
// EditProjectColumn allows a project board's to be updated
// EditProjectColumn allows a project column's to be updated
func EditProjectColumn(ctx *context.Context) {
form := web.GetForm(ctx).(*forms.EditProjectColumnForm)
_, board := checkProjectBoardChangePermissions(ctx)
_, column := checkProjectColumnChangePermissions(ctx)
if ctx.Written() {
return
}
if form.Title != "" {
board.Title = form.Title
column.Title = form.Title
}
board.Color = form.Color
column.Color = form.Color
if form.Sorting != 0 {
board.Sorting = form.Sorting
column.Sorting = form.Sorting
}
if err := project_model.UpdateColumn(ctx, board); err != nil {
ctx.ServerError("UpdateProjectBoard", err)
if err := project_model.UpdateColumn(ctx, column); err != nil {
ctx.ServerError("UpdateProjectColumn", err)
return
}
ctx.JSONOK()
}
// SetDefaultProjectColumn set default board for uncategorized issues/pulls
// SetDefaultProjectColumn set default column for uncategorized issues/pulls
func SetDefaultProjectColumn(ctx *context.Context) {
project, board := checkProjectBoardChangePermissions(ctx)
project, column := checkProjectColumnChangePermissions(ctx)
if ctx.Written() {
return
}
if err := project_model.SetDefaultColumn(ctx, project.ID, board.ID); err != nil {
if err := project_model.SetDefaultColumn(ctx, project.ID, column.ID); err != nil {
ctx.ServerError("SetDefaultBoard", err)
return
}
@ -609,7 +607,7 @@ func MoveIssues(ctx *context.Context) {
return
}
board, err := project_model.GetColumn(ctx, ctx.ParamsInt64(":boardID"))
column, err := project_model.GetColumn(ctx, ctx.ParamsInt64(":boardID"))
if err != nil {
if project_model.IsErrProjectColumnNotExist(err) {
ctx.NotFound("ProjectColumnNotExist", nil)
@ -619,7 +617,7 @@ func MoveIssues(ctx *context.Context) {
return
}
if board.ProjectID != project.ID {
if column.ProjectID != project.ID {
ctx.NotFound("BoardNotInProject", nil)
return
}
@ -664,7 +662,7 @@ func MoveIssues(ctx *context.Context) {
}
}
if err = project_model.MoveIssuesOnProjectColumn(ctx, board, sortedIssueIDs); err != nil {
if err = project_model.MoveIssuesOnProjectColumn(ctx, column, sortedIssueIDs); err != nil {
ctx.ServerError("MoveIssuesOnProjectColumn", err)
return
}

View File

@ -12,7 +12,7 @@ import (
"github.com/stretchr/testify/assert"
)
func TestCheckProjectBoardChangePermissions(t *testing.T) {
func TestCheckProjectColumnChangePermissions(t *testing.T) {
unittest.PrepareTestEnv(t)
ctx, _ := contexttest.MockContext(t, "user2/repo1/projects/1/2")
contexttest.LoadUser(t, ctx, 2)
@ -20,8 +20,8 @@ func TestCheckProjectBoardChangePermissions(t *testing.T) {
ctx.SetParams(":id", "1")
ctx.SetParams(":boardID", "2")
project, board := checkProjectBoardChangePermissions(ctx)
project, column := checkProjectColumnChangePermissions(ctx)
assert.NotNil(t, project)
assert.NotNil(t, board)
assert.NotNil(t, column)
assert.False(t, ctx.Written())
}

View File

@ -1007,7 +1007,7 @@ func registerRoutes(m *web.Route) {
m.Group("/{boardID}", func() {
m.Put("", web.Bind(forms.EditProjectColumnForm{}), org.EditProjectColumn)
m.Delete("", org.DeleteProjectColumn)
m.Post("/default", org.SetDefaultProjectBoard)
m.Post("/default", org.SetDefaultProjectColumn)
m.Post("/move", org.MoveIssues)
})
@ -1336,7 +1336,7 @@ func registerRoutes(m *web.Route) {
m.Get("/new", repo.RenderNewProject)
m.Post("/new", web.Bind(forms.CreateProjectForm{}), repo.NewProjectPost)
m.Group("/{id}", func() {
m.Post("", web.Bind(forms.EditProjectColumnForm{}), repo.AddBoardToProjectPost)
m.Post("", web.Bind(forms.EditProjectColumnForm{}), repo.AddColumnToProjectPost)
m.Post("/delete", repo.DeleteProject)
m.Get("/edit", repo.RenderEditProject)
@ -1345,7 +1345,7 @@ func registerRoutes(m *web.Route) {
m.Group("/{boardID}", func() {
m.Put("", web.Bind(forms.EditProjectColumnForm{}), repo.EditProjectColumn)
m.Delete("", repo.DeleteProjectBoard)
m.Delete("", repo.DeleteProjectColumn)
m.Post("/default", repo.SetDefaultProjectColumn)
m.Post("/move", repo.MoveIssues)

View File

@ -522,7 +522,7 @@ type UserCreateProjectForm struct {
UID int64 `binding:"Required"`
}
// EditProjectColumnForm is a form for editing a project board
// EditProjectColumnForm is a form for editing a project column
type EditProjectColumnForm struct {
Title string `binding:"Required;MaxSize(100)"`
Sorting int8

View File

@ -65,7 +65,7 @@ var hiddenCommentTypeGroups = hiddenCommentTypeGroupsType{
},
"project": {
/*30*/ issues_model.CommentTypeProject,
/*31*/ issues_model.CommentTypeProjectBoard,
/*31*/ issues_model.CommentTypeProjectColumn,
},
"issue_ref": {
/*33*/ issues_model.CommentTypeChangeIssueRef,