-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Projects enhancements #12506
Projects enhancements #12506
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ import ( | |
|
||
"code.gitea.io/gitea/modules/base" | ||
"code.gitea.io/gitea/modules/log" | ||
"code.gitea.io/gitea/modules/markup" | ||
"code.gitea.io/gitea/modules/setting" | ||
"code.gitea.io/gitea/modules/structs" | ||
api "code.gitea.io/gitea/modules/structs" | ||
|
@@ -63,6 +64,7 @@ type Issue struct { | |
Reactions ReactionList `xorm:"-"` | ||
TotalTrackedTime int64 `xorm:"-"` | ||
Assignees []*User `xorm:"-"` | ||
ProjectIssueID ProjectIssue | ||
|
||
// IsLocked limits commenting abilities to users on an issue | ||
// with write access | ||
|
@@ -1100,8 +1102,10 @@ type IssuesOptions struct { | |
ExcludedLabelNames []string | ||
SortType string | ||
IssueIDs []int64 | ||
ExcludeProjectID int64 | ||
// prioritize issues from this repo | ||
PriorityRepoID int64 | ||
PriorityRepoID int64 | ||
RenderEmojiTitle util.OptionalBool | ||
} | ||
|
||
// sortIssuesSession sort an issues-related session based on the provided | ||
|
@@ -1180,17 +1184,21 @@ func (opts *IssuesOptions) setupSession(sess *xorm.Session) { | |
|
||
if opts.ProjectID > 0 { | ||
sess.Join("INNER", "project_issue", "issue.id = project_issue.issue_id"). | ||
And("project_issue.project_id=?", opts.ProjectID) | ||
And("project_issue.project_id=?", opts.ProjectID).OrderBy("`project_issue`.priority") | ||
} | ||
lafriks marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
lafriks marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if opts.ProjectBoardID != 0 { | ||
if opts.ProjectBoardID > 0 { | ||
sess.In("issue.id", builder.Select("issue_id").From("project_issue").Where(builder.Eq{"project_board_id": opts.ProjectBoardID})) | ||
sess.In("issue.id", builder.Select("issue_id").From("project_issue").Where(builder.Eq{"project_board_id": opts.ProjectBoardID}).OrderBy("`project_issue`.priority")) | ||
} else { | ||
sess.In("issue.id", builder.Select("issue_id").From("project_issue").Where(builder.Eq{"project_board_id": 0})) | ||
sess.In("issue.id", builder.Select("issue_id").From("project_issue").Where(builder.Eq{"project_board_id": 0}).OrderBy("`project_issue`.priority")) | ||
zeripath marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
|
||
if opts.ExcludeProjectID != 0 { | ||
sess.NotIn("issue.id", builder.Select("issue_id").From("project_issue").Where(builder.Eq{"project_id": opts.ExcludeProjectID}).OrderBy("`project_issue`.priority")) | ||
zeripath marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
switch opts.IsPull { | ||
case util.OptionalBoolTrue: | ||
sess.And("issue.is_pull=?", true) | ||
|
@@ -1280,7 +1288,15 @@ func Issues(opts *IssuesOptions) ([]*Issue, error) { | |
if err := IssueList(issues).LoadAttributes(); err != nil { | ||
return nil, fmt.Errorf("LoadAttributes: %v", err) | ||
} | ||
|
||
if opts.RenderEmojiTitle == util.OptionalBoolTrue { | ||
var issuesWithEmojis []*Issue | ||
for _, issue := range issues { | ||
title := string(markup.RenderEmoji(issue.Title)) | ||
issue.Title = title | ||
issuesWithEmojis = append(issuesWithEmojis, issue) | ||
} | ||
return issuesWithEmojis, nil | ||
} | ||
Comment on lines
+1291
to
+1299
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rendering of the emoji should be done elsewhere. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was it made an option? I thought emoji rendering to be a non-destructive operation that should always be performed where possible and generally we do it through the template helper. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the search API is being used to display issue in the board search and you requested it shows emojis. Where else could this code go? In the JavaScript? Sounds not practical to me. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can probably use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @silverwind this would require every function in api that queries a list of issues. It makes more sense to leave it the central Issues function so that all can benefit. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should move elsewhere or use one of the shared functions. Thematically, a issue has nothing to do with emoji rendering, we're doing that all over the place, not just in issues. |
||
return issues, nil | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2020 The Gitea Authors. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package migrations | ||
|
||
import ( | ||
"xorm.io/xorm" | ||
) | ||
|
||
func addProjectsIssuesBoardsPriority(x *xorm.Engine) error { | ||
// ProjectIssue saves relation from issue to a project | ||
type ProjectIssue struct { | ||
Priority int `xorm:"NOT NULL DEFAULT 0"` | ||
} | ||
|
||
if err := x.Sync2(new(ProjectIssue)); err != nil { | ||
return err | ||
} | ||
|
||
type ProjectBoard struct { | ||
Priority int `xorm:"NOT NULL DEFAULT 0"` | ||
} | ||
|
||
return x.Sync2(new(ProjectBoard)) | ||
} |
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.
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.
@6543 I can't do this because otherwise my query will stop working here https://github.com/patcito/gitea/blob/projects-enhancements/models/project_board.go#L206 as I use a field called project_issue_id in the join query and xorm will remove this field if I apply your suggestion of adding
xorm:"-"
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.
But ID should not be
ProjectIssue
type. Also this will generate columns toissue
table just likeExcludeProjectID