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.

comments.tmpl 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. {{ template "base/alert" }}
  2. {{range .Issue.Comments}}
  3. {{ $createdStr:= TimeSinceUnix .CreatedUnix $.Lang }}
  4. <!-- 0 = COMMENT, 1 = REOPEN, 2 = CLOSE, 3 = ISSUE_REF, 4 = COMMIT_REF,
  5. 5 = COMMENT_REF, 6 = PULL_REF, 7 = COMMENT_LABEL, 12 = START_TRACKING,
  6. 13 = STOP_TRACKING, 14 = ADD_TIME_MANUAL, 16 = ADDED_DEADLINE, 17 = MODIFIED_DEADLINE,
  7. 18 = REMOVED_DEADLINE, 19 = ADD_DEPENDENCY, 20 = REMOVE_DEPENDENCY, 21 = CODE,
  8. 22 = REVIEW, 23 = ISSUE_LOCKED, 24 = ISSUE_UNLOCKED -->
  9. {{if eq .Type 0}}
  10. <div class="comment" id="{{.HashTag}}">
  11. <a class="avatar" {{if gt .Poster.ID 0}}href="{{.Poster.HomeLink}}"{{end}}>
  12. <img src="{{.Poster.RelAvatarLink}}">
  13. </a>
  14. <div class="content">
  15. <div class="ui top attached header">
  16. <span class="text grey"><a {{if gt .Poster.ID 0}}href="{{.Poster.HomeLink}}"{{end}}>{{.Poster.Name}}</a> {{$.i18n.Tr "repo.issues.commented_at" .HashTag $createdStr | Safe}}</span>
  17. {{if not $.Repository.IsArchived}}
  18. <div class="ui right actions">
  19. {{if gt .ShowTag 0}}
  20. <div class="item tag">
  21. {{if eq .ShowTag 1}}
  22. {{$.i18n.Tr "repo.issues.poster"}}
  23. {{else if eq .ShowTag 2}}
  24. {{$.i18n.Tr "repo.issues.collaborator"}}
  25. {{else if eq .ShowTag 3}}
  26. {{$.i18n.Tr "repo.issues.owner"}}
  27. {{end}}
  28. </div>
  29. {{end}}
  30. {{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) }}
  31. {{if or $.Permission.IsAdmin (eq .Poster.ID $.SignedUserID)}}
  32. <div class="item action">
  33. <a class="edit-content" href="#"><i class="octicon octicon-pencil"></i></a>
  34. <a class="delete-comment" href="#" data-comment-id={{.HashTag}} data-url="{{$.RepoLink}}/comments/{{.ID}}/delete" data-locale="{{$.i18n.Tr "repo.issues.delete_comment_confirm"}}"><i class="octicon octicon-x"></i></a>
  35. </div>
  36. {{end}}
  37. </div>
  38. {{end}}
  39. </div>
  40. <div class="ui attached segment">
  41. <div class="render-content markdown has-emoji">
  42. {{if .RenderedContent}}
  43. {{.RenderedContent|Str2html}}
  44. {{else}}
  45. <span class="no-content">{{$.i18n.Tr "repo.issues.no_content"}}</span>
  46. {{end}}
  47. </div>
  48. <div class="raw-content hide">{{.Content}}</div>
  49. <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}}"></div>
  50. </div>
  51. {{$reactions := .Reactions.GroupByType}}
  52. {{if $reactions}}
  53. <div class="ui attached segment reactions">
  54. {{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) "Reactions" $reactions }}
  55. </div>
  56. {{end}}
  57. {{if .Attachments}}
  58. <div class="ui bottom attached segment">
  59. <div class="ui small images">
  60. {{range .Attachments}}
  61. <a target="_blank" rel="noopener noreferrer" href="{{AppSubUrl}}/attachments/{{.UUID}}">
  62. {{if FilenameIsImage .Name}}
  63. <img class="ui image" src="{{AppSubUrl}}/attachments/{{.UUID}}" title='{{$.i18n.Tr "repo.issues.attachment.open_tab" .Name}}'>
  64. {{else}}
  65. <span class="ui image octicon octicon-desktop-download" title='{{$.i18n.Tr "repo.issues.attachment.download" .Name}}'></span>
  66. {{end}}
  67. </a>
  68. {{end}}
  69. </div>
  70. </div>
  71. {{end}}
  72. </div>
  73. </div>
  74. {{else if eq .Type 1}}
  75. <div class="event">
  76. <span class="octicon octicon-primitive-dot"></span>
  77. <a class="ui avatar image" href="{{.Poster.HomeLink}}">
  78. <img src="{{.Poster.RelAvatarLink}}">
  79. </a>
  80. <span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a> {{$.i18n.Tr "repo.issues.reopened_at" .EventTag $createdStr | Safe}}</span>
  81. </div>
  82. {{else if eq .Type 2}}
  83. <div class="event">
  84. <span class="octicon octicon-circle-slash"></span>
  85. <a class="ui avatar image" href="{{.Poster.HomeLink}}">
  86. <img src="{{.Poster.RelAvatarLink}}">
  87. </a>
  88. <span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a> {{$.i18n.Tr "repo.issues.closed_at" .EventTag $createdStr | Safe}}</span>
  89. </div>
  90. {{else if eq .Type 4}}
  91. <div class="event">
  92. <span class="octicon octicon-bookmark"></span>
  93. <a class="ui avatar image" href="{{.Poster.HomeLink}}">
  94. <img src="{{.Poster.RelAvatarLink}}">
  95. </a>
  96. <span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a> {{$.i18n.Tr "repo.issues.commit_ref_at" .EventTag $createdStr | Safe}}</span>
  97. <div class="detail">
  98. <span class="octicon octicon-git-commit"></span>
  99. <span class="text grey">{{.Content | Str2html}}</span>
  100. </div>
  101. </div>
  102. {{else if eq .Type 7}}
  103. {{if .Label}}
  104. <div class="event">
  105. <span class="octicon octicon-primitive-dot"></span>
  106. <a class="ui avatar image" href="{{.Poster.HomeLink}}">
  107. <img src="{{.Poster.RelAvatarLink}}">
  108. </a>
  109. <span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a>
  110. {{if .Content}}{{$.i18n.Tr "repo.issues.add_label_at" .Label.ForegroundColor .Label.Color (.Label.Name|Escape) $createdStr | Safe}}{{else}}{{$.i18n.Tr "repo.issues.remove_label_at" .Label.ForegroundColor .Label.Color (.Label.Name|Escape) $createdStr | Safe}}{{end}}</span>
  111. </div>
  112. {{end}}
  113. {{else if eq .Type 8}}
  114. <div class="event">
  115. <span class="octicon octicon-primitive-dot"></span>
  116. <a class="ui avatar image" href="{{.Poster.HomeLink}}">
  117. <img src="{{.Poster.RelAvatarLink}}">
  118. </a>
  119. <span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a>
  120. {{if gt .OldMilestoneID 0}}{{if gt .MilestoneID 0}}{{$.i18n.Tr "repo.issues.change_milestone_at" (.OldMilestone.Name|Escape) (.Milestone.Name|Escape) $createdStr | Safe}}{{else}}{{$.i18n.Tr "repo.issues.remove_milestone_at" (.OldMilestone.Name|Escape) $createdStr | Safe}}{{end}}{{else if gt .MilestoneID 0}}{{$.i18n.Tr "repo.issues.add_milestone_at" (.Milestone.Name|Escape) $createdStr | Safe}}{{end}}</span>
  121. </div>
  122. {{else if eq .Type 9}}
  123. <div class="event">
  124. <span class="octicon octicon-primitive-dot"></span>
  125. {{if gt .AssigneeID 0}}
  126. {{if .RemovedAssignee}}
  127. <a class="ui avatar image" href="{{.Assignee.HomeLink}}">
  128. <img src="{{.Assignee.RelAvatarLink}}">
  129. </a>
  130. <span class="text grey">
  131. <a href="{{.Assignee.HomeLink}}">{{.Assignee.Name}}</a>
  132. {{ if eq .Poster.ID .Assignee.ID }}
  133. {{$.i18n.Tr "repo.issues.remove_self_assignment" $createdStr | Safe}}
  134. {{ else }}
  135. {{$.i18n.Tr "repo.issues.remove_assignee_at" .Poster.Name $createdStr | Safe}}
  136. {{ end }}
  137. </span>
  138. {{else}}
  139. <a class="ui avatar image" href="{{.Assignee.HomeLink}}">
  140. <img src="{{.Assignee.RelAvatarLink}}">
  141. </a>
  142. <span class="text grey">
  143. <a href="{{.Assignee.HomeLink}}">{{.Assignee.Name}}</a>
  144. {{if eq .Poster.ID .AssigneeID}}
  145. {{$.i18n.Tr "repo.issues.self_assign_at" $createdStr | Safe}}
  146. {{else}}
  147. {{$.i18n.Tr "repo.issues.add_assignee_at" .Poster.Name $createdStr | Safe}}
  148. {{end}}
  149. </span>
  150. {{end}}
  151. {{end}}
  152. </div>
  153. {{else if eq .Type 10}}
  154. <div class="event">
  155. <span class="octicon octicon-primitive-dot"></span>
  156. <a class="ui avatar image" href="{{.Poster.HomeLink}}">
  157. <img src="{{.Poster.RelAvatarLink}}">
  158. </a>
  159. <span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a>
  160. {{$.i18n.Tr "repo.issues.change_title_at" (.OldTitle|Escape) (.NewTitle|Escape) $createdStr | Safe}}
  161. </span>
  162. </div>
  163. {{else if eq .Type 11}}
  164. <div class="event">
  165. <span class="octicon octicon-primitive-dot"></span>
  166. <a class="ui avatar image" href="{{.Poster.HomeLink}}">
  167. <img src="{{.Poster.RelAvatarLink}}">
  168. </a>
  169. <span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a>
  170. {{$.i18n.Tr "repo.issues.delete_branch_at" (.CommitSHA|Escape) $createdStr | Safe}}
  171. </span>
  172. </div>
  173. {{else if eq .Type 12}}
  174. <div class="event">
  175. <span class="octicon octicon-primitive-dot"></span>
  176. <a class="ui avatar image" href="{{.Poster.HomeLink}}">
  177. <img src="{{.Poster.RelAvatarLink}}">
  178. </a>
  179. <span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a> {{$.i18n.Tr "repo.issues.start_tracking_history" $createdStr | Safe}}</span>
  180. </div>
  181. {{else if eq .Type 13}}
  182. <div class="event">
  183. <span class="octicon octicon-primitive-dot"></span>
  184. <a class="ui avatar image" href="{{.Poster.HomeLink}}">
  185. <img src="{{.Poster.RelAvatarLink}}">
  186. </a>
  187. <span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a> {{$.i18n.Tr "repo.issues.stop_tracking_history" $createdStr | Safe}}</span>
  188. <div class="detail">
  189. <span class="octicon octicon-clock"></span>
  190. <span class="text grey">{{.Content}}</span>
  191. </div>
  192. </div>
  193. {{else if eq .Type 14}}
  194. <div class="event">
  195. <span class="octicon octicon-primitive-dot"></span>
  196. <a class="ui avatar image" href="{{.Poster.HomeLink}}">
  197. <img src="{{.Poster.RelAvatarLink}}">
  198. </a>
  199. <span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a> {{$.i18n.Tr "repo.issues.add_time_history" $createdStr | Safe}}</span>
  200. <div class="detail">
  201. <span class="octicon octicon-clock"></span>
  202. <span class="text grey">{{.Content}}</span>
  203. </div>
  204. </div>
  205. {{else if eq .Type 15}}
  206. <div class="event">
  207. <span class="octicon octicon-primitive-dot"></span>
  208. <a class="ui avatar image" href="{{.Poster.HomeLink}}">
  209. <img src="{{.Poster.RelAvatarLink}}">
  210. </a>
  211. <span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a> {{$.i18n.Tr "repo.issues.cancel_tracking_history" $createdStr | Safe}}</span>
  212. </div>
  213. {{else if eq .Type 16}}
  214. <div class="event">
  215. <span class="octicon octicon-primitive-dot"></span>
  216. <a class="ui avatar image" href="{{.Poster.HomeLink}}">
  217. <img src="{{.Poster.RelAvatarLink}}">
  218. </a>
  219. <span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a>
  220. {{$.i18n.Tr "repo.issues.due_date_added" .Content $createdStr | Safe}}
  221. </span>
  222. </div>
  223. {{else if eq .Type 17}}
  224. <div class="event">
  225. <span class="octicon octicon-primitive-dot"></span>
  226. <a class="ui avatar image" href="{{.Poster.HomeLink}}">
  227. <img src="{{.Poster.RelAvatarLink}}">
  228. </a>
  229. <span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a>
  230. {{$.i18n.Tr "repo.issues.due_date_modified" (.Content | ParseDeadline) $createdStr | Safe}}
  231. </span>
  232. </div>
  233. {{else if eq .Type 18}}
  234. <div class="event">
  235. <span class="octicon octicon-primitive-dot"></span>
  236. <a class="ui avatar image" href="{{.Poster.HomeLink}}">
  237. <img src="{{.Poster.RelAvatarLink}}">
  238. </a>
  239. <span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a>
  240. {{$.i18n.Tr "repo.issues.due_date_remove" .Content $createdStr | Safe}}
  241. </span>
  242. </div>
  243. {{else if eq .Type 19}}
  244. <div class="event">
  245. <span class="octicon octicon-primitive-dot"></span>
  246. <a class="ui avatar image" href="{{.Poster.HomeLink}}">
  247. <img src="{{.Poster.RelAvatarLink}}">
  248. </a>
  249. <span class="text grey">
  250. {{$.i18n.Tr "repo.issues.dependency.added_dependency" .Poster.HomeLink .Poster.Name $createdStr | Safe}}
  251. </span>
  252. <div class="detail">
  253. <span class="octicon octicon-plus"></span>
  254. <span class="text grey"><a href="{{$.RepoLink}}/issues/{{.DependentIssue.Index}}">#{{.DependentIssue.Index}} {{.DependentIssue.Title}}</a></span>
  255. </div>
  256. </div>
  257. {{else if eq .Type 20}}
  258. <div class="event">
  259. <span class="octicon octicon-primitive-dot"></span>
  260. <a class="ui avatar image" href="{{.Poster.HomeLink}}">
  261. <img src="{{.Poster.RelAvatarLink}}">
  262. </a>
  263. <span class="text grey">
  264. {{$.i18n.Tr "repo.issues.dependency.removed_dependency" .Poster.HomeLink .Poster.Name $createdStr | Safe}}
  265. </span>
  266. <div class="detail">
  267. <span class="text grey octicon octicon-trashcan"></span>
  268. <span class="text grey"><a href="{{$.RepoLink}}/issues/{{.DependentIssue.Index}}">#{{.DependentIssue.Index}} {{.DependentIssue.Title}}</a></span>
  269. </div>
  270. </div>
  271. {{else if eq .Type 22}}
  272. <div class="event" id="{{.HashTag}}">
  273. <span class="octicon octicon-{{.Review.Type.Icon}}"></span>
  274. <a class="ui avatar image" href="{{.Poster.HomeLink}}">
  275. <img src="{{.Poster.RelAvatarLink}}">
  276. </a>
  277. <span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a>
  278. {{if eq .Review.Type 1}}
  279. {{$.i18n.Tr "repo.issues.review.approve" $createdStr | Safe}}
  280. {{else if eq .Review.Type 2}}
  281. {{$.i18n.Tr "repo.issues.review.comment" $createdStr | Safe}}
  282. {{else if eq .Review.Type 3}}
  283. {{$.i18n.Tr "repo.issues.review.reject" $createdStr | Safe}}
  284. {{else}}
  285. {{$.i18n.Tr "repo.issues.review.comment" $createdStr | Safe}}
  286. {{end}}
  287. </span>
  288. {{if .Content}}
  289. <div class="detail">
  290. <span class="octicon octicon-quote"></span>
  291. <span class="text grey">{{.Content}}</span>
  292. </div>
  293. {{end}}
  294. {{ range $filename, $lines := .Review.CodeComments}}
  295. {{range $line, $comms := $lines}}
  296. <div class="ui segments">
  297. <div class="ui segment">
  298. {{$invalid := (index $comms 0).Invalidated}}
  299. {{if $invalid}}
  300. <button id="show-outdated-{{(index $comms 0).ID}}" data-comment="{{(index $comms 0).ID}}" class="ui compact right labeled button show-outdated">
  301. <i class="octicon octicon-fold"></i>
  302. {{$.i18n.Tr "repo.issues.review.show_outdated"}}
  303. </button>
  304. <button id="hide-outdated-{{(index $comms 0).ID}}" data-comment="{{(index $comms 0).ID}}" class="hide ui compact right labeled button hide-outdated">
  305. <i class="octicon octicon-fold"></i>
  306. {{$.i18n.Tr "repo.issues.review.hide_outdated"}}
  307. </button>
  308. {{end}}
  309. <a href="{{(index $comms 0).CodeCommentURL}}" class="file-comment">{{$filename}}</a>
  310. </div>
  311. {{$diff := ((index $comms 0).MustAsDiff)}}
  312. {{if $diff}}
  313. {{$file := (index $diff.Files 0)}}
  314. <div id="code-preview-{{(index $comms 0).ID}}" class="ui table segment{{if $invalid}} hide{{end}}">
  315. <div class="diff-file-box diff-box file-content {{TabSizeClass $.Editorconfig $file.Name}}">
  316. <div class="file-body file-code code-view code-diff code-diff-unified">
  317. <table>
  318. <tbody>
  319. {{template "repo/diff/section_unified" dict "file" $file "root" $}}
  320. </tbody>
  321. </table>
  322. </div>
  323. </div>
  324. </div>
  325. {{end}}
  326. <div id="code-comments-{{(index $comms 0).ID}}" class="ui segment{{if $invalid}} hide{{end}}">
  327. <div class="ui comments">
  328. {{range $comms}}
  329. {{ $createdSubStr:= TimeSinceUnix .CreatedUnix $.Lang }}
  330. <div class="comment" id="{{.HashTag}}">
  331. <a class="avatar">
  332. <img src="{{.Poster.RelAvatarLink}}">
  333. </a>
  334. <div class="content">
  335. <a class="author" {{if gt .Poster.ID 0}}href="{{.Poster.HomeLink}}"{{end}}>{{.Poster.Name}}</a>
  336. <div class="metadata">
  337. <span class="date">{{$.i18n.Tr "repo.issues.commented_at" .HashTag $createdSubStr | Safe}}</span>
  338. </div>
  339. <div class="text">
  340. <div class="render-content markdown has-emoji">
  341. {{if .RenderedContent}}
  342. {{.RenderedContent|Str2html}}
  343. {{else}}
  344. <span class="no-content">{{$.i18n.Tr "repo.issues.no_content"}}</span>
  345. {{end}}
  346. </div>
  347. <div class="raw-content hide">{{.Content}}</div>
  348. </div>
  349. </div>
  350. </div>
  351. {{end}}
  352. </div>
  353. {{template "repo/diff/comment_form_datahandler" dict "hidden" true "reply" (index $comms 0).ReviewID "root" $ "comment" (index $comms 0)}}
  354. </div>
  355. </div>
  356. {{end}}
  357. {{end}}
  358. </div>
  359. {{else if eq .Type 23}}
  360. <div class="event">
  361. <span class="octicon octicon-lock"
  362. style="font-size:20px;margin-left:-28.5px; margin-right: -1px"></span>
  363. <a class="ui avatar image" href="{{.Poster.HomeLink}}">
  364. <img src="{{.Poster.RelAvatarLink}}">
  365. </a>
  366. {{ if .Content }}
  367. <span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a>
  368. {{$.i18n.Tr "repo.issues.lock_with_reason" .Content $createdStr | Safe}}
  369. </span>
  370. {{ else }}
  371. <span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a>
  372. {{$.i18n.Tr "repo.issues.lock_no_reason" $createdStr | Safe}}
  373. </span>
  374. {{ end }}
  375. </div>
  376. {{else if eq .Type 24}}
  377. <div class="event">
  378. <span class="octicon octicon-key"
  379. style="font-size:20px;margin-left:-28.5px; margin-right: -1px"></span>
  380. <a class="ui avatar image" href="{{.Poster.HomeLink}}">
  381. <img src="{{.Poster.RelAvatarLink}}">
  382. </a>
  383. <span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a>
  384. {{$.i18n.Tr "repo.issues.unlock_comment" $createdStr | Safe}}
  385. </span>
  386. </div>
  387. {{end}}
  388. {{end}}