From ca63a9d3f1120d8c76eb83ff1fd07e0992a683a8 Mon Sep 17 00:00:00 2001 From: Lauris BH Date: Sun, 17 Jan 2021 19:29:10 +0200 Subject: [PATCH] Add edit, delete and reaction support to code review comments on issue page (#14339) --- routers/repo/issue.go | 19 ++++++ templates/repo/diff/comments.tmpl | 2 +- .../repo/issue/view_content/comments.tmpl | 63 ++++++++++++++----- .../repo/issue/view_content/context_menu.tmpl | 6 +- web_src/less/_repository.less | 31 +++++++++ 5 files changed, 101 insertions(+), 20 deletions(-) diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 7b4044ac7..6a532dc12 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -1377,7 +1377,26 @@ func ViewIssue(ctx *context.Context) { ctx.ServerError("Review.LoadCodeComments", err) return } + for _, codeComments := range comment.Review.CodeComments { + for _, lineComments := range codeComments { + for _, c := range lineComments { + // Check tag. + tag, ok = marked[c.PosterID] + if ok { + c.ShowTag = tag + continue + } + c.ShowTag, err = commentTag(repo, c.Poster, issue) + if err != nil { + ctx.ServerError("commentTag", err) + return + } + marked[c.PosterID] = c.ShowTag + participants = addParticipant(c.Poster, participants) + } + } + } if err = comment.LoadResolveDoer(); err != nil { ctx.ServerError("LoadResolveDoer", err) return diff --git a/templates/repo/diff/comments.tmpl b/templates/repo/diff/comments.tmpl index 59bc89b79..36e725936 100644 --- a/templates/repo/diff/comments.tmpl +++ b/templates/repo/diff/comments.tmpl @@ -47,7 +47,7 @@ {{end}} {{end}} {{template "repo/issue/view_content/add_reaction" Dict "ctx" $.root "ActionURL" (Printf "%s/comments/%d/reactions" $.root.RepoLink .ID) }} - {{template "repo/issue/view_content/context_menu" Dict "ctx" $.root "item" . "delete" true "diff" true "IsCommentPoster" (and $.root.IsSigned (eq $.root.SignedUserID .PosterID))}} + {{template "repo/issue/view_content/context_menu" Dict "ctx" $.root "item" . "delete" true "issue" false "diff" true "IsCommentPoster" (and $.root.IsSigned (eq $.root.SignedUserID .PosterID))}}
diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index 8f5426b83..abf5792a9 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -58,7 +58,7 @@
{{end}} {{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID)}} - {{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" . "delete" true "diff" false "IsCommentPoster" (and $.IsSigned (eq $.SignedUserID .PosterID))}} + {{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" . "delete" true "issue" true "diff" false "IsCommentPoster" (and $.IsSigned (eq $.SignedUserID .PosterID))}} {{end}} @@ -494,25 +494,49 @@ {{end}} -
+
{{range $comms}} {{ $createdSubStr:= TimeSinceUnix .CreatedUnix $.Lang }}
- {{if not .OriginalAuthor }} - - {{avatar .Poster}} - - {{end}}
- - {{if .OriginalAuthor }} - {{ .OriginalAuthor }} {{if $.Repository.OriginalURL}}({{$.i18n.Tr "repo.migrated_from" $.Repository.OriginalURL $.Repository.GetOriginalURLHostname | Safe }}){{end}} - {{else}} - {{.Poster.GetDisplayName}} - {{end}} - {{$.i18n.Tr "repo.issues.commented_at" .HashTag $createdSubStr | Safe}} - +
+
+ {{if not .OriginalAuthor }} + + {{avatar .Poster}} + + {{end}} + + {{if .OriginalAuthor }} + {{ .OriginalAuthor }} {{if $.Repository.OriginalURL}}({{$.i18n.Tr "repo.migrated_from" $.Repository.OriginalURL $.Repository.GetOriginalURLHostname | Safe }}){{end}} + {{else}} + {{.Poster.GetDisplayName}} + {{end}} + {{$.i18n.Tr "repo.issues.commented_at" .HashTag $createdSubStr | Safe}} + +
+
+ {{if not $.Repository.IsArchived}} + {{if or (and (eq .PosterID $.Issue.PosterID) (eq $.Issue.OriginalAuthorID 0)) (eq $.Issue.OriginalAuthorID .OriginalAuthorID) }} +
+ {{$.i18n.Tr "repo.issues.poster"}} +
+ {{end}} + {{if gt .ShowTag 0}} +
+ {{if eq .ShowTag 2}} + {{$.i18n.Tr "repo.issues.collaborator"}} + {{else if eq .ShowTag 3}} + {{$.i18n.Tr "repo.issues.owner"}} + {{end}} +
+ {{end}} + {{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID)}} + {{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" . "delete" true "issue" true "diff" true "IsCommentPoster" (and $.IsSigned (eq $.SignedUserID .PosterID))}} + {{end}} +
+
{{if .RenderedContent}} @@ -521,8 +545,15 @@ {{$.i18n.Tr "repo.issues.no_content"}} {{end}}
-
{{.Content}}
+
{{.Content}}
+
+ {{$reactions := .Reactions.GroupByType}} + {{if $reactions}} +
+ {{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) "Reactions" $reactions}} +
+ {{end}}
{{end}} diff --git a/templates/repo/issue/view_content/context_menu.tmpl b/templates/repo/issue/view_content/context_menu.tmpl index 744821cb3..0b8b84e9f 100644 --- a/templates/repo/issue/view_content/context_menu.tmpl +++ b/templates/repo/issue/view_content/context_menu.tmpl @@ -4,10 +4,10 @@ {{svg "octicon-kebab-horizontal"}}