mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-16 12:05:30 +09:00
Show review summary in pull requests (#5132)
This commit is contained in:
1 parent
cef0f12c51
commit
0dcf31ae49
8 files changed
+179
-2
No files matched your search
@@ -30,3 +30,43 @@
|
||||
content: "Pending Review"
|
||||
updated_unix: 946684810
|
||||
created_unix: 946684810
|
||||
-
|
||||
id: 5
|
||||
type: 2
|
||||
reviewer_id: 1
|
||||
issue_id: 3
|
||||
content: "New review 1"
|
||||
updated_unix: 946684810
|
||||
created_unix: 946684810
|
||||
-
|
||||
id: 6
|
||||
type: 0
|
||||
reviewer_id: 2
|
||||
issue_id: 3
|
||||
content: "New review 3"
|
||||
updated_unix: 946684810
|
||||
created_unix: 946684810
|
||||
-
|
||||
id: 7
|
||||
type: 3
|
||||
reviewer_id: 3
|
||||
issue_id: 3
|
||||
content: "New review 4"
|
||||
updated_unix: 946684810
|
||||
created_unix: 946684810
|
||||
-
|
||||
id: 8
|
||||
type: 1
|
||||
reviewer_id: 4
|
||||
issue_id: 3
|
||||
content: "New review 5"
|
||||
updated_unix: 946684810
|
||||
created_unix: 946684810
|
||||
-
|
||||
id: 9
|
||||
type: 3
|
||||
reviewer_id: 2
|
||||
issue_id: 3
|
||||
content: "New review 3 rejected"
|
||||
updated_unix: 946684810
|
||||
created_unix: 946684810
|
||||
@@ -255,3 +255,36 @@ func UpdateReview(r *Review) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// PullReviewersWithType represents the type used to display a review overview
|
||||
type PullReviewersWithType struct {
|
||||
User `xorm:"extends"`
|
||||
Type ReviewType
|
||||
ReviewUpdatedUnix util.TimeStamp `xorm:"review_updated_unix"`
|
||||
}
|
||||
|
||||
// GetReviewersByPullID gets all reviewers for a pull request with the statuses
|
||||
func GetReviewersByPullID(pullID int64) (issueReviewers []*PullReviewersWithType, err error) {
|
||||
irs := []*PullReviewersWithType{}
|
||||
err = x.Select("`user`.*, review.type, max(review.updated_unix) as review_updated_unix").
|
||||
Table("review").
|
||||
Join("INNER", "`user`", "review.reviewer_id = `user`.id").
|
||||
Where("review.issue_id = ? AND (review.type = ? OR review.type = ?)", pullID, ReviewTypeApprove, ReviewTypeReject).
|
||||
GroupBy("`user`.id, review.type").
|
||||
OrderBy("review_updated_unix DESC").
|
||||
Find(&irs)
|
||||
|
||||
// We need to group our results by user id _and_ review type, otherwise the query fails when using postgresql.
|
||||
// But becaus we're doing this, we need to manually filter out multiple reviews of different types by the
|
||||
// same person because we only want to show the newest review grouped by user. Thats why we're using a map here.
|
||||
issueReviewers = []*PullReviewersWithType{}
|
||||
usersInArray := make(map[int64]bool)
|
||||
for _, ir := range irs {
|
||||
if !usersInArray[ir.ID] {
|
||||
issueReviewers = append(issueReviewers, ir)
|
||||
usersInArray[ir.ID] = true
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
+31
-1
@@ -74,7 +74,7 @@ func TestGetCurrentReview(t *testing.T) {
|
||||
assert.Equal(t, ReviewTypePending, review.Type)
|
||||
assert.Equal(t, "Pending Review", review.Content)
|
||||
|
||||
user2 := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
|
||||
user2 := AssertExistsAndLoadBean(t, &User{ID: 7}).(*User)
|
||||
review2, err := GetCurrentReview(user2, issue)
|
||||
assert.Error(t, err)
|
||||
assert.True(t, IsErrReviewNotExist(err))
|
||||
@@ -105,3 +105,33 @@ func TestUpdateReview(t *testing.T) {
|
||||
assert.NoError(t, UpdateReview(review))
|
||||
AssertExistsAndLoadBean(t, &Review{ID: 1, Content: "Updated Review"})
|
||||
}
|
||||
|
||||
func TestGetReviewersByPullID(t *testing.T) {
|
||||
assert.NoError(t, PrepareTestDatabase())
|
||||
|
||||
issue := AssertExistsAndLoadBean(t, &Issue{ID: 3}).(*Issue)
|
||||
user2 := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
|
||||
user3 := AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
|
||||
user4 := AssertExistsAndLoadBean(t, &User{ID: 4}).(*User)
|
||||
|
||||
expectedReviews := []*PullReviewersWithType{}
|
||||
expectedReviews = append(expectedReviews, &PullReviewersWithType{
|
||||
User: *user2,
|
||||
Type: ReviewTypeReject,
|
||||
ReviewUpdatedUnix: 946684810,
|
||||
},
|
||||
&PullReviewersWithType{
|
||||
User: *user3,
|
||||
Type: ReviewTypeReject,
|
||||
ReviewUpdatedUnix: 946684810,
|
||||
},
|
||||
&PullReviewersWithType{
|
||||
User: *user4,
|
||||
Type: ReviewTypeApprove,
|
||||
ReviewUpdatedUnix: 946684810,
|
||||
})
|
||||
|
||||
allReviews, err := GetReviewersByPullID(issue.ID)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, expectedReviews, allReviews)
|
||||
}
|
||||
@@ -832,6 +832,7 @@ issues.review.content.empty = You need to leave a comment indicating the request
|
||||
issues.review.reject = "rejected these changes %s"
|
||||
issues.review.pending = Pending
|
||||
issues.review.review = Review
|
||||
issues.review.reviewers = Reviewers
|
||||
issues.review.show_outdated = Show outdated
|
||||
issues.review.hide_outdated = Hide outdated
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
.tribute-container{box-shadow:0 1px 3px 1px #c7c7c7}.tribute-container ul{background:#fff}.tribute-container li{padding:8px 12px;border-bottom:1px solid #dcdcdc}.tribute-container li img{display:inline-block;vertical-align:middle;width:28px;height:28px;margin-right:5px}.tribute-container li span.fullname{font-weight:400;font-size:.8rem;margin-left:3px}.tribute-container li.highlight,.tribute-container li:hover{background:#2185D0;color:#fff}.emoji{width:1.5em;height:1.5em;display:inline-block;background-size:contain}body{font-family:Lato,"Segoe UI","Microsoft YaHei",Arial,Helvetica,sans-serif!important;background-color:#fff;overflow-y:scroll;-webkit-font-smoothing:antialiased}img{border-radius:3px}table{border-collapse:collapse}.rounded{border-radius:.28571429rem!important}code,pre{font:12px Consolas,"Liberation Mono",Menlo,Courier,monospace}code.raw,pre.raw{padding:7px 12px;margin:10px 0;background-color:#f8f8f8;border:1px solid #ddd;border-radius:3px;font-size:13px;line-height:1.5;overflow:auto}code.wrap,pre.wrap{white-space:pre-wrap;-ms-word-break:break-all;word-break:break-all;overflow-wrap:break-word;word-wrap:break-word}.dont-break-out{overflow-wrap:break-word;word-wrap:break-word;-ms-word-break:break-all;word-break:break-all;-ms-hyphens:auto;-moz-hyphens:auto;-webkit-hyphens:auto;hyphens:auto}.full.height{padding:0;margin:0 0 -40px 0;min-height:100%}.following.bar{z-index:900;left:0;width:100%;margin:0}.following.bar.light{background-color:#fff;border-bottom:1px solid #DDD;box-shadow:0 2px 3px rgba(0,0,0,.04)}.following.bar .column .menu{margin-top:0}.following.bar .top.menu a.item.brand{padding-left:0}.following.bar .brand .ui.mini.image{width:30px}.following.bar .top.menu .dropdown.item.active,.following.bar .top.menu .dropdown.item:hover,.following.bar .top.menu a.item:hover{background-color:transparent}.following.bar .top.menu a.item:hover{color:rgba(0,0,0,.45)}.following.bar .top.menu .menu{z-index:900}.following.bar .octicon{margin-right:.75em}.following.bar .octicon.fitted{margin-right:0}.following.bar .searchbox{background-color:#f4f4f4!important}.following.bar .searchbox:focus{background-color:#e9e9e9!important}.following.bar .text .octicon{width:16px;text-align:center}@media only screen and (max-width:767px){.following.bar #navbar:not(.shown)>:not(:first-child){display:none}}.right.stackable.menu{margin-left:auto;display:flex;display:-ms-flexbox;-ms-flex-align:inherit;align-items:inherit;-ms-flex-direction:inherit;flex-direction:inherit}.ui.left{float:left}.ui.right{float:right}.ui.button,.ui.menu .item{-moz-user-select:auto;-ms-user-select:auto;-webkit-user-select:auto;user-select:auto}.ui.container.fluid.padded{padding:0 10px 0 10px}.ui.form .ui.button{font-weight:400}.ui.floating.label{z-index:10}.ui.transparent.label{background-color:transparent}.ui.menu,.ui.segment,.ui.vertical.menu{box-shadow:none}.ui .menu:not(.vertical) .item>.button.compact{padding:.58928571em 1.125em}.ui .menu:not(.vertical) .item>.button.small{font-size:.92857143rem}.ui.dropdown .menu>.item>.floating.label{z-index:11}.ui.dropdown .menu .menu>.item>.floating.label{z-index:21}.ui .text.red{color:#d95c5c!important}.ui .text.red a{color:#d95c5c!important}.ui .text.red a:hover{color:#E67777!important}.ui .text.blue{color:#428bca!important}.ui .text.blue a{color:#15c!important}.ui .text.blue a:hover{color:#428bca!important}.ui .text.black{color:#444}.ui .text.black:hover{color:#000}.ui .text.grey{color:#767676!important}.ui .text.grey a{color:#444!important}.ui .text.grey a:hover{color:#000!important}.ui .text.light.grey{color:#888!important}.ui .text.green{color:#6cc644!important}.ui .text.purple{color:#6e5494!important}.ui .text.yellow{color:#FBBD08!important}.ui .text.gold{color:#a1882b!important}.ui .text.left{text-align:left!important}.ui .text.right{text-align:right!important}.ui .text.small{font-size:.75em}.ui .text.normal{font-weight:400}.ui .text.bold{font-weight:700}.ui .text.italic{font-style:italic}.ui .text.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:inline-block}.ui .text.thin{font-weight:400}.ui .text.middle{vertical-align:middle}.ui .message{text-align:center}.ui .header>i+.content{padding-left:.75rem;vertical-align:middle}.ui .warning.header{background-color:#F9EDBE!important;border-color:#F0C36D}.ui .warning.segment{border-color:#F0C36D}.ui .info.segment{border:1px solid #c5d5dd}.ui .info.segment.top{background-color:#e6f1f6!important}.ui .info.segment.top h3,.ui .info.segment.top h4{margin-top:0}.ui .info.segment.top h3:last-child{margin-top:4px}.ui .info.segment.top>:last-child{margin-bottom:0}.ui .normal.header{font-weight:400}.ui .avatar.image{border-radius:3px}.ui .form .fake{display:none!important}.ui .form .sub.field{margin-left:25px}.ui .sha.label{font-family:Consolas,Menlo,Monaco,"Lucida Console",monospace;font-size:13px;padding:6px 10px 4px 10px;font-weight:400;margin:0 6px}.ui.status.buttons .octicon{margin-right:4px}.ui.inline.delete-button{padding:8px 15px;fLine truncated
|
||||
.tribute-container{box-shadow:0 1px 3px 1px #c7c7c7}.tribute-container ul{background:#fff}.tribute-container li{padding:8px 12px;border-bottom:1px solid #dcdcdc}.tribute-container li img{display:inline-block;vertical-align:middle;width:28px;height:28px;margin-right:5px}.tribute-container li span.fullname{font-weight:400;font-size:.8rem;margin-left:3px}.tribute-container li.highlight,.tribute-container li:hover{background:#2185D0;color:#fff}.emoji{width:1.5em;height:1.5em;display:inline-block;background-size:contain}body{font-family:Lato,"Segoe UI","Microsoft YaHei",Arial,Helvetica,sans-serif!important;background-color:#fff;overflow-y:scroll;-webkit-font-smoothing:antialiased}img{border-radius:3px}table{border-collapse:collapse}.rounded{border-radius:.28571429rem!important}code,pre{font:12px Consolas,"Liberation Mono",Menlo,Courier,monospace}code.raw,pre.raw{padding:7px 12px;margin:10px 0;background-color:#f8f8f8;border:1px solid #ddd;border-radius:3px;font-size:13px;line-height:1.5;overflow:auto}code.wrap,pre.wrap{white-space:pre-wrap;-ms-word-break:break-all;word-break:break-all;overflow-wrap:break-word;word-wrap:break-word}.dont-break-out{overflow-wrap:break-word;word-wrap:break-word;-ms-word-break:break-all;word-break:break-all;-ms-hyphens:auto;-moz-hyphens:auto;-webkit-hyphens:auto;hyphens:auto}.full.height{padding:0;margin:0 0 -40px 0;min-height:100%}.following.bar{z-index:900;left:0;width:100%;margin:0}.following.bar.light{background-color:#fff;border-bottom:1px solid #DDD;box-shadow:0 2px 3px rgba(0,0,0,.04)}.following.bar .column .menu{margin-top:0}.following.bar .top.menu a.item.brand{padding-left:0}.following.bar .brand .ui.mini.image{width:30px}.following.bar .top.menu .dropdown.item.active,.following.bar .top.menu .dropdown.item:hover,.following.bar .top.menu a.item:hover{background-color:transparent}.following.bar .top.menu a.item:hover{color:rgba(0,0,0,.45)}.following.bar .top.menu .menu{z-index:900}.following.bar .octicon{margin-right:.75em}.following.bar .octicon.fitted{margin-right:0}.following.bar .searchbox{background-color:#f4f4f4!important}.following.bar .searchbox:focus{background-color:#e9e9e9!important}.following.bar .text .octicon{width:16px;text-align:center}@media only screen and (max-width:767px){.following.bar #navbar:not(.shown)>:not(:first-child){display:none}}.right.stackable.menu{margin-left:auto;display:flex;display:-ms-flexbox;-ms-flex-align:inherit;align-items:inherit;-ms-flex-direction:inherit;flex-direction:inherit}.ui.left{float:left}.ui.right{float:right}.ui.button,.ui.menu .item{-moz-user-select:auto;-ms-user-select:auto;-webkit-user-select:auto;user-select:auto}.ui.container.fluid.padded{padding:0 10px 0 10px}.ui.form .ui.button{font-weight:400}.ui.floating.label{z-index:10}.ui.transparent.label{background-color:transparent}.ui.menu,.ui.segment,.ui.vertical.menu{box-shadow:none}.ui .menu:not(.vertical) .item>.button.compact{padding:.58928571em 1.125em}.ui .menu:not(.vertical) .item>.button.small{font-size:.92857143rem}.ui.dropdown .menu>.item>.floating.label{z-index:11}.ui.dropdown .menu .menu>.item>.floating.label{z-index:21}.ui .text.red{color:#d95c5c!important}.ui .text.red a{color:#d95c5c!important}.ui .text.red a:hover{color:#E67777!important}.ui .text.blue{color:#428bca!important}.ui .text.blue a{color:#15c!important}.ui .text.blue a:hover{color:#428bca!important}.ui .text.black{color:#444}.ui .text.black:hover{color:#000}.ui .text.grey{color:#767676!important}.ui .text.grey a{color:#444!important}.ui .text.grey a:hover{color:#000!important}.ui .text.light.grey{color:#888!important}.ui .text.green{color:#6cc644!important}.ui .text.purple{color:#6e5494!important}.ui .text.yellow{color:#FBBD08!important}.ui .text.gold{color:#a1882b!important}.ui .text.left{text-align:left!important}.ui .text.right{text-align:right!important}.ui .text.small{font-size:.75em}.ui .text.normal{font-weight:400}.ui .text.bold{font-weight:700}.ui .text.italic{font-style:italic}.ui .text.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:inline-block}.ui .text.thin{font-weight:400}.ui .text.middle{vertical-align:middle}.ui .message{text-align:center}.ui .header>i+.content{padding-left:.75rem;vertical-align:middle}.ui .warning.header{background-color:#F9EDBE!important;border-color:#F0C36D}.ui .warning.segment{border-color:#F0C36D}.ui .info.segment{border:1px solid #c5d5dd}.ui .info.segment.top{background-color:#e6f1f6!important}.ui .info.segment.top h3,.ui .info.segment.top h4{margin-top:0}.ui .info.segment.top h3:last-child{margin-top:4px}.ui .info.segment.top>:last-child{margin-bottom:0}.ui .normal.header{font-weight:400}.ui .avatar.image{border-radius:3px}.ui .form .fake{display:none!important}.ui .form .sub.field{margin-left:25px}.ui .sha.label{font-family:Consolas,Menlo,Monaco,"Lucida Console",monospace;font-size:13px;padding:6px 10px 4px 10px;font-weight:400;margin:0 6px}.ui.status.buttons .octicon{margin-right:4px}.ui.inline.delete-button{padding:8px 15px;fLine truncated
|
||||
@@ -556,6 +556,38 @@
|
||||
margin-top: 10px;
|
||||
}
|
||||
}
|
||||
.review-item {
|
||||
|
||||
.avatar, .type-icon{
|
||||
float: none;
|
||||
display: inline-block;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
|
||||
.octicon {
|
||||
width: 23px;
|
||||
font-size: 23px;
|
||||
margin-top: 0.45em;
|
||||
}
|
||||
}
|
||||
|
||||
.text {
|
||||
margin: .3em 0 .5em .5em
|
||||
}
|
||||
|
||||
.type-icon{
|
||||
float: right;
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
.divider{
|
||||
margin: .5rem 0;
|
||||
}
|
||||
|
||||
.review-content {
|
||||
padding: 1em 0 1em 3.8em;
|
||||
}
|
||||
}
|
||||
}
|
||||
.comment-list {
|
||||
&:before {
|
||||
|
||||
@@ -802,6 +802,12 @@ func ViewIssue(ctx *context.Context) {
|
||||
}
|
||||
}
|
||||
ctx.Data["IsPullBranchDeletable"] = canDelete && pull.HeadRepo != nil && git.IsBranchExist(pull.HeadRepo.RepoPath(), pull.HeadBranch)
|
||||
|
||||
ctx.Data["PullReviewersWithType"], err = models.GetReviewersByPullID(issue.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetReviewersByPullID", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Get Dependencies
|
||||
|
||||
@@ -1,3 +1,38 @@
|
||||
{{if gt (len .PullReviewersWithType) 0}}
|
||||
<div class="comment box">
|
||||
<div class="content">
|
||||
<div class="ui segment">
|
||||
<h4>{{$.i18n.Tr "repo.issues.review.reviewers"}}</h4>
|
||||
{{range .PullReviewersWithType}}
|
||||
{{ $createdStr:= TimeSinceUnix .ReviewUpdatedUnix $.Lang }}
|
||||
<div class="ui divider"></div>
|
||||
<div class="review-item">
|
||||
<span class="type-icon text {{if eq .Type 1}}green
|
||||
{{else if eq .Type 2}}grey
|
||||
{{else if eq .Type 3}}red
|
||||
{{else}}grey{{end}}">
|
||||
<span class="octicon octicon-{{.Type.Icon}}"></span>
|
||||
</span>
|
||||
<a class="ui avatar image" href="{{.HomeLink}}">
|
||||
<img src="{{.RelAvatarLink}}">
|
||||
</a>
|
||||
<span class="text grey"><a href="{{.HomeLink}}">{{.Name}}</a>
|
||||
{{if eq .Type 1}}
|
||||
{{$.i18n.Tr "repo.issues.review.approve" $createdStr | Safe}}
|
||||
{{else if eq .Type 2}}
|
||||
{{$.i18n.Tr "repo.issues.review.comment" $createdStr | Safe}}
|
||||
{{else if eq .Type 3}}
|
||||
{{$.i18n.Tr "repo.issues.review.reject" $createdStr | Safe}}
|
||||
{{else}}
|
||||
{{$.i18n.Tr "repo.issues.review.comment" $createdStr | Safe}}
|
||||
{{end}}
|
||||
</span>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
<div class="comment merge box">
|
||||
<a class="avatar text
|
||||
{{if .Issue.PullRequest.HasMerged}}purple
|
||||
|
||||
Reference in new issue
Block a user