You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

box.tmpl 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. {{if .DiffNotAvailable}}
  2. <div class="diff-detail-box diff-box sticky">
  3. <div>
  4. <div class="ui right">
  5. {{if .PageIsPullFiles}}
  6. {{template "repo/diff/whitespace_dropdown" .}}
  7. {{else}}
  8. <a class="ui tiny basic toggle button" href="?style={{if .IsSplitStyle}}unified{{else}}split{{end}}">{{ if .IsSplitStyle }}{{.i18n.Tr "repo.diff.show_unified_view"}}{{else}}{{.i18n.Tr "repo.diff.show_split_view"}}{{end}}</a>
  9. {{end}}
  10. {{template "repo/diff/options_dropdown" .}}
  11. {{if and .PageIsPullFiles $.SignedUserID (not .IsArchived)}}
  12. {{template "repo/diff/new_review" .}}
  13. {{end}}
  14. </div>
  15. </div>
  16. </div>
  17. <h4>{{.i18n.Tr "repo.diff.data_not_available"}}</h4>
  18. {{else}}
  19. <div>
  20. <div class="diff-detail-box diff-box sticky">
  21. <i class="fa fa-retweet"></i>
  22. {{.i18n.Tr "repo.diff.stats_desc" .Diff.NumFiles .Diff.TotalAddition .Diff.TotalDeletion | Str2html}}
  23. <div class="ui right">
  24. {{if .PageIsPullFiles}}
  25. {{template "repo/diff/whitespace_dropdown" .}}
  26. {{else}}
  27. <a class="ui tiny basic toggle button" href="?style={{if .IsSplitStyle}}unified{{else}}split{{end}}">{{ if .IsSplitStyle }}{{.i18n.Tr "repo.diff.show_unified_view"}}{{else}}{{.i18n.Tr "repo.diff.show_split_view"}}{{end}}</a>
  28. {{end}}
  29. {{template "repo/diff/options_dropdown" .}}
  30. {{if and .PageIsPullFiles $.SignedUserID (not .IsArchived)}}
  31. {{template "repo/diff/new_review" .}}
  32. {{end}}
  33. </div>
  34. </div>
  35. <ol class="diff-detail-box diff-stats detail-files hide" id="diff-files">
  36. {{range .Diff.Files}}
  37. <li>
  38. <div class="diff-counter count pull-right">
  39. {{if not .IsBin}}
  40. <span class="add" data-line="{{.Addition}}">+{{.Addition}}</span>
  41. <span class="bar">
  42. <div class="pull-left add"></div>
  43. <div class="pull-left del"></div>
  44. </span>
  45. <span class="del" data-line="{{.Deletion}}">-{{.Deletion}}</span>
  46. {{else}}
  47. <span>{{$.i18n.Tr "repo.diff.bin"}}</span>
  48. {{end}}
  49. </div>
  50. <!-- todo finish all file status, now modify, add, delete and rename -->
  51. <span class="status {{DiffTypeToStr .GetType}} poping up" data-content="{{DiffTypeToStr .GetType}}" data-variation="inverted tiny" data-position="right center">&nbsp;</span>
  52. <a class="file" href="#diff-{{.Index}}">{{.Name}}</a>
  53. </li>
  54. {{end}}
  55. </ol>
  56. {{range $i, $file := .Diff.Files}}
  57. {{if $file.IsIncomplete}}
  58. <div class="diff-file-box diff-box file-content">
  59. <h4 class="ui top attached normal header rounded">
  60. <div class="diff-counter count ui left">
  61. {{if not $file.IsRenamed}}
  62. <span class="add" data-line="{{.Addition}}">+ {{.Addition}}</span>
  63. <span class="bar">
  64. <div class="pull-left add"></div>
  65. <div class="pull-left del"></div>
  66. </span>
  67. <span class="del" data-line="{{.Deletion}}">- {{.Deletion}}</span>
  68. {{end}}
  69. </div>
  70. <span class="file">{{$file.Name}}</span>
  71. <div>{{$.i18n.Tr "repo.diff.file_suppressed"}}</div>
  72. {{if and (not $file.IsSubmodule) (not $.PageIsWiki)}}
  73. {{if $file.IsDeleted}}
  74. <a class="ui basic grey tiny button" rel="nofollow" href="{{EscapePound $.BeforeSourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
  75. {{else}}
  76. <a class="ui basic grey tiny button" rel="nofollow" href="{{EscapePound $.SourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
  77. {{end}}
  78. {{end}}
  79. </h4>
  80. </div>
  81. {{else}}
  82. <div class="diff-file-box diff-box file-content {{TabSizeClass $.Editorconfig $file.Name}}" id="diff-{{.Index}}">
  83. <h4 class="diff-file-header ui top attached normal header">
  84. {{$isImage := false}}
  85. {{if $file.IsDeleted}}
  86. {{$isImage = (call $.IsImageFileInBase $file.Name)}}
  87. {{else}}
  88. {{$isImage = (call $.IsImageFileInHead $file.Name)}}
  89. {{end}}
  90. {{if or (not $file.IsBin) $isImage}}
  91. <i class="ui fold-code grey fa fa-chevron-down"></i>
  92. {{end}}
  93. <div class="diff-counter count">
  94. {{if $file.IsBin}}
  95. {{$.i18n.Tr "repo.diff.bin"}}
  96. {{else if not $file.IsRenamed}}
  97. <span class="add" data-line="{{.Addition}}">+ {{.Addition}}</span>
  98. <span class="bar">
  99. <div class="pull-left add"></div>
  100. <div class="pull-left del"></div>
  101. </span>
  102. <span class="del" data-line="{{.Deletion}}">- {{.Deletion}}</span>
  103. {{end}}
  104. </div>
  105. <span class="file">{{if $file.IsRenamed}}{{$file.OldName}} &rarr; {{end}}{{$file.Name}}{{if .IsLFSFile}} ({{$.i18n.Tr "repo.stored_lfs"}}){{end}}</span>
  106. {{if and (not $file.IsSubmodule) (not $.PageIsWiki)}}
  107. {{if $file.IsDeleted}}
  108. <a class="ui basic grey tiny button" rel="nofollow" href="{{EscapePound $.BeforeSourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
  109. {{else}}
  110. <a class="ui basic grey tiny button" rel="nofollow" href="{{EscapePound $.SourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
  111. {{end}}
  112. {{end}}
  113. </h4>
  114. <div class="diff-file-body ui attached unstackable table segment">
  115. {{if ne $file.Type 4}}
  116. <div class="file-body file-code code-view has-context-menu code-diff {{if $.IsSplitStyle}}code-diff-split{{else}}code-diff-unified{{end}}">
  117. <table class="chroma">
  118. <tbody>
  119. {{if $isImage}}
  120. {{template "repo/diff/image_diff" dict "file" . "root" $}}
  121. {{else}}
  122. {{if $.IsSplitStyle}}
  123. {{range $j, $section := $file.Sections}}
  124. {{range $k, $line := $section.Lines}}
  125. <tr class="{{DiffLineTypeToStr .GetType}}-code nl-{{$k}} ol-{{$k}}">
  126. {{if eq .GetType 4}}
  127. <td class="lines-num lines-num-old">
  128. {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5) }}
  129. <i class="ui blob-excerpt fa fa-caret-down" data-url="{{$.RepoLink}}/blob_excerpt/{{$.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=split&direction=down" data-anchor="diff-{{Sha1 $file.Name}}K{{$line.SectionInfo.RightIdx}}"></i>
  130. {{end}}
  131. {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4) }}
  132. <i class="ui blob-excerpt fa fa-caret-up" data-url="{{$.RepoLink}}/blob_excerpt/{{$.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=split&direction=up" data-anchor="diff-{{Sha1 $file.Name}}K{{$line.SectionInfo.RightIdx}}"></i>
  133. {{end}}
  134. {{if eq $line.GetExpandDirection 2}}
  135. <span class="ui blob-excerpt" data-url="{{$.RepoLink}}/blob_excerpt/{{$.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=split&direction=" data-anchor="diff-{{Sha1 $file.Name}}K{{$line.SectionInfo.RightIdx}}">{{svg "octicon-fold" 16}}</span>
  136. {{end}}
  137. </td>
  138. <td colspan="5" class="lines-code lines-code-old "><span class="mono wrap">{{$section.GetComputedInlineDiffFor $line}}</span></td>
  139. {{else}}
  140. <td class="lines-num lines-num-old" data-line-num="{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}"><span rel="{{if $line.LeftIdx}}diff-{{Sha1 $file.Name}}L{{$line.LeftIdx}}{{end}}"></span></td>
  141. <td class="lines-type-marker lines-type-marker-old">{{if $line.LeftIdx}}<span class="mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span>{{end}}</td>
  142. <td class="lines-code lines-code-old halfwidth">{{if and $.SignedUserID $line.CanComment $.PageIsPullFiles (not (eq .GetType 2))}}<a class="ui green button add-code-comment add-code-comment-left" data-path="{{$file.Name}}" data-side="left" data-idx="{{$line.LeftIdx}}">+</a>{{end}}<span class="mono wrap">{{if $line.LeftIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}</span></td>
  143. <td class="lines-num lines-num-new" data-line-num="{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}"><span rel="{{if $line.RightIdx}}diff-{{Sha1 $file.Name}}R{{$line.RightIdx}}{{end}}"></span></td>
  144. <td class="lines-type-marker lines-type-marker-new">{{if $line.RightIdx}}<span class="mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span>{{end}}</td>
  145. <td class="lines-code lines-code-new halfwidth">{{if and $.SignedUserID $line.CanComment $.PageIsPullFiles (not (eq .GetType 3))}}<a class="ui green button add-code-comment add-code-comment-right" data-path="{{$file.Name}}" data-side="right" data-idx="{{$line.RightIdx}}">+</a>{{end}}<span class="mono wrap">{{if $line.RightIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}</span></td>
  146. {{end}}
  147. </tr>
  148. {{if gt (len $line.Comments) 0}}
  149. {{$resolved := (index $line.Comments 0).IsResolved}}
  150. {{$resolveDoer := (index $line.Comments 0).ResolveDoer}}
  151. {{$isNotPending := (not (eq (index $line.Comments 0).Review.Type 0))}}
  152. <tr class="add-code-comment">
  153. <td class="lines-num"></td>
  154. <td class="lines-type-marker"></td>
  155. <td class="add-comment-left">
  156. {{if and $resolved (eq $line.GetCommentSide "previous")}}
  157. <div class="ui top attached header">
  158. <span class="ui grey text left"><b>{{$resolveDoer.Name}}</b> {{$.i18n.Tr "repo.issues.review.resolved_by"}}</span>
  159. <button id="show-outdated-{{(index $line.Comments 0).ID}}" data-comment="{{(index $line.Comments 0).ID}}" class="ui compact right labeled button show-outdated">
  160. {{svg "octicon-unfold" 16}}
  161. {{$.i18n.Tr "repo.issues.review.show_resolved"}}
  162. </button>
  163. <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">
  164. {{svg "octicon-fold" 16}}
  165. {{$.i18n.Tr "repo.issues.review.hide_resolved"}}
  166. </button>
  167. </div>
  168. {{end}}
  169. {{if eq $line.GetCommentSide "previous"}}
  170. <div id="code-comments-{{(index $line.Comments 0).ID}}" class="field comment-code-cloud {{if $resolved}}hide{{end}}">
  171. <div class="comment-list">
  172. <ui class="ui comments">
  173. {{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}}
  174. </ui>
  175. </div>
  176. {{template "repo/diff/comment_form_datahandler" dict "reply" (index $line.Comments 0).ReviewID "hidden" true "root" $ "comment" (index $line.Comments 0)}}
  177. {{if and $.CanMarkConversation $isNotPending}}
  178. <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" >
  179. {{if $resolved}}
  180. {{$.i18n.Tr "repo.issues.review.un_resolve_conversation"}}
  181. {{else}}
  182. {{$.i18n.Tr "repo.issues.review.resolve_conversation"}}
  183. {{end}}
  184. </button>
  185. {{end}}
  186. </div>
  187. {{end}}
  188. </td>
  189. <td class="lines-num"></td>
  190. <td class="lines-type-marker"></td>
  191. <td class="add-comment-right">
  192. {{if and $resolved (eq $line.GetCommentSide "proposed")}}
  193. <div class="ui top attached header">
  194. <span class="ui grey text left"><b>{{$resolveDoer.Name}}</b> {{$.i18n.Tr "repo.issues.review.resolved_by"}}</span>
  195. <button id="show-outdated-{{(index $line.Comments 0).ID}}" data-comment="{{(index $line.Comments 0).ID}}" class="ui compact right labeled button show-outdated">
  196. {{svg "octicon-unfold" 16}}
  197. {{$.i18n.Tr "repo.issues.review.show_resolved"}}
  198. </button>
  199. <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">
  200. {{svg "octicon-fold" 16}}
  201. {{$.i18n.Tr "repo.issues.review.hide_resolved"}}
  202. </button>
  203. </div>
  204. {{end}}
  205. {{if eq $line.GetCommentSide "proposed"}}
  206. <div id="code-comments-{{(index $line.Comments 0).ID}}" class="field comment-code-cloud {{if $resolved}}hide{{end}}">
  207. <div class="comment-list">
  208. <ui class="ui comments">
  209. {{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}}
  210. </ui>
  211. </div>
  212. {{template "repo/diff/comment_form_datahandler" dict "reply" (index $line.Comments 0).ReviewID "hidden" true "root" $ "comment" (index $line.Comments 0)}}
  213. {{if and $.CanMarkConversation $isNotPending}}
  214. <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" >
  215. {{if $resolved}}
  216. {{$.i18n.Tr "repo.issues.review.un_resolve_conversation"}}
  217. {{else}}
  218. {{$.i18n.Tr "repo.issues.review.resolve_conversation"}}
  219. {{end}}
  220. </button>
  221. {{end}}
  222. </div>
  223. {{end}}
  224. </td>
  225. </tr>
  226. {{end}}
  227. {{end}}
  228. {{end}}
  229. {{else}}
  230. {{template "repo/diff/section_unified" dict "file" . "root" $}}
  231. {{end}}
  232. {{end}}
  233. </tbody>
  234. </table>
  235. </div>
  236. {{end}}
  237. </div>
  238. </div>
  239. {{end}}
  240. <br>
  241. {{end}}
  242. {{if .Diff.IsIncomplete}}
  243. <div class="diff-file-box diff-box file-content">
  244. <h4 class="ui top attached normal header">
  245. {{$.i18n.Tr "repo.diff.too_many_files"}}
  246. </h4>
  247. </div>
  248. {{end}}
  249. {{if not $.Repository.IsArchived}}
  250. <div id="pull_review_add_comment" class="hide">
  251. {{template "repo/diff/new_comment" dict "root" .}}
  252. </div>
  253. <div class="hide" id="edit-content-form">
  254. <div class="ui comment form">
  255. <div class="ui top attached tabular menu">
  256. <a class="active write item">{{$.i18n.Tr "write"}}</a>
  257. <a class="preview item" data-url="{{$.Repository.APIURL}}/markdown" data-context="{{$.RepoLink}}">{{$.i18n.Tr "preview"}}</a>
  258. </div>
  259. <div class="ui bottom attached active write tab segment">
  260. <textarea class="review-textarea" tabindex="1" name="content"></textarea>
  261. </div>
  262. <div class="ui bottom attached tab preview segment markdown">
  263. {{$.i18n.Tr "loading"}}
  264. </div>
  265. <div class="text right edit buttons">
  266. <div class="ui basic blue cancel button" tabindex="3">{{.i18n.Tr "repo.issues.cancel"}}</div>
  267. <div class="ui green save button" tabindex="2">{{.i18n.Tr "repo.issues.save"}}</div>
  268. </div>
  269. </div>
  270. </div>
  271. {{end}}
  272. {{if .IsSplitStyle}}
  273. <script>
  274. document.addEventListener('DOMContentLoaded', function() {
  275. $('tr.add-code').each(function() {
  276. var prev = $(this).prev();
  277. if(prev.is('.del-code') && prev.children().eq(5).text().trim() === '') {
  278. while(prev.prev().is('.del-code') && prev.prev().children().eq(5).text().trim() === '') {
  279. prev = prev.prev();
  280. }
  281. prev.children().eq(3).attr("data-line-num", $(this).children().eq(3).attr("data-line-num"));
  282. prev.children().eq(3).html($(this).children().eq(3).html());
  283. prev.children().eq(4).html($(this).children().eq(4).html());
  284. prev.children().eq(5).html($(this).children().eq(5).html());
  285. prev.children().eq(0).addClass('del-code');
  286. prev.children().eq(1).addClass('del-code');
  287. prev.children().eq(2).addClass('del-code');
  288. prev.children().eq(3).addClass('add-code');
  289. prev.children().eq(4).addClass('add-code');
  290. prev.children().eq(5).addClass('add-code');
  291. $(this).remove();
  292. }
  293. });
  294. });
  295. </script>
  296. {{end}}
  297. </div>
  298. {{end}}