mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-23 20:17:03 +01:00
Show original author's reviews on pull summary box (#13127)
follow #12039, show original author's reviews by other way. fix #11705. Signed-off-by: a1012112796 <1012112796@qq.com>
This commit is contained in:
parent
e70df67d47
commit
97980146c5
4 changed files with 53 additions and 2 deletions
|
@ -486,6 +486,20 @@ func GetReviewersByIssueID(issueID int64) ([]*Review, error) {
|
|||
return reviews, nil
|
||||
}
|
||||
|
||||
// GetReviewersFromOriginalAuthorsByIssueID gets the latest review of each original authors for a pull request
|
||||
func GetReviewersFromOriginalAuthorsByIssueID(issueID int64) ([]*Review, error) {
|
||||
reviews := make([]*Review, 0, 10)
|
||||
|
||||
// Get latest review of each reviwer, sorted in order they were made
|
||||
if err := x.SQL("SELECT * FROM review WHERE id IN (SELECT max(id) as id FROM review WHERE issue_id = ? AND reviewer_team_id = 0 AND type in (?, ?, ?) AND original_author_id <> 0 GROUP BY issue_id, original_author_id) ORDER BY review.updated_unix ASC",
|
||||
issueID, ReviewTypeApprove, ReviewTypeReject, ReviewTypeRequest).
|
||||
Find(&reviews); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return reviews, nil
|
||||
}
|
||||
|
||||
// GetReviewByIssueIDAndUserID get the latest review of reviewer for a pull request
|
||||
func GetReviewByIssueIDAndUserID(issueID, userID int64) (*Review, error) {
|
||||
return getReviewByIssueIDAndUserID(x, issueID, userID)
|
||||
|
|
|
@ -450,6 +450,13 @@ type repoReviewerSelection struct {
|
|||
func RetrieveRepoReviewers(ctx *context.Context, repo *models.Repository, issue *models.Issue, canChooseReviewer bool) {
|
||||
ctx.Data["CanChooseReviewer"] = canChooseReviewer
|
||||
|
||||
originalAuthorReviews, err := models.GetReviewersFromOriginalAuthorsByIssueID(issue.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetReviewersFromOriginalAuthorsByIssueID", err)
|
||||
return
|
||||
}
|
||||
ctx.Data["OriginalReviews"] = originalAuthorReviews
|
||||
|
||||
reviews, err := models.GetReviewersByIssueID(issue.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetReviewersByIssueID", err)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{{if .PullReviewers }}
|
||||
{{if or .PullReviewers .OriginalReviews }}
|
||||
<div class="comment box">
|
||||
<div class="content">
|
||||
<div class="ui segment">
|
||||
|
@ -54,6 +54,24 @@
|
|||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
{{range .OriginalReviews}}
|
||||
{{ $createdStr:= TimeSinceUnix .UpdatedUnix $.Lang }}
|
||||
<div class="ui divider"></div>
|
||||
<div class="review-item">
|
||||
<div class="review-item-left">
|
||||
<a href="{{$.Repository.OriginalURL}}" class="ui poping up" data-content="{{$.i18n.Tr "repo.migrated_from_fake" $.Repository.GetOriginalURLHostname | Safe }}"><span class="text black "><i class="fa {{MigrationIcon $.Repository.GetOriginalURLHostname}}" aria-hidden="true"></i> {{ .OriginalAuthor }}</span></a>
|
||||
</div>
|
||||
<div class="review-item-right">
|
||||
<span class="type-icon text {{if eq .Type 1}}green
|
||||
{{- else if eq .Type 2}}grey
|
||||
{{- else if eq .Type 3}}red
|
||||
{{- else if eq .Type 4}}yellow
|
||||
{{else}}grey{{end}}">
|
||||
{{svg (printf "octicon-%s" .Type.Icon)}}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
</div>
|
||||
|
||||
<div class="ui assignees list">
|
||||
<span class="no-select item {{if .PullReviewers}}hide{{end}}">{{.i18n.Tr "repo.issues.new.no_reviewers"}}</span>
|
||||
<span class="no-select item {{if or .OriginalReviews .PullReviewers}}hide{{end}}">{{.i18n.Tr "repo.issues.new.no_reviewers"}}</span>
|
||||
<div class="selected">
|
||||
{{range .PullReviewers}}
|
||||
<div class="item" style="margin-bottom: 10px;">
|
||||
|
@ -73,6 +73,18 @@
|
|||
</span>
|
||||
</div>
|
||||
{{end}}
|
||||
{{range .OriginalReviews}}
|
||||
<div class="item" style="margin-bottom: 10px;">
|
||||
<a href="{{$.Repository.OriginalURL}}" class="ui poping up" data-content="{{$.i18n.Tr "repo.migrated_from_fake" $.Repository.GetOriginalURLHostname | Safe }}"><span class="text black "><i class="fa {{MigrationIcon $.Repository.GetOriginalURLHostname}}" aria-hidden="true"></i> {{ .OriginalAuthor }}</span></a>
|
||||
<span class="ui right type-icon text {{if eq .Type 1}}green
|
||||
{{- else if eq .Type 2}}grey
|
||||
{{- else if eq .Type 3}}red
|
||||
{{- else if eq .Type 4}}yellow
|
||||
{{- else}}grey{{end}} right ">
|
||||
{{svg (printf "octicon-%s" .Type.Icon)}}
|
||||
</span>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui divider"></div>
|
||||
|
|
Loading…
Reference in a new issue