From 268f3edbc4983597e7a182a98ed7f93fd2cec646 Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 4 May 2023 20:47:06 +0200 Subject: [PATCH 01/14] Review fixes and enhancements --- modules/templates/helper.go | 1 + modules/templates/util_misc.go | 15 ++++++++ templates/repo/issue/view_content/pull.tmpl | 32 ++++++----------- .../repo/issue/view_content/sidebar.tmpl | 15 +++----- web_src/css/repository.css | 34 ++++++++----------- 5 files changed, 46 insertions(+), 51 deletions(-) diff --git a/modules/templates/helper.go b/modules/templates/helper.go index 4abd94d46e59e..a13bd97d41e4c 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -188,6 +188,7 @@ func NewFuncMap() template.FuncMap { "FilenameIsImage": FilenameIsImage, "TabSizeClass": TabSizeClass, + "ReviewTypeColor": ReviewTypeColor, } } diff --git a/modules/templates/util_misc.go b/modules/templates/util_misc.go index 599a0942ce782..6eb452e48a3aa 100644 --- a/modules/templates/util_misc.go +++ b/modules/templates/util_misc.go @@ -13,6 +13,7 @@ import ( "time" activities_model "code.gitea.io/gitea/models/activities" + issue_model "code.gitea.io/gitea/models/issues" repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/modules/git" giturl "code.gitea.io/gitea/modules/git/url" @@ -135,6 +136,20 @@ func DiffLineTypeToStr(diffType int) string { return "same" } +func ReviewTypeColor(review issue_model.Review) string { + switch review.Type { + case 1: + return "green" + case 2: + return "grey" + case 3: + return "red" + case 4: + return "yellow" + } + return "grey" +} + // MigrationIcon returns a SVG name matching the service an issue/comment was migrated from func MigrationIcon(hostname string) string { switch hostname { diff --git a/templates/repo/issue/view_content/pull.tmpl b/templates/repo/issue/view_content/pull.tmpl index 29d8d9d47ce96..45089ff3e77fa 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}} -
+
@@ -86,6 +81,9 @@
-
- - {{svg (printf "octicon-%s" .Type.Icon)}} - -
+
{{end}}
diff --git a/templates/repo/issue/view_content/sidebar.tmpl b/templates/repo/issue/view_content/sidebar.tmpl index 86796a91cbb95..03c32aa61d6f5 100644 --- a/templates/repo/issue/view_content/sidebar.tmpl +++ b/templates/repo/issue/view_content/sidebar.tmpl @@ -61,18 +61,11 @@ {{else if .Team}} {{svg "octicon-people" 16 "teamavatar"}}{{$.Issue.Repo.OwnerName}}/{{.Team.Name}} {{end}} - - + {{if .CanChange}} - - {{if .Checked}} {{svg "octicon-trash"}} {{else}} {{svg "octicon-sync"}} {{end}} - + {{if .Checked}}{{svg "octicon-trash"}}{{else}}{{svg "octicon-sync"}}{{end}} {{end}} - {{svg (printf "octicon-%s" .Review.Type.Icon)}} + {{svg (printf "octicon-%s" .Review.Type.Icon) 18 (printf "text %s" (ReviewTypeColor .Review))}}
{{end}} @@ -84,7 +77,7 @@ {{.OriginalAuthor}} - Date: Thu, 4 May 2023 21:22:58 +0200 Subject: [PATCH 02/14] add avatars to review and review dismiss events --- templates/repo/issue/view_content/comments.tmpl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index 13e3b53051936..ee871b8e2e98a 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -377,6 +377,7 @@ {{end}} {{svg (printf "octicon-%s" .Review.Type.Icon)}} + {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}} {{if .OriginalAuthor}} @@ -763,6 +764,7 @@ {{svg "octicon-x" 16}} + {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}} {{template "shared/user/authorlink" .Poster}} {{$reviewerName := ""}} From 5438a5ba6c23ef67c02378b0175df88051ef6d56 Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 4 May 2023 22:02:43 +0200 Subject: [PATCH 03/14] add missing inline avatars, fix avatar offset, icon size tweaks --- templates/repo/issue/view_content/comments.tmpl | 14 ++++++++++++-- templates/repo/issue/view_content/pull.tmpl | 14 ++++++-------- templates/repo/issue/view_content/sidebar.tmpl | 5 +---- web_src/css/repository.css | 4 +++- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index ee871b8e2e98a..db676b32d4b49 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -372,7 +372,7 @@
{{if .OriginalAuthor}} {{else}} - + {{avatar $.Context .Poster}} {{end}} @@ -409,6 +409,11 @@
+ {{if gt .Poster.ID 0}} + + {{avatar $.Context .Poster}} + + {{end}} {{if .OriginalAuthor}} @@ -779,7 +784,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 45089ff3e77fa..930a1148e3b3e 100644 --- a/templates/repo/issue/view_content/pull.tmpl +++ b/templates/repo/issue/view_content/pull.tmpl @@ -12,7 +12,7 @@ {{svg (printf "octicon-%s" .Review.Type.Icon) 18}} {{if .User}} - + {{avatar $.Context .User}} {{end}} @@ -43,7 +43,7 @@ {{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}} - + {{if .CanChange}} + {{if .Checked}}{{svg "octicon-trash"}}{{else}}{{svg "octicon-sync"}}{{end}} + {{end}}
{{end}} @@ -85,7 +83,7 @@ {{svg (printf "octicon-%s" .Type.Icon) 18}} - + {{svg (MigrationIcon $.Repository.GetOriginalURLHostname)}} {{.OriginalAuthor}} diff --git a/templates/repo/issue/view_content/sidebar.tmpl b/templates/repo/issue/view_content/sidebar.tmpl index 03c32aa61d6f5..41efea08c5b3a 100644 --- a/templates/repo/issue/view_content/sidebar.tmpl +++ b/templates/repo/issue/view_content/sidebar.tmpl @@ -54,10 +54,7 @@ {{range .PullReviewers}}
{{if .User}} - - {{avatar $.Context .User 28 "gt-mr-3"}} - {{.User.GetDisplayName}} - + {{avatar $.Context .User 28 "gt-mr-3"}}{{.User.GetDisplayName}} {{else if .Team}} {{svg "octicon-people" 16 "teamavatar"}}{{$.Issue.Repo.OwnerName}}/{{.Team.Name}} {{end}} diff --git a/web_src/css/repository.css b/web_src/css/repository.css index 80e59be1e7790..9e63ce344b557 100644 --- a/web_src/css/repository.css +++ b/web_src/css/repository.css @@ -774,7 +774,7 @@ padding-bottom: 8px; } -.repository.view.issue .comment-list .timeline-item-group .timeline-avatar { +.repository.view.issue .comment-list .timeline-item-group .timeline-avatar-offset { margin-top: 48px; } @@ -3257,6 +3257,8 @@ td.blob-excerpt { .repository.view.issue .comment-list .timeline .inline-timeline-avatar { display: flex; margin-bottom: auto; + margin-left: 6px; + margin-right: 2px; } .repository.view.issue .comment-list .timeline .inline-timeline-avatar img.avatar { height: 24px; From 043b6f8bfb9fc7b0e0a02c41ce174b32adbb01d7 Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 4 May 2023 22:34:04 +0200 Subject: [PATCH 04/14] Update web_src/css/repository.css --- web_src/css/repository.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_src/css/repository.css b/web_src/css/repository.css index 9e63ce344b557..8a8a7964da25d 100644 --- a/web_src/css/repository.css +++ b/web_src/css/repository.css @@ -774,7 +774,7 @@ padding-bottom: 8px; } -.repository.view.issue .comment-list .timeline-item-group .timeline-avatar-offset { +.repository.view.issue .comment-list .timeline-avatar-offset { margin-top: 48px; } From 768672245df1c17246abcd4763c434f95947d4fb Mon Sep 17 00:00:00 2001 From: silverwind Date: Mon, 8 May 2023 22:27:07 +0200 Subject: [PATCH 05/14] move to .Review.HTMLTypeColorName --- models/issues/review.go | 15 +++++++++++++++ modules/templates/helper.go | 1 - modules/templates/util_misc.go | 15 --------------- templates/repo/issue/view_content/pull.tmpl | 4 ++-- templates/repo/issue/view_content/sidebar.tmpl | 2 +- 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/models/issues/review.go b/models/issues/review.go index fe123d73986bd..b2d5734de938c 100644 --- a/models/issues/review.go +++ b/models/issues/review.go @@ -189,6 +189,21 @@ func (r *Review) LoadAttributes(ctx context.Context) (err error) { return err } + +func (r *Review) HTMLTypeColorName() string { + switch r.Type { + case 1: + return "green" + case 2: + return "grey" + case 3: + return "red" + case 4: + 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/modules/templates/helper.go b/modules/templates/helper.go index a13bd97d41e4c..4abd94d46e59e 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -188,7 +188,6 @@ func NewFuncMap() template.FuncMap { "FilenameIsImage": FilenameIsImage, "TabSizeClass": TabSizeClass, - "ReviewTypeColor": ReviewTypeColor, } } diff --git a/modules/templates/util_misc.go b/modules/templates/util_misc.go index 6eb452e48a3aa..599a0942ce782 100644 --- a/modules/templates/util_misc.go +++ b/modules/templates/util_misc.go @@ -13,7 +13,6 @@ import ( "time" activities_model "code.gitea.io/gitea/models/activities" - issue_model "code.gitea.io/gitea/models/issues" repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/modules/git" giturl "code.gitea.io/gitea/modules/git/url" @@ -136,20 +135,6 @@ func DiffLineTypeToStr(diffType int) string { return "same" } -func ReviewTypeColor(review issue_model.Review) string { - switch review.Type { - case 1: - return "green" - case 2: - return "grey" - case 3: - return "red" - case 4: - return "yellow" - } - return "grey" -} - // MigrationIcon returns a SVG name matching the service an issue/comment was migrated from func MigrationIcon(hostname string) string { switch hostname { diff --git a/templates/repo/issue/view_content/pull.tmpl b/templates/repo/issue/view_content/pull.tmpl index 930a1148e3b3e..93e5489510586 100644 --- a/templates/repo/issue/view_content/pull.tmpl +++ b/templates/repo/issue/view_content/pull.tmpl @@ -8,7 +8,7 @@
- + {{svg (printf "octicon-%s" .Review.Type.Icon) 18}} {{if .User}} @@ -79,7 +79,7 @@
- + {{svg (printf "octicon-%s" .Type.Icon) 18}} diff --git a/templates/repo/issue/view_content/sidebar.tmpl b/templates/repo/issue/view_content/sidebar.tmpl index 41efea08c5b3a..d706633c16e91 100644 --- a/templates/repo/issue/view_content/sidebar.tmpl +++ b/templates/repo/issue/view_content/sidebar.tmpl @@ -62,7 +62,7 @@ {{if .CanChange}} {{if .Checked}}{{svg "octicon-trash"}}{{else}}{{svg "octicon-sync"}}{{end}} {{end}} - {{svg (printf "octicon-%s" .Review.Type.Icon) 18 (printf "text %s" (ReviewTypeColor .Review))}} + {{svg (printf "octicon-%s" .Review.Type.Icon) 18 (printf "text %s" (.Review.HTMLTypeColorName))}}
{{end}} From 293d98c193e33ceedba9c8d7579da09ba9d82153 Mon Sep 17 00:00:00 2001 From: silverwind Date: Mon, 8 May 2023 22:50:19 +0200 Subject: [PATCH 06/14] misc tweaks, decrease review list avatar size --- templates/repo/issue/view_content/pull.tmpl | 10 +++++----- templates/repo/issue/view_content/sidebar.tmpl | 4 ++-- web_src/css/repository.css | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/templates/repo/issue/view_content/pull.tmpl b/templates/repo/issue/view_content/pull.tmpl index 93e5489510586..df10d68343f68 100644 --- a/templates/repo/issue/view_content/pull.tmpl +++ b/templates/repo/issue/view_content/pull.tmpl @@ -9,11 +9,11 @@
- {{svg (printf "octicon-%s" .Review.Type.Icon) 18}} + {{svg (printf "octicon-%s" .Review.Type.Icon) 16}} {{if .User}} - - {{avatar $.Context .User}} + + {{avatar $.Context .User 20}} {{end}} @@ -42,7 +42,7 @@ {{end}} {{if (and $.Permission.IsAdmin (or (eq .Review.Type 1) (eq .Review.Type 3)) (not $.Issue.IsClosed))}} - + {{svg "octicon-x" 20}} {{end}} {{if .CanChange}} - {{if .Checked}}{{svg "octicon-trash"}}{{else}}{{svg "octicon-sync"}}{{end}} + {{if .Checked}}{{svg "octicon-trash"}}{{else}}{{svg "octicon-sync"}}{{end}} {{end}}
diff --git a/templates/repo/issue/view_content/sidebar.tmpl b/templates/repo/issue/view_content/sidebar.tmpl index d706633c16e91..c8e65d0900b5b 100644 --- a/templates/repo/issue/view_content/sidebar.tmpl +++ b/templates/repo/issue/view_content/sidebar.tmpl @@ -62,12 +62,12 @@ {{if .CanChange}} {{if .Checked}}{{svg "octicon-trash"}}{{else}}{{svg "octicon-sync"}}{{end}} {{end}} - {{svg (printf "octicon-%s" .Review.Type.Icon) 18 (printf "text %s" (.Review.HTMLTypeColorName))}} + {{svg (printf "octicon-%s" .Review.Type.Icon) 16 (printf "text %s" (.Review.HTMLTypeColorName))}}
{{end}} {{range .OriginalReviews}} -
+
{{svg (MigrationIcon $.Repository.GetOriginalURLHostname)}} diff --git a/web_src/css/repository.css b/web_src/css/repository.css index 8a8a7964da25d..0d81d65110689 100644 --- a/web_src/css/repository.css +++ b/web_src/css/repository.css @@ -1094,8 +1094,8 @@ margin-left: 3em; } -.repository.view.issue .comment-list .code-comment img.avatar, -.repository.view.issue .comment-list .comment img.avatar { +.repository.view.issue .comment-code-cloud .comment-list .code-comment img.avatar, +.repository.view.issue .comment-code-cloud .comment-list .comment img.avatar { width: 28px; height: 28px; } From 9a72ff882ab5420689dc5504dee90aac6e170858 Mon Sep 17 00:00:00 2001 From: silverwind Date: Mon, 8 May 2023 23:14:46 +0200 Subject: [PATCH 07/14] make fmt --- models/issues/review.go | 1 - 1 file changed, 1 deletion(-) diff --git a/models/issues/review.go b/models/issues/review.go index b2d5734de938c..4aa108f92ec8c 100644 --- a/models/issues/review.go +++ b/models/issues/review.go @@ -189,7 +189,6 @@ func (r *Review) LoadAttributes(ctx context.Context) (err error) { return err } - func (r *Review) HTMLTypeColorName() string { switch r.Type { case 1: From ebbfa0eab0223f4228b727ba30842769cd016510 Mon Sep 17 00:00:00 2001 From: silverwind Date: Mon, 8 May 2023 23:25:01 +0200 Subject: [PATCH 08/14] final avatar fixes for review timeline --- templates/repo/issue/view_content/comments.tmpl | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index db676b32d4b49..c4523e654564b 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -372,12 +372,11 @@
{{if .OriginalAuthor}} {{else}} - + {{avatar $.Context .Poster}} {{end}} {{svg (printf "octicon-%s" .Review.Type.Icon)}} - {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}} {{if .OriginalAuthor}} @@ -409,11 +408,6 @@
- {{if gt .Poster.ID 0}} - - {{avatar $.Context .Poster}} - - {{end}} {{if .OriginalAuthor}} From 396b9d1f26ba984bc2b02b52484551dfd8b90ebb Mon Sep 17 00:00:00 2001 From: silverwind Date: Mon, 8 May 2023 23:26:49 +0200 Subject: [PATCH 09/14] restore inline avatar --- templates/repo/issue/view_content/comments.tmpl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index c4523e654564b..a4b72b5d7fa37 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -408,6 +408,11 @@
+ {{if gt .Poster.ID 0}} + + {{avatar $.Context .Poster}} + + {{end}} {{if .OriginalAuthor}} From a963dd2f504900a29f50047309300e7d902c1ac1 Mon Sep 17 00:00:00 2001 From: silverwind Date: Wed, 10 May 2023 00:07:11 +0200 Subject: [PATCH 10/14] use constants --- models/issues/review.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/models/issues/review.go b/models/issues/review.go index 4aa108f92ec8c..ed30bce149a3b 100644 --- a/models/issues/review.go +++ b/models/issues/review.go @@ -191,13 +191,13 @@ func (r *Review) LoadAttributes(ctx context.Context) (err error) { func (r *Review) HTMLTypeColorName() string { switch r.Type { - case 1: + case ReviewTypeApprove: return "green" - case 2: + case ReviewTypeComment: return "grey" - case 3: + case ReviewTypeReject: return "red" - case 4: + case ReviewTypeRequest: return "yellow" } return "grey" From dbea7c3ce745137d693f36386801fd37a84c2b79 Mon Sep 17 00:00:00 2001 From: silverwind Date: Wed, 10 May 2023 00:10:47 +0200 Subject: [PATCH 11/14] add comment --- templates/repo/issue/view_content/comments.tmpl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index a4b72b5d7fa37..75804de1cb611 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -372,6 +372,9 @@
{{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}} From 38ee4daae30eb4b4e09887d360d35ab94f53d010 Mon Sep 17 00:00:00 2001 From: silverwind Date: Wed, 10 May 2023 00:15:15 +0200 Subject: [PATCH 12/14] use 16px everywhere except dismiss --- templates/repo/issue/view_content/pull.tmpl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/templates/repo/issue/view_content/pull.tmpl b/templates/repo/issue/view_content/pull.tmpl index df10d68343f68..5c78a3599146a 100644 --- a/templates/repo/issue/view_content/pull.tmpl +++ b/templates/repo/issue/view_content/pull.tmpl @@ -9,7 +9,7 @@
- {{svg (printf "octicon-%s" .Review.Type.Icon) 16}} + {{svg (printf "octicon-%s" .Review.Type.Icon)}} {{if .User}} @@ -80,7 +80,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}} @@ -282,7 +282,7 @@
    - {{svg "octicon-alert" 16}} + {{svg "octicon-alert"}} {{$.locale.Tr "repo.pulls.is_empty"}}
    {{end}} @@ -418,7 +418,7 @@
{{else if .IsBlockedByChangedProtectedFiles}}
-
{{end}}
From 26d2a1381184007e856e0defd72056bbd204764b Mon Sep 17 00:00:00 2001 From: silverwind Date: Wed, 10 May 2023 08:58:49 +0200 Subject: [PATCH 14/14] fix lint --- templates/repo/issue/view_content/comments.tmpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index 75804de1cb611..ab499f346afdb 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -373,8 +373,8 @@ {{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 */}} + bubble. The condition depends on review type and for positive reviews whether + there is a comment element or not */}} {{avatar $.Context .Poster}}