-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix 500 when sorting the default project board #29870
Conversation
if ctx.ParamsInt64(":boardID") == 0 { | ||
board = &project_model.Board{ | ||
ID: 0, | ||
ProjectID: project.ID, | ||
Title: ctx.Locale.TrString("repo.projects.type.uncategorized"), | ||
} | ||
} else { | ||
board, err = project_model.GetBoard(ctx, ctx.ParamsInt64(":boardID")) | ||
if err != nil { | ||
if project_model.IsErrProjectBoardNotExist(err) { | ||
ctx.NotFound("ProjectBoardNotExist", nil) | ||
} else { | ||
ctx.ServerError("GetProjectBoard", err) | ||
} | ||
return nil, nil | ||
} | ||
if board.ProjectID != project.ID { | ||
ctx.NotFound("BoardNotInProject", nil) | ||
return nil, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we extract this into one func getContextBoard(ctx context, projectID int64) (project_model.Board, error)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will clean it up afterward
That's what I mean in the PR description. I rather keep this PR focus on the fix. What do you think?
Found this interesting comment: gitea/templates/projects/view.tmpl Line 168 in 095fdd6
So it seems column 0 was at least initially never meant to be moved. I do agree we should allow it. |
It seems that the default column can indeed not be dragged itself, but another column can be dragged into its place, so the restriction is kind of pointless currently. I think we should unrestrict column entirely either in this PR or a followup, removing the JS restriction that currently forbids the default column from being dragged. |
@silverwind The default column doesn't really exist, it's dynamically generated if there are no columns in a project. See #29874 |
The backend uses the |
I still don't get it. Why is that board different from others and why can't it be sortable? |
gitea/routers/web/repo/projects.go Lines 633 to 648 in 16e3600
the DB didn't store the column. The backend checks it first and returns a mock one. Therefore, the sorting field, which is used for sorting, always defaults to value 0 .If we want to sort this column, we need to redesign the backend logic. |
So if we can't make it sortable on backend, we should just prevent dropping anything in place of the default column, should be possible in the JS. Long term, it should be made sortable, just like it is on GitHub. |
The JS solution could replace this PR because no more requests about
After #29874, when projects are created, the default board can be treated like a normal board. The |
Well what we could do in #29874 is adding a migration to create the new default column retroactively, then disallow for a project to have less than one board (the last one cannot be deleted). Then we could get rid of board 0 completely. |
I think we should actually follow GitHub and make it possible to have multiple default columns, GitHub seems to have various template and the first one has thee columns "Todo", "In Progress", "Done". I think that'd be good set of default columns. |
That's another point, we already have project templates. Currently however we're taking about default columns for issues added to a project, which is currently either set manually or generated dynamically when the backend notices that the project doesn't have a default column. The proposal is to just add one if the project is empty and not to allow deleting all columns, then we would not have the need for dynamically generating this non-editable pseudo-column. |
#29892 does that, making this PR obsolete I guess. |
Closing in favor of the proper fix in #29874 removing boardID 0 completely |
fix #29853
The problem is that
checkProjectBoardChangePermission
didn't check if theproject board id == 0
, which is the default project board.BTW, I think the code about this
default project board
trick is a little redundant. It required every function to check whether theproject board id == 0
. I will clean it up afterward.