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.

view_content.tmpl 9.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <div class="ui stackable grid">
  2. {{if .Flash}}
  3. <div class="sixteen wide column">
  4. {{template "base/alert" .}}
  5. </div>
  6. {{end}}
  7. {{if not .Issue.IsPull}}
  8. {{template "repo/issue/view_title" .}}
  9. {{end}}
  10. <!-- I know, there is probably a better way to do this (moved from sidebar.tmpl, original author: 6543 @ 2021-02-28) -->
  11. <!-- Agree, there should be a better way, eg: introduce window.config.pageData (original author: wxiaoguang @ 2021-09-05) -->
  12. <input type="hidden" id="repolink" value="{{$.RepoRelPath}}">
  13. <input type="hidden" id="repoId" value="{{.Repository.ID}}">
  14. <input type="hidden" id="issueIndex" value="{{.Issue.Index}}"/>
  15. <input type="hidden" id="type" value="{{.IssueType}}">
  16. {{ $createdStr:= TimeSinceUnix .Issue.CreatedUnix $.Lang }}
  17. <div class="twelve wide column comment-list prevent-before-timeline">
  18. <ui class="ui timeline">
  19. <div id="{{.Issue.HashTag}}" class="timeline-item comment first">
  20. {{if .Issue.OriginalAuthor }}
  21. <span class="timeline-avatar"><img src="{{AppSubUrl}}/assets/img/avatar_default.png"></span>
  22. {{else}}
  23. <a class="timeline-avatar" {{if gt .Issue.Poster.ID 0}}href="{{.Issue.Poster.HomeLink}}"{{end}}>
  24. {{avatar .Issue.Poster}}
  25. </a>
  26. {{end}}
  27. <div class="content comment-container">
  28. <div class="ui top attached header comment-header df ac sb">
  29. <div class="comment-header-left df ac">
  30. {{if .Issue.OriginalAuthor }}
  31. <span class="text black">
  32. {{svg (MigrationIcon .Repository.GetOriginalURLHostname)}}
  33. {{ .Issue.OriginalAuthor }}
  34. </span>
  35. <span class="text grey">
  36. {{ .i18n.Tr "repo.issues.commented_at" (.Issue.HashTag|Escape) $createdStr | Safe }}
  37. </span>
  38. <span class="text migrate">
  39. {{if .Repository.OriginalURL}} ({{$.i18n.Tr "repo.migrated_from" (.Repository.OriginalURL|Escape) (.Repository.GetOriginalURLHostname|Escape) | Safe }}){{end}}
  40. </span>
  41. {{else}}
  42. <span class="text grey">
  43. <a class="author"{{if gt .Issue.Poster.ID 0}} href="{{.Issue.Poster.HomeLink}}"{{end}}>{{.Issue.Poster.GetDisplayName}}</a>
  44. {{.i18n.Tr "repo.issues.commented_at" (.Issue.HashTag|Escape) $createdStr | Safe}}
  45. </span>
  46. {{end}}
  47. </div>
  48. <div class="comment-header-right actions df ac">
  49. {{if gt .Issue.ShowRole 0}}
  50. {{if (.Issue.ShowRole.HasRole "Writer")}}
  51. <div class="ui basic label">
  52. {{$.i18n.Tr "repo.issues.collaborator"}}
  53. </div>
  54. {{end}}
  55. {{if (.Issue.ShowRole.HasRole "Owner")}}
  56. <div class="ui basic label">
  57. {{$.i18n.Tr "repo.issues.owner"}}
  58. </div>
  59. {{end}}
  60. {{end}}
  61. {{if not $.Repository.IsArchived}}
  62. {{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index)}}
  63. {{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" .Issue "delete" false "issue" true "diff" false "IsCommentPoster" $.IsIssuePoster}}
  64. {{end}}
  65. </div>
  66. </div>
  67. <div class="ui attached segment comment-body">
  68. <div class="render-content markup" {{if or $.Permission.IsAdmin $.HasIssuesOrPullsWritePermission $.IsIssuePoster}}data-can-edit="true"{{end}}>
  69. {{if .Issue.RenderedContent}}
  70. {{.Issue.RenderedContent|Str2html}}
  71. {{else}}
  72. <span class="no-content">{{.i18n.Tr "repo.issues.no_content"}}</span>
  73. {{end}}
  74. </div>
  75. <div id="comment-{{.Issue.ID}}" class="raw-content hide">{{.Issue.Content}}</div>
  76. <div class="edit-content-zone hide" data-write="issue-{{.Issue.ID}}-write" data-preview="issue-{{.Issue.ID}}-preview" data-update-url="{{$.RepoLink}}/issues/{{.Issue.Index}}/content" data-context="{{.RepoLink}}" data-attachment-url="{{$.RepoLink}}/issues/{{.Issue.Index}}/attachments" data-view-attachment-url="{{$.RepoLink}}/issues/{{.Issue.Index}}/view-attachments"></div>
  77. {{if .Issue.Attachments}}
  78. {{template "repo/issue/view_content/attachments" Dict "ctx" $ "Attachments" .Issue.Attachments "Content" .Issue.RenderedContent}}
  79. {{end}}
  80. </div>
  81. {{$reactions := .Issue.Reactions.GroupByType}}
  82. {{if $reactions}}
  83. <div class="ui attached segment reactions">
  84. {{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index) "Reactions" $reactions}}
  85. </div>
  86. {{end}}
  87. </div>
  88. </div>
  89. {{ template "repo/issue/view_content/comments" . }}
  90. {{if and .Issue.IsPull (not $.Repository.IsArchived)}}
  91. {{ template "repo/issue/view_content/pull". }}
  92. {{end}}
  93. {{if .IsSigned}}
  94. {{ if and (or .IsRepoAdmin .HasIssuesOrPullsWritePermission (not .Issue.IsLocked)) (not .Repository.IsArchived) }}
  95. <div class="timeline-item comment form">
  96. <a class="timeline-avatar" href="{{.SignedUser.HomeLink}}">
  97. {{avatar .SignedUser}}
  98. </a>
  99. <div class="content">
  100. <form class="ui segment form" id="comment-form" action="{{$.RepoLink}}/issues/{{.Issue.Index}}/comments" method="post">
  101. {{template "repo/issue/comment_tab" .}}
  102. {{.CsrfTokenHtml}}
  103. <input id="status" name="status" type="hidden">
  104. <div class="field footer">
  105. <div class="text right">
  106. {{if and (or .HasIssuesOrPullsWritePermission .IsIssuePoster) (not .DisableStatusChange)}}
  107. {{if .Issue.IsClosed}}
  108. <div id="status-button" class="ui green basic button" tabindex="6" data-status="{{.i18n.Tr "repo.issues.reopen_issue"}}" data-status-and-comment="{{.i18n.Tr "repo.issues.reopen_comment_issue"}}" data-status-val="reopen">
  109. {{.i18n.Tr "repo.issues.reopen_issue"}}
  110. </div>
  111. {{else}}
  112. <div id="status-button" class="ui red basic button" tabindex="6" data-status="{{.i18n.Tr "repo.issues.close_issue"}}" data-status-and-comment="{{.i18n.Tr "repo.issues.close_comment_issue"}}" data-status-val="close">
  113. {{.i18n.Tr "repo.issues.close_issue"}}
  114. </div>
  115. {{end}}
  116. {{end}}
  117. <button class="ui green button" tabindex="5">
  118. {{.i18n.Tr "repo.issues.create_comment"}}
  119. </button>
  120. </div>
  121. </div>
  122. </form>
  123. </div>
  124. </div>
  125. {{ else if .Repository.IsArchived }}
  126. <div class="ui warning message">
  127. {{if .Issue.IsPull}}
  128. {{.i18n.Tr "repo.archive.pull.nocomment"}}
  129. {{else}}
  130. {{.i18n.Tr "repo.archive.issue.nocomment"}}
  131. {{end}}
  132. </div>
  133. {{ end }}
  134. {{else}}
  135. {{if .Repository.IsArchived}}
  136. <div class="ui warning message">
  137. {{if .Issue.IsPull}}
  138. {{.i18n.Tr "repo.archive.pull.nocomment"}}
  139. {{else}}
  140. {{.i18n.Tr "repo.archive.issue.nocomment"}}
  141. {{end}}
  142. </div>
  143. {{else}}
  144. {{if .IsSigned}}
  145. {{if .Repository.IsArchived}}
  146. <div class="timeline-item comment form">
  147. <a class="timeline-avatar" href="{{.SignedUser.HomeLink}}">
  148. {{avatar .SignedUser}}
  149. </a>
  150. <div class="content">
  151. <form class="ui segment form" id="comment-form" action="{{$.RepoLink}}/issues/{{.Issue.Index}}/comments" method="post">
  152. {{template "repo/issue/comment_tab" .}}
  153. {{.CsrfTokenHtml}}
  154. <input id="status" name="status" type="hidden">
  155. <div class="field footer">
  156. <div class="text right">
  157. {{if and (or .HasIssuesOrPullsWritePermission .IsIssuePoster) (not .DisableStatusChange)}}
  158. {{if .Issue.IsClosed}}
  159. <div id="status-button" class="ui green basic button" tabindex="6" data-status="{{.i18n.Tr "repo.issues.reopen_issue"}}" data-status-and-comment="{{.i18n.Tr "repo.issues.reopen_comment_issue"}}" data-status-val="reopen">
  160. {{.i18n.Tr "repo.issues.reopen_issue"}}
  161. </div>
  162. {{else}}
  163. <div id="status-button" class="ui red basic button" tabindex="6" data-status="{{.i18n.Tr "repo.issues.close_issue"}}" data-status-and-comment="{{.i18n.Tr "repo.issues.close_comment_issue"}}" data-status-val="close">
  164. {{.i18n.Tr "repo.issues.close_issue"}}
  165. </div>
  166. {{end}}
  167. {{end}}
  168. <button class="ui green button" tabindex="5">
  169. {{.i18n.Tr "repo.issues.create_comment"}}
  170. </button>
  171. </div>
  172. </div>
  173. </form>
  174. </div>
  175. </div>
  176. {{end}}
  177. {{else}}
  178. <div class="ui warning message">
  179. {{.i18n.Tr "repo.issues.sign_in_require_desc" (.SignInLink|Escape) | Safe}}
  180. </div>
  181. {{end}}
  182. {{end}}
  183. {{end}}
  184. </ui>
  185. </div>
  186. {{ template "repo/issue/view_content/sidebar" . }}
  187. </div>
  188. <div class="hide" id="edit-content-form">
  189. <div class="ui comment form">
  190. <div class="ui top tabular menu">
  191. <a class="active write item">{{$.i18n.Tr "write"}}</a>
  192. <a class="preview item" data-url="{{$.Repository.APIURL}}/markdown" data-context="{{$.RepoLink}}">{{$.i18n.Tr "preview"}}</a>
  193. </div>
  194. <div class="field">
  195. <div class="ui bottom active tab write">
  196. <textarea tabindex="1" name="content"></textarea>
  197. </div>
  198. <div class="ui bottom tab preview markup">
  199. {{$.i18n.Tr "loading"}}
  200. </div>
  201. </div>
  202. {{if .IsAttachmentEnabled}}
  203. <div class="field">
  204. {{template "repo/upload" .}}
  205. </div>
  206. {{end}}
  207. <div class="field footer">
  208. <div class="text right edit">
  209. <div class="ui basic blue cancel button" tabindex="3">{{.i18n.Tr "repo.issues.cancel"}}</div>
  210. <div class="ui green save button" tabindex="2">{{.i18n.Tr "repo.issues.save"}}</div>
  211. </div>
  212. </div>
  213. </div>
  214. </div>
  215. {{template "repo/issue/view_content/reference_issue_dialog" .}}
  216. <div class="hide" id="no-content">
  217. <span class="no-content">{{.i18n.Tr "repo.issues.no_content"}}</span>
  218. </div>
  219. <div class="ui small basic delete modal">
  220. <div class="ui icon header">
  221. {{svg "octicon-trash"}}
  222. {{.i18n.Tr "repo.branch.delete" .HeadTarget }}
  223. </div>
  224. <div class="content">
  225. <p>{{.i18n.Tr "repo.branch.delete_desc" | Str2html}}</p>
  226. </div>
  227. {{template "base/delete_modal_actions" .}}
  228. </div>