From 0eac09e0662ae70b8b6e3e5e8c33547c79ff7124 Mon Sep 17 00:00:00 2001 From: Gusted Date: Sat, 7 May 2022 05:35:12 +0000 Subject: [PATCH] Improve reviewing PR UX (#19612) --- routers/web/repo/pull.go | 18 +++++++++++++++++- templates/repo/diff/comments.tmpl | 2 +- templates/repo/diff/new_review.tmpl | 1 + web_src/js/features/repo-diff.js | 17 ++++++++++++++++- web_src/js/features/repo-issue.js | 10 ++++++++++ web_src/less/_review.less | 13 +++++++++++++ web_src/less/animations.less | 16 ++++++++++++++++ 7 files changed, 74 insertions(+), 3 deletions(-) diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go index 74028c316c..7cedeec10e 100644 --- a/routers/web/repo/pull.go +++ b/routers/web/repo/pull.go @@ -752,11 +752,27 @@ func ViewPullFiles(ctx *context.Context) { if ctx.Written() { return } - ctx.Data["CurrentReview"], err = models.GetCurrentReview(ctx.Doer, issue) + + currentReview, err := models.GetCurrentReview(ctx.Doer, issue) if err != nil && !models.IsErrReviewNotExist(err) { ctx.ServerError("GetCurrentReview", err) return } + numPendingCodeComments := int64(0) + if currentReview != nil { + numPendingCodeComments, err = models.CountComments(&models.FindCommentsOptions{ + Type: models.CommentTypeCode, + ReviewID: currentReview.ID, + IssueID: issue.ID, + }) + if err != nil { + ctx.ServerError("CountComments", err) + return + } + } + ctx.Data["CurrentReview"] = currentReview + ctx.Data["PendingCodeCommentNumber"] = numPendingCodeComments + getBranchData(ctx, issue) ctx.Data["IsIssuePoster"] = ctx.IsSigned && issue.IsPoster(ctx.Doer.ID) ctx.Data["HasIssuesOrPullsWritePermission"] = ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull) diff --git a/templates/repo/diff/comments.tmpl b/templates/repo/diff/comments.tmpl index 3b8f1c2a9c..863e295862 100644 --- a/templates/repo/diff/comments.tmpl +++ b/templates/repo/diff/comments.tmpl @@ -37,7 +37,7 @@
{{if and .Review}} {{if eq .Review.Type 0}} -
+
{{$.root.i18n.Tr "repo.issues.review.pending"}}
{{else}} diff --git a/templates/repo/diff/new_review.tmpl b/templates/repo/diff/new_review.tmpl index cbaabe255e..e4110b50ed 100644 --- a/templates/repo/diff/new_review.tmpl +++ b/templates/repo/diff/new_review.tmpl @@ -1,6 +1,7 @@