From ae0fa64ef6261bc99b9b7f6af2047c017399f509 Mon Sep 17 00:00:00 2001 From: silverwind Date: Wed, 10 May 2023 11:16:44 +0200 Subject: [PATCH] Review fixes and enhancements (#24526) - Fix regression with icons wrapping from https://github.com/go-gitea/gitea/pull/24459 - Fix box misalignment on small screen - Fix avatar misalignment on review comment - Fix incorrect underline hover effect on review icons - Move status icon to left side in review box - Enhance review icon colors, add helper function for it - Add missing inline avatars in review comments - Tweak icon sizes because some octicons have inconsistent sizing ### Before Screenshot 2023-05-04 at 20 50 28 Screenshot 2023-05-04 at 20 50 42 ### After Screenshot 2023-05-04 at 20 55 08 Screenshot 2023-05-04 at 20 55 16 --------- Co-authored-by: Giteabot --- models/issues/review.go | 14 +++++ .../repo/issue/view_content/comments.tmpl | 18 ++++++- templates/repo/issue/view_content/pull.tmpl | 51 +++++++------------ .../repo/issue/view_content/sidebar.tmpl | 22 +++----- web_src/css/repository.css | 40 +++++++-------- 5 files changed, 74 insertions(+), 71 deletions(-) diff --git a/models/issues/review.go b/models/issues/review.go index fe123d7398..ed30bce149 100644 --- a/models/issues/review.go +++ b/models/issues/review.go @@ -189,6 +189,20 @@ func (r *Review) LoadAttributes(ctx context.Context) (err error) { return err } +func (r *Review) HTMLTypeColorName() string { + switch r.Type { + case ReviewTypeApprove: + return "green" + case ReviewTypeComment: + return "grey" + case ReviewTypeReject: + return "red" + case ReviewTypeRequest: + return "yellow" + } + return "grey" +} + // GetReviewByID returns the review by the given ID func GetReviewByID(ctx context.Context, id int64) (*Review, error) { review := new(Review) diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index 13e3b53051..ab499f346a 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -372,7 +372,10 @@
{{if .OriginalAuthor}} {{else}} - + {{/* Some timeline avatars need a offset to correctly allign with their speech + bubble. The condition depends on review type and for positive reviews whether + there is a comment element or not */}} + {{avatar $.Context .Poster}} {{end}} @@ -408,6 +411,11 @@
+ {{if gt .Poster.ID 0}} + + {{avatar $.Context .Poster}} + + {{end}} {{if .OriginalAuthor}} @@ -763,6 +771,7 @@ {{svg "octicon-x" 16}} + {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}} {{template "shared/user/authorlink" .Poster}} {{$reviewerName := ""}} @@ -777,7 +786,12 @@ {{if .Content}}
-
+
+ {{if gt .Poster.ID 0}} + + {{avatar $.Context .Poster}} + + {{end}} {{$.locale.Tr "action.review_dismissed_reason"}} diff --git a/templates/repo/issue/view_content/pull.tmpl b/templates/repo/issue/view_content/pull.tmpl index 29d8d9d47c..907ee19857 100644 --- a/templates/repo/issue/view_content/pull.tmpl +++ b/templates/repo/issue/view_content/pull.tmpl @@ -1,5 +1,5 @@ {{if or .PullReviewers .OriginalReviews}} -
+

{{$.locale.Tr "repo.issues.review.reviewers"}}

@@ -8,9 +8,12 @@
+ + {{svg (printf "octicon-%s" .Review.Type.Icon)}} + {{if .User}} - {{avatar $.Context .User}} + {{avatar $.Context .User 20}} {{end}} @@ -34,13 +37,13 @@
{{if .Review.Stale}} - + {{svg "octicon-hourglass" 16 "icon"}} {{end}} {{if (and $.Permission.IsAdmin (or (eq .Review.Type 1) (eq .Review.Type 3)) (not $.Issue.IsClosed))}} - - {{svg "octicon-x" 16}} + + {{svg "octicon-x" 20}} {{end}} - - - {{if .CanChange}} - - {{if .Checked}} {{svg "octicon-trash"}} {{else}} {{svg "octicon-sync"}} {{end}} - - {{end}} - {{svg (printf "octicon-%s" .Review.Type.Icon)}} - + {{if .CanChange}} + {{if .Checked}}{{svg "octicon-trash"}}{{else}}{{svg "octicon-sync"}}{{end}} + {{end}}
{{end}} @@ -86,22 +79,16 @@
-
- - {{svg (printf "octicon-%s" .Type.Icon)}} - -
{{end}}
@@ -204,7 +191,7 @@
{{else if .Issue.PullRequest.IsAncestor}}
- {{svg "octicon-alert" 16}} + {{svg "octicon-alert"}} {{$.locale.Tr "repo.pulls.is_ancestor"}}
{{else if or .Issue.PullRequest.CanAutoMerge .Issue.PullRequest.IsEmpty}} @@ -230,7 +217,7 @@
{{else if .IsBlockedByChangedProtectedFiles}}
- {{svg "octicon-x" 16}} + {{svg "octicon-x"}} {{$.locale.TrN $.ChangedProtectedFilesNum "repo.pulls.blocked_by_changed_protected_files_1" "repo.pulls.blocked_by_changed_protected_files_n" | Safe}}
    {{range .ChangedProtectedFiles}} @@ -294,7 +281,7 @@
    - {{svg "octicon-alert" 16}} + {{svg "octicon-alert"}} {{$.locale.Tr "repo.pulls.is_empty"}}
    {{end}} @@ -430,7 +417,7 @@
{{else if .IsBlockedByChangedProtectedFiles}}
- {{svg "octicon-x" 16}} + {{svg "octicon-x"}} {{$.locale.TrN $.ChangedProtectedFilesNum "repo.pulls.blocked_by_changed_protected_files_1" "repo.pulls.blocked_by_changed_protected_files_n" | Safe}}