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.

258 lines
13KB

  1. {{if .DiffNotAvailable}}
  2. <div class="diff-detail-box diff-box ui 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 ui 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 not $file.IsSubmodule}}
  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 not $file.IsSubmodule}}
  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>
  118. <tbody>
  119. {{if $isImage}}
  120. {{template "repo/diff/image_diff" dict "file" . "root" $}}
  121. {{else}}
  122. {{if $.IsSplitStyle}}
  123. {{$highlightClass := $file.GetHighlightClass}}
  124. {{range $j, $section := $file.Sections}}
  125. {{range $k, $line := $section.Lines}}
  126. <tr class="{{DiffLineTypeToStr .GetType}}-code nl-{{$k}} ol-{{$k}}">
  127. {{if eq .GetType 4}}
  128. <td class="lines-num lines-num-old">
  129. {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5) }}
  130. <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>
  131. {{end}}
  132. {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4) }}
  133. <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>
  134. {{end}}
  135. {{if or (eq $line.GetExpandDirection 2)}}
  136. <i class="ui blob-excerpt octicon octicon-fold" data-url="{{$.RepoLink}}/blob_excerpt/{{$.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=split&direction=" data-anchor="diff-{{Sha1 $file.Name}}K{{$line.SectionInfo.RightIdx}}"></i>
  137. {{end}}
  138. </td>
  139. <td colspan="5" class="lines-code lines-code-old "><span class="mono wrap{{if $highlightClass}} language-{{$highlightClass}}{{else}} nohighlight{{end}}">{{$section.GetComputedInlineDiffFor $line}}</span></td>
  140. {{else}}
  141. <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>
  142. <td class="lines-type-marker lines-type-marker-old">{{if $line.LeftIdx}}<span class="mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span>{{end}}</td>
  143. <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 $highlightClass}} language-{{$highlightClass}}{{else}} nohighlight{{end}}">{{if $line.LeftIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}</span></td>
  144. <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>
  145. <td class="lines-type-marker lines-type-marker-new">{{if $line.RightIdx}}<span class="mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span>{{end}}</td>
  146. <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 $highlightClass}} language-{{$highlightClass}}{{else}} nohighlight{{end}}">{{if $line.RightIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}</span></td>
  147. {{end}}
  148. </tr>
  149. {{if gt (len $line.Comments) 0}}
  150. <tr class="add-code-comment">
  151. <td class="lines-num"></td>
  152. <td class="lines-type-marker"></td>
  153. <td class="add-comment-left">
  154. {{if eq $line.GetCommentSide "previous"}}
  155. <div class="field comment-code-cloud">
  156. <div class="comment-list">
  157. <ui class="ui comments">
  158. {{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}}
  159. </ui>
  160. </div>
  161. {{template "repo/diff/comment_form_datahandler" dict "reply" (index $line.Comments 0).ReviewID "hidden" true "root" $ "comment" (index $line.Comments 0)}}
  162. </div>
  163. {{end}}
  164. </td>
  165. <td class="lines-num"></td>
  166. <td class="lines-type-marker"></td>
  167. <td class="add-comment-right">
  168. {{if eq $line.GetCommentSide "proposed"}}
  169. <div class="field comment-code-cloud">
  170. <div class="comment-list">
  171. <ui class="ui comments">
  172. {{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}}
  173. </ui>
  174. </div>
  175. {{template "repo/diff/comment_form_datahandler" dict "reply" (index $line.Comments 0).ReviewID "hidden" true "root" $ "comment" (index $line.Comments 0)}}
  176. </div>
  177. {{end}}
  178. </td>
  179. </tr>
  180. {{end}}
  181. {{end}}
  182. {{end}}
  183. {{else}}
  184. {{template "repo/diff/section_unified" dict "file" . "root" $}}
  185. {{end}}
  186. {{end}}
  187. </tbody>
  188. </table>
  189. </div>
  190. {{end}}
  191. </div>
  192. </div>
  193. {{end}}
  194. <br>
  195. {{end}}
  196. {{if .Diff.IsIncomplete}}
  197. <div class="diff-file-box diff-box file-content">
  198. <h4 class="ui top attached normal header">
  199. {{$.i18n.Tr "repo.diff.too_many_files"}}
  200. </h4>
  201. </div>
  202. {{end}}
  203. {{if not $.Repository.IsArchived}}
  204. <div id="pull_review_add_comment" class="hide">
  205. {{template "repo/diff/new_comment" dict "root" .}}
  206. </div>
  207. <div class="hide" id="edit-content-form">
  208. <div class="ui comment form">
  209. <div class="ui top attached tabular menu">
  210. <a class="active write item">{{$.i18n.Tr "write"}}</a>
  211. <a class="preview item" data-url="{{$.Repository.APIURL}}/markdown" data-context="{{$.RepoLink}}">{{$.i18n.Tr "preview"}}</a>
  212. </div>
  213. <div class="ui bottom attached active write tab segment">
  214. <textarea class="review-textarea" tabindex="1" name="content"></textarea>
  215. </div>
  216. <div class="ui bottom attached tab preview segment markdown">
  217. {{$.i18n.Tr "loading"}}
  218. </div>
  219. <div class="text right edit buttons">
  220. <div class="ui basic blue cancel button" tabindex="3">{{.i18n.Tr "repo.issues.cancel"}}</div>
  221. <div class="ui green save button" tabindex="2">{{.i18n.Tr "repo.issues.save"}}</div>
  222. </div>
  223. </div>
  224. </div>
  225. {{end}}
  226. {{if .IsSplitStyle}}
  227. <script>
  228. document.addEventListener('DOMContentLoaded', function() {
  229. $('tr.add-code').each(function() {
  230. var prev = $(this).prev();
  231. if(prev.is('.del-code') && prev.children().eq(5).text().trim() === '') {
  232. while(prev.prev().is('.del-code') && prev.prev().children().eq(5).text().trim() === '') {
  233. prev = prev.prev();
  234. }
  235. prev.children().eq(3).attr("data-line-num", $(this).children().eq(3).attr("data-line-num"));
  236. prev.children().eq(3).html($(this).children().eq(3).html());
  237. prev.children().eq(4).html($(this).children().eq(4).html());
  238. prev.children().eq(5).html($(this).children().eq(5).html());
  239. prev.children().eq(0).addClass('del-code');
  240. prev.children().eq(1).addClass('del-code');
  241. prev.children().eq(2).addClass('del-code');
  242. prev.children().eq(3).addClass('add-code');
  243. prev.children().eq(4).addClass('add-code');
  244. prev.children().eq(5).addClass('add-code');
  245. $(this).remove();
  246. }
  247. });
  248. });
  249. </script>
  250. {{end}}
  251. </div>
  252. {{end}}