]> source.dussan.org Git - gitea.git/commitdiff
Add edit, delete and reaction support to code review comments on issue page (#14339)
authorLauris BH <lauris@nix.lv>
Sun, 17 Jan 2021 17:29:10 +0000 (19:29 +0200)
committerGitHub <noreply@github.com>
Sun, 17 Jan 2021 17:29:10 +0000 (19:29 +0200)
routers/repo/issue.go
templates/repo/diff/comments.tmpl
templates/repo/issue/view_content/comments.tmpl
templates/repo/issue/view_content/context_menu.tmpl
web_src/less/_repository.less

index 7b4044ac7b81b9faaa7bb05b1b05ce5120d068b2..6a532dc125a92b802a7d44b3b50b3c1bb3eda8ba 100644 (file)
@@ -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
index 59bc89b79e8ef623b4e26fc933c60be881bb1cf1..36e7259360b433d1d07fc1823aaa662d298aa2d7 100644 (file)
@@ -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))}}
                        </div>
                </div>
                <div class="ui attached segment comment-body">
index 8f5426b83e86f47f7523b474095e323a8b51af96..abf5792a9ee1cf55d274957031ae72cfc64f002c 100644 (file)
@@ -58,7 +58,7 @@
                                                                </div>
                                                        {{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}}
                                        </div>
                                </div>
                                                                                </div>
                                                                        </div>
                                                                {{end}}
-                                                               <div id="code-comments-{{(index $comms 0).ID}}" class="ui segment{{if $resolved}} hide{{end}} py-3">
+                                                               <div id="code-comments-{{(index $comms 0).ID}}" class="comment-code-cloud ui segment{{if $resolved}} hide{{end}} py-3">
                                                                        <div class="ui comments mb-0">
                                                                                {{range $comms}}
                                                                                        {{ $createdSubStr:= TimeSinceUnix .CreatedUnix $.Lang }}
                                                                                        <div class="comment code-comment" id="{{.HashTag}}">
-                                                                                               {{if not .OriginalAuthor }}
-                                                                                                       <a class="avatar">
-                                                                                                               {{avatar .Poster}}
-                                                                                                       </a>
-                                                                                               {{end}}
                                                                                                <div class="content">
-                                                                                                       <span class="text grey">
-                                                                                                               {{if .OriginalAuthor }}
-                                                                                                                       <span class="text black"><i class="fa {{MigrationIcon $.Repository.GetOriginalURLHostname}}" aria-hidden="true"></i> {{ .OriginalAuthor }}</span><span class="text grey"> {{if $.Repository.OriginalURL}}</span><span class="text migrate">({{$.i18n.Tr "repo.migrated_from" $.Repository.OriginalURL $.Repository.GetOriginalURLHostname | Safe }}){{end}}</span>
-                                                                                                               {{else}}
-                                                                                                                       <a class="author"{{if gt .Poster.ID 0}} href="{{.Poster.HomeLink}}"{{end}}>{{.Poster.GetDisplayName}}</a>
-                                                                                                               {{end}}
-                                                                                                               {{$.i18n.Tr "repo.issues.commented_at" .HashTag $createdSubStr | Safe}}
-                                                                                                       </span>
+                                                                                                       <div class="header comment-header">
+                                                                                                               <div class="comment-header-left df ac">
+                                                                                                                       {{if not .OriginalAuthor }}
+                                                                                                                               <a class="avatar">
+                                                                                                                                       {{avatar .Poster}}
+                                                                                                                               </a>
+                                                                                                                       {{end}}
+                                                                                                                       <span class="text grey">
+                                                                                                                               {{if .OriginalAuthor }}
+                                                                                                                                       <span class="text black"><i class="fa {{MigrationIcon $.Repository.GetOriginalURLHostname}}" aria-hidden="true"></i> {{ .OriginalAuthor }}</span><span class="text grey"> {{if $.Repository.OriginalURL}}</span><span class="text migrate">({{$.i18n.Tr "repo.migrated_from" $.Repository.OriginalURL $.Repository.GetOriginalURLHostname | Safe }}){{end}}</span>
+                                                                                                                               {{else}}
+                                                                                                                                       <a class="author"{{if gt .Poster.ID 0}} href="{{.Poster.HomeLink}}"{{end}}>{{.Poster.GetDisplayName}}</a>
+                                                                                                                               {{end}}
+                                                                                                                               {{$.i18n.Tr "repo.issues.commented_at" .HashTag $createdSubStr | Safe}}
+                                                                                                                       </span>
+                                                                                                               </div>
+                                                                                                               <div class="comment-header-right actions df ac">
+                                                                                                                       {{if not $.Repository.IsArchived}}
+                                                                                                                               {{if or (and (eq .PosterID $.Issue.PosterID) (eq $.Issue.OriginalAuthorID 0)) (eq $.Issue.OriginalAuthorID .OriginalAuthorID) }}
+                                                                                                                                       <div class="ui basic label">
+                                                                                                                                               {{$.i18n.Tr "repo.issues.poster"}}
+                                                                                                                                       </div>
+                                                                                                                               {{end}}
+                                                                                                                               {{if gt .ShowTag 0}}
+                                                                                                                                       <div class="ui basic label">
+                                                                                                                                               {{if eq .ShowTag 2}}
+                                                                                                                                                       {{$.i18n.Tr "repo.issues.collaborator"}}
+                                                                                                                                               {{else if eq .ShowTag 3}}
+                                                                                                                                                       {{$.i18n.Tr "repo.issues.owner"}}
+                                                                                                                                               {{end}}
+                                                                                                                                       </div>
+                                                                                                                               {{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}}
+                                                                                                               </div>
+                                                                                                       </div>
                                                                                                        <div class="text comment-content">
                                                                                                                <div class="render-content markdown">
                                                                                                                {{if .RenderedContent}}
                                                                                                                        <span class="no-content">{{$.i18n.Tr "repo.issues.no_content"}}</span>
                                                                                                                {{end}}
                                                                                                                </div>
-                                                                                                               <div class="raw-content hide">{{.Content}}</div>
+                                                                                                               <div id="comment-{{.ID}}" class="raw-content hide">{{.Content}}</div>
+                                                                                                               <div class="edit-content-zone hide" data-write="issuecomment-{{.ID}}-write" data-preview="issuecomment-{{.ID}}-preview" data-update-url="{{$.RepoLink}}/comments/{{.ID}}" data-context="{{$.RepoLink}}" data-attachment-url="{{$.RepoLink}}/comments/{{.ID}}/attachments"></div>
                                                                                                        </div>
+                                                                                                       {{$reactions := .Reactions.GroupByType}}
+                                                                                                       {{if $reactions}}
+                                                                                                               <div class="ui attached segment reactions">
+                                                                                                                       {{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) "Reactions" $reactions}}
+                                                                                                               </div>
+                                                                                                       {{end}}
                                                                                                </div>
                                                                                        </div>
                                                                                {{end}}
index 744821cb3c4d6a1d9a38e0dfa2d35a8121f2cf41..0b8b84e9f1a9914021f839bc168a9b0ea98faf43 100644 (file)
@@ -4,10 +4,10 @@
                {{svg "octicon-kebab-horizontal"}}
        </a>
        <div class="menu">
-               {{if .diff}}
-                       <div class="item context clipboard" data-clipboard-text="{{Printf "%s%s/pulls/%d/files#%s" AppUrl .ctx.Repository.FullName .ctx.Issue.Index .item.HashTag}}">{{.ctx.i18n.Tr "repo.issues.context.copy_link"}}</div>
-               {{else}}
+               {{if .issue}}
                        <div class="item context clipboard" data-clipboard-text="{{Printf "%s%s/issues/%d#%s" AppUrl .ctx.Repository.FullName .ctx.Issue.Index .item.HashTag}}">{{.ctx.i18n.Tr "repo.issues.context.copy_link"}}</div>
+               {{else}}
+                       <div class="item context clipboard" data-clipboard-text="{{Printf "%s%s/pulls/%d/files#%s" AppUrl .ctx.Repository.FullName .ctx.Issue.Index .item.HashTag}}">{{.ctx.i18n.Tr "repo.issues.context.copy_link"}}</div>
                {{end}}
                <div class="item context quote-reply {{if .diff}}quote-reply-diff{{end}}" data-target="{{.item.ID}}">{{.ctx.i18n.Tr "repo.issues.context.quote_reply"}}</div>
                {{if or .ctx.Permission.IsAdmin .IsCommentPoster .ctx.HasIssuesOrPullsWritePermission}}
index 6c7de750753104ed4dcb8e772af822f539e8fc31..fa6ea4467b63f48da0fefe2ff8ef8f63f98d80a6 100644 (file)
         }
       }
 
+      .ui.comments {
+        max-width: 100%;
+      }
+
       .comment {
         > .content {
           > div:first-child {
           border: none !important;
         }
 
+        .comment-header {
+          background: transparent;
+          border-bottom: 0 !important;
+          padding: 0 !important;
+
+          &::after,
+          &::before {
+            display: none;
+          }
+        }
+
         .avatar.image {
           width: 28px;
           height: 28px;
         }
       }
 
+      .comment-code-cloud {
+        .segment.reactions {
+          border-top: none !important;
+
+          .ui.label {
+            border: 1px solid;
+            padding: 6px !important;
+            border-radius: var(--border-radius);
+          }
+        }
+
+        button.comment-form-reply {
+          margin-left: 0;
+        }
+      }
+
       .event {
         padding-left: 15px;