Add Approval Counts to pulls list (#10238)
* Add Approval Counts to pulls list Add simple approvals counts to pulls lists * Remove non-official counts * Add PR features to milestone_issues.tmpl
This commit is contained in:
parent
f422a115f4
commit
80db44267c
8 changed files with 154 additions and 4 deletions
|
@ -216,6 +216,12 @@ func issues(ctx *context.Context, milestoneID int64, isPullOption util.OptionalB
|
|||
}
|
||||
}
|
||||
|
||||
approvalCounts, err := models.IssueList(issues).GetApprovalCounts()
|
||||
if err != nil {
|
||||
ctx.ServerError("ApprovalCounts", err)
|
||||
return
|
||||
}
|
||||
|
||||
var commitStatus = make(map[int64]*models.CommitStatus, len(issues))
|
||||
|
||||
// Get posters.
|
||||
|
@ -263,6 +269,22 @@ func issues(ctx *context.Context, milestoneID int64, isPullOption util.OptionalB
|
|||
assigneeID = 0 // Reset ID to prevent unexpected selection of assignee.
|
||||
}
|
||||
|
||||
ctx.Data["ApprovalCounts"] = func(issueID int64, typ string) int64 {
|
||||
counts, ok := approvalCounts[issueID]
|
||||
if !ok || len(counts) == 0 {
|
||||
return 0
|
||||
}
|
||||
reviewTyp := models.ReviewTypeApprove
|
||||
if typ == "reject" {
|
||||
reviewTyp = models.ReviewTypeReject
|
||||
}
|
||||
for _, count := range counts {
|
||||
if count.Type == reviewTyp {
|
||||
return count.Count
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
ctx.Data["IssueStats"] = issueStats
|
||||
ctx.Data["SelLabelIDs"] = labelIDs
|
||||
ctx.Data["SelectLabels"] = selectLabels
|
||||
|
|
|
@ -528,6 +528,12 @@ func Issues(ctx *context.Context) {
|
|||
issues = []*models.Issue{}
|
||||
}
|
||||
|
||||
approvalCounts, err := models.IssueList(issues).GetApprovalCounts()
|
||||
if err != nil {
|
||||
ctx.ServerError("ApprovalCounts", err)
|
||||
return
|
||||
}
|
||||
|
||||
showReposMap := make(map[int64]*models.Repository, len(counts))
|
||||
for repoID := range counts {
|
||||
if repoID > 0 {
|
||||
|
@ -639,6 +645,22 @@ func Issues(ctx *context.Context) {
|
|||
}
|
||||
|
||||
ctx.Data["Issues"] = issues
|
||||
ctx.Data["ApprovalCounts"] = func(issueID int64, typ string) int64 {
|
||||
counts, ok := approvalCounts[issueID]
|
||||
if !ok || len(counts) == 0 {
|
||||
return 0
|
||||
}
|
||||
reviewTyp := models.ReviewTypeApprove
|
||||
if typ == "reject" {
|
||||
reviewTyp = models.ReviewTypeReject
|
||||
}
|
||||
for _, count := range counts {
|
||||
if count.Type == reviewTyp {
|
||||
return count.Count
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
ctx.Data["CommitStatus"] = commitStatus
|
||||
ctx.Data["Repos"] = showRepos
|
||||
ctx.Data["Counts"] = counts
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue