aboutsummaryrefslogtreecommitdiffstats
path: root/templates
diff options
context:
space:
mode:
author赵智超 <1012112796@qq.com>2020-04-18 21:50:25 +0800
committerGitHub <noreply@github.com>2020-04-18 10:50:25 -0300
commit1b86f174ce99b579df35c32e800551b1fd1df807 (patch)
treee057206a13cea7a0e2eb0219bb66d8d83a8781c9 /templates
parent38d5f88a8183147cc5ecc6ece58fc28836a4af8b (diff)
downloadgitea-1b86f174ce99b579df35c32e800551b1fd1df807.tar.gz
gitea-1b86f174ce99b579df35c32e800551b1fd1df807.zip
Add a way to mark Conversation (code comment) resolved (#11037)
* Add a way to mark Conversation (code comment) resolved mark Conversation is a way to mark a Conversation is stale or be solved. when it's marked as stale, will be hided like stale. all Pull Request writer , Offical Reviewers and poster can add or remove Conversation resolved mark. Signed-off-by: a1012112796 <1012112796@qq.com> * fix lint * Apply suggestions from code review * Add ResolveDoer * fix ui Co-Authored-By: Lauris BH <lauris@nix.lv> Co-Authored-By: 6543 <6543@obermui.de> * change IsResolved to an function Add permission check in UpdateResolveConversation * Apply suggestions from code review * change return error for permisson check * add default message for deleted user * get issue message from comment * add migration for ``ResolveDoerID`` column another change: * block mark pending review as resolved because it's not necessary Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com> * change button color * resolve button size * fix code style * remove unusefull code Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com> Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Diffstat (limited to 'templates')
-rw-r--r--templates/repo/diff/box.tmpl51
-rw-r--r--templates/repo/diff/section_unified.tmpl27
-rw-r--r--templates/repo/issue/view_content/comments.tmpl38
3 files changed, 107 insertions, 9 deletions
diff --git a/templates/repo/diff/box.tmpl b/templates/repo/diff/box.tmpl
index d113f9ecee..a789350525 100644
--- a/templates/repo/diff/box.tmpl
+++ b/templates/repo/diff/box.tmpl
@@ -147,32 +147,79 @@
{{end}}
</tr>
{{if gt (len $line.Comments) 0}}
+ {{$resolved := (index $line.Comments 0).IsResolved}}
+ {{$resolveDoer := (index $line.Comments 0).ResolveDoer}}
+ {{$isNotPending := (not (eq (index $line.Comments 0).Review.Type 0))}}
<tr class="add-code-comment">
<td class="lines-num"></td>
<td class="lines-type-marker"></td>
<td class="add-comment-left">
+ {{if and $resolved (eq $line.GetCommentSide "previous")}}
+ <div class="ui top attached header">
+ <span class="ui grey text left"><b>{{$resolveDoer.Name}}</b> {{$.i18n.Tr "repo.issues.review.resolved_by"}}</span>
+ <button id="show-outdated-{{(index $line.Comments 0).ID}}" data-comment="{{(index $line.Comments 0).ID}}" class="ui compact right labeled button show-outdated">
+ {{svg "octicon-unfold" 16}}
+ {{$.i18n.Tr "repo.issues.review.show_resolved"}}
+ </button>
+ <button id="hide-outdated-{{(index $line.Comments 0).ID}}" data-comment="{{(index $line.Comments 0).ID}}" class="hide ui compact right labeled button hide-outdated">
+ {{svg "octicon-fold" 16}}
+ {{$.i18n.Tr "repo.issues.review.hide_resolved"}}
+ </button>
+ </div>
+ {{end}}
{{if eq $line.GetCommentSide "previous"}}
- <div class="field comment-code-cloud">
+ <div id="code-comments-{{(index $line.Comments 0).ID}}" class="field comment-code-cloud {{if $resolved}}hide{{end}}">
<div class="comment-list">
<ui class="ui comments">
{{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}}
</ui>
</div>
{{template "repo/diff/comment_form_datahandler" dict "reply" (index $line.Comments 0).ReviewID "hidden" true "root" $ "comment" (index $line.Comments 0)}}
+ {{if and $.CanMarkConversation $isNotPending}}
+ <button class="ui icon tiny button resolve-conversation" data-action="{{if not $resolved}}Resolve{{else}}UnResolve{{end}}" data-comment-id="{{(index $line.Comments 0).ID}}" data-update-url="{{$.RepoLink}}/issues/resolve_conversation" >
+ {{if $resolved}}
+ {{$.i18n.Tr "repo.issues.review.un_resolve_conversation"}}
+ {{else}}
+ {{$.i18n.Tr "repo.issues.review.resolve_conversation"}}
+ {{end}}
+ </button>
+ {{end}}
</div>
{{end}}
</td>
<td class="lines-num"></td>
<td class="lines-type-marker"></td>
<td class="add-comment-right">
+ {{if and $resolved (eq $line.GetCommentSide "proposed")}}
+ <div class="ui top attached header">
+ <span class="ui grey text left"><b>{{$resolveDoer.Name}}</b> {{$.i18n.Tr "repo.issues.review.resolved_by"}}</span>
+ <button id="show-outdated-{{(index $line.Comments 0).ID}}" data-comment="{{(index $line.Comments 0).ID}}" class="ui compact right labeled button show-outdated">
+ {{svg "octicon-unfold" 16}}
+ {{$.i18n.Tr "repo.issues.review.show_resolved"}}
+ </button>
+ <button id="hide-outdated-{{(index $line.Comments 0).ID}}" data-comment="{{(index $line.Comments 0).ID}}" class="hide ui compact right labeled button hide-outdated">
+ {{svg "octicon-fold" 16}}
+ {{$.i18n.Tr "repo.issues.review.hide_resolved"}}
+ </button>
+ </div>
+ {{end}}
{{if eq $line.GetCommentSide "proposed"}}
- <div class="field comment-code-cloud">
+ <div id="code-comments-{{(index $line.Comments 0).ID}}" class="field comment-code-cloud {{if $resolved}}hide{{end}}">
<div class="comment-list">
<ui class="ui comments">
{{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}}
</ui>
</div>
{{template "repo/diff/comment_form_datahandler" dict "reply" (index $line.Comments 0).ReviewID "hidden" true "root" $ "comment" (index $line.Comments 0)}}
+ {{if and $.CanMarkConversation $isNotPending}}
+ <button class="ui icon tiny button resolve-conversation" data-action="{{if not $resolved}}Resolve{{else}}UnResolve{{end}}" data-comment-id="{{(index $line.Comments 0).ID}}" data-update-url="{{$.RepoLink}}/issues/resolve_conversation" >
+ {{if $resolved}}
+ {{$.i18n.Tr "repo.issues.review.un_resolve_conversation"}}
+ {{else}}
+ {{$.i18n.Tr "repo.issues.review.resolve_conversation"}}
+ {{end}}
+ </button>
+ {{end}}
</div>
{{end}}
</td>
diff --git a/templates/repo/diff/section_unified.tmpl b/templates/repo/diff/section_unified.tmpl
index c25d3ef079..4c23c159a2 100644
--- a/templates/repo/diff/section_unified.tmpl
+++ b/templates/repo/diff/section_unified.tmpl
@@ -23,17 +23,42 @@
<td class="lines-code{{if (not $line.RightIdx)}} lines-code-old{{end}}">{{if and $.root.SignedUserID $line.CanComment $.root.PageIsPullFiles}}<a class="ui green button add-code-comment add-code-comment-{{if $line.RightIdx}}right{{else}}left{{end}}" data-path="{{$file.Name}}" data-side="{{if $line.RightIdx}}right{{else}}left{{end}}" data-idx="{{if $line.RightIdx}}{{$line.RightIdx}}{{else}}{{$line.LeftIdx}}{{end}}">+</a>{{end}}<span class="mono wrap{{if $highlightClass}} language-{{$highlightClass}}{{else}} nohighlight{{end}}">{{$section.GetComputedInlineDiffFor $line}}</span></td>
</tr>
{{if gt (len $line.Comments) 0}}
+ {{$resolved := (index $line.Comments 0).IsResolved}}
+ {{$resolveDoer := (index $line.Comments 0).ResolveDoer}}
+ {{$isNotPending := (not (eq (index $line.Comments 0).Review.Type 0))}}
<tr>
<td colspan="2" class="lines-num"></td>
<td class="lines-type-marker"></td>
<td class="add-comment-left add-comment-right">
- <div class="field comment-code-cloud">
+ {{if $resolved}}
+ <div class = "ui attached header">
+ <span class="ui grey text left"><b>{{$resolveDoer.Name}}</b> {{$.root.i18n.Tr "repo.issues.review.resolved_by"}}</span>
+ <button id="show-outdated-{{(index $line.Comments 0).ID}}" data-comment="{{(index $line.Comments 0).ID}}" class="ui compact right labeled button show-outdated">
+ {{svg "octicon-unfold" 16}}
+ {{$.root.i18n.Tr "repo.issues.review.show_resolved"}}
+ </button>
+ <button id="hide-outdated-{{(index $line.Comments 0).ID}}" data-comment="{{(index $line.Comments 0).ID}}" class="hide ui compact right labeled button hide-outdated">
+ {{svg "octicon-fold" 16}}
+ {{$.root.i18n.Tr "repo.issues.review.hide_resolved"}}
+ </button>
+ </div>
+ {{end}}
+ <div id="code-comments-{{(index $line.Comments 0).ID}}" class="field comment-code-cloud {{if $resolved}}hide{{end}}">
<div class="comment-list">
<ui class="ui comments">
{{ template "repo/diff/comments" dict "root" $.root "comments" $line.Comments}}
</ui>
</div>
{{template "repo/diff/comment_form_datahandler" dict "hidden" true "reply" (index $line.Comments 0).ReviewID "root" $.root "comment" (index $line.Comments 0)}}
+ {{if and $.root.CanMarkConversation $isNotPending}}
+ <button class="ui icon tiny button resolve-conversation" data-action="{{if not $resolved}}Resolve{{else}}UnResolve{{end}}" data-comment-id="{{(index $line.Comments 0).ID}}" data-update-url="{{$.root.RepoLink}}/issues/resolve_conversation" >
+ {{if $resolved}}
+ {{$.root.i18n.Tr "repo.issues.review.un_resolve_conversation"}}
+ {{else}}
+ {{$.root.i18n.Tr "repo.issues.review.resolve_conversation"}}
+ {{end}}
+ </button>
+ {{end}}
</div>
</td>
</tr>
diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl
index da1483ec37..27baaed3f2 100644
--- a/templates/repo/issue/view_content/comments.tmpl
+++ b/templates/repo/issue/view_content/comments.tmpl
@@ -381,6 +381,7 @@
</div>
</div>
{{end}}
+
{{if .Review.CodeComments}}
<div class="timeline-item event">
{{ range $filename, $lines := .Review.CodeComments}}
@@ -388,14 +389,25 @@
<div class="ui segments">
<div class="ui segment">
{{$invalid := (index $comms 0).Invalidated}}
- {{if $invalid}}
+ {{$resolved := (index $comms 0).IsResolved}}
+ {{$resolveDoer := (index $comms 0).ResolveDoer}}
+ {{$isNotPending := (not (eq (index $comms 0).Review.Type 0))}}
+ {{if or $invalid $resolved}}
<button id="show-outdated-{{(index $comms 0).ID}}" data-comment="{{(index $comms 0).ID}}" class="ui compact right labeled button show-outdated">
- {{svg "octicon-fold" 16}}
- {{$.i18n.Tr "repo.issues.review.show_outdated"}}
+ {{svg "octicon-unfold" 16}}
+ {{if $invalid }}
+ {{$.i18n.Tr "repo.issues.review.show_outdated"}}
+ {{else}}
+ {{$.i18n.Tr "repo.issues.review.show_resolved"}}
+ {{end}}
</button>
<button id="hide-outdated-{{(index $comms 0).ID}}" data-comment="{{(index $comms 0).ID}}" class="hide ui compact right labeled button hide-outdated">
{{svg "octicon-fold" 16}}
- {{$.i18n.Tr "repo.issues.review.hide_outdated"}}
+ {{if $invalid}}
+ {{$.i18n.Tr "repo.issues.review.hide_outdated"}}
+ {{else}}
+ {{$.i18n.Tr "repo.issues.review.hide_resolved"}}
+ {{end}}
</button>
{{end}}
<a href="{{(index $comms 0).CodeCommentURL}}" class="file-comment">{{$filename}}</a>
@@ -403,7 +415,7 @@
{{$diff := (CommentMustAsDiff (index $comms 0))}}
{{if $diff}}
{{$file := (index $diff.Files 0)}}
- <div id="code-preview-{{(index $comms 0).ID}}" class="ui table segment{{if $invalid}} hide{{end}}">
+ <div id="code-preview-{{(index $comms 0).ID}}" class="ui table segment{{if or $invalid $resolved}} hide{{end}}">
<div class="diff-file-box diff-box file-content {{TabSizeClass $.Editorconfig $file.Name}}">
<div class="file-body file-code code-view code-diff code-diff-unified">
<table>
@@ -415,7 +427,7 @@
</div>
</div>
{{end}}
- <div id="code-comments-{{(index $comms 0).ID}}" class="ui segment{{if $invalid}} hide{{end}}">
+ <div id="code-comments-{{(index $comms 0).ID}}" class="ui segment{{if or $invalid $resolved}} hide{{end}}">
<div class="ui comments">
{{range $comms}}
{{ $createdSubStr:= TimeSinceUnix .CreatedUnix $.Lang }}
@@ -445,6 +457,20 @@
{{end}}
</div>
{{template "repo/diff/comment_form_datahandler" dict "hidden" true "reply" (index $comms 0).ReviewID "root" $ "comment" (index $comms 0)}}
+
+ {{if and $.CanMarkConversation $isNotPending}}
+ <button class="ui tiny button resolve-conversation" data-action="{{if not $resolved}}Resolve{{else}}UnResolve{{end}}" data-comment-id="{{(index $comms 0).ID}}" data-update-url="{{$.RepoLink}}/issues/resolve_conversation" >
+ {{if $resolved}}
+ {{$.i18n.Tr "repo.issues.review.un_resolve_conversation"}}
+ {{else}}
+ {{$.i18n.Tr "repo.issues.review.resolve_conversation"}}
+ {{end}}
+ </button>
+ {{end}}
+
+ {{if $resolved}}
+ <span class="ui grey text"><b>{{$resolveDoer.Name}}</b> {{$.i18n.Tr "repo.issues.review.resolved_by"}}</span>
+ {{end}}
</div>
</div>
{{end}}