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 7.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <div class="issue-content">
  2. <!-- I know, there is probably a better way to do this (moved from sidebar.tmpl, original author: 6543 @ 2021-02-28) -->
  3. <!-- Agree, there should be a better way, eg: introduce window.config.pageData (original author: wxiaoguang @ 2021-09-05) -->
  4. <input type="hidden" id="repolink" value="{{$.RepoRelPath}}">
  5. <input type="hidden" id="repoId" value="{{.Repository.ID}}">
  6. <input type="hidden" id="issueIndex" value="{{.Issue.Index}}">
  7. <input type="hidden" id="type" value="{{.IssueType}}">
  8. {{$createdStr:= TimeSinceUnix .Issue.CreatedUnix ctx.Locale}}
  9. <div class="issue-content-left comment-list prevent-before-timeline">
  10. <div class="ui timeline">
  11. <div id="{{.Issue.HashTag}}" class="timeline-item comment first">
  12. {{if .Issue.OriginalAuthor}}
  13. <span class="timeline-avatar">
  14. {{ctx.AvatarUtils.Avatar nil 40}}
  15. </span>
  16. {{else}}
  17. <a class="timeline-avatar" {{if gt .Issue.Poster.ID 0}}href="{{.Issue.Poster.HomeLink}}"{{end}}>
  18. {{ctx.AvatarUtils.Avatar .Issue.Poster 40}}
  19. </a>
  20. {{end}}
  21. <div class="content comment-container">
  22. <div class="ui top attached header comment-header tw-flex tw-items-center tw-justify-between" role="heading" aria-level="3">
  23. <div class="comment-header-left tw-flex tw-items-center">
  24. {{if .Issue.OriginalAuthor}}
  25. <span class="text black tw-font-semibold">
  26. {{svg (MigrationIcon .Repository.GetOriginalURLHostname)}}
  27. {{.Issue.OriginalAuthor}}
  28. </span>
  29. <span class="text grey muted-links">
  30. {{ctx.Locale.Tr "repo.issues.commented_at" .Issue.HashTag $createdStr}}
  31. </span>
  32. <span class="text migrate">
  33. {{if .Repository.OriginalURL}} ({{ctx.Locale.Tr "repo.migrated_from" .Repository.OriginalURL .Repository.GetOriginalURLHostname}}){{end}}
  34. </span>
  35. {{else}}
  36. <a class="inline-timeline-avatar" href="{{.Issue.Poster.HomeLink}}">
  37. {{ctx.AvatarUtils.Avatar .Issue.Poster 24}}
  38. </a>
  39. <span class="text grey muted-links">
  40. {{template "shared/user/authorlink" .Issue.Poster}}
  41. {{ctx.Locale.Tr "repo.issues.commented_at" .Issue.HashTag $createdStr}}
  42. </span>
  43. {{end}}
  44. </div>
  45. <div class="comment-header-right actions tw-flex tw-items-center">
  46. {{template "repo/issue/view_content/show_role" dict "ShowRole" .Issue.ShowRole "IgnorePoster" true}}
  47. {{if not $.Repository.IsArchived}}
  48. {{template "repo/issue/view_content/add_reaction" dict "ActionURL" (printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index)}}
  49. {{end}}
  50. {{template "repo/issue/view_content/context_menu" dict "ctxData" $ "item" .Issue "delete" false "issue" true "diff" false "IsCommentPoster" $.IsIssuePoster}}
  51. </div>
  52. </div>
  53. <div class="ui attached segment comment-body" role="article">
  54. <div class="render-content markup" {{if or $.Permission.IsAdmin $.HasIssuesOrPullsWritePermission $.IsIssuePoster}}data-can-edit="true"{{end}}>
  55. {{if .Issue.RenderedContent}}
  56. {{.Issue.RenderedContent}}
  57. {{else}}
  58. <span class="no-content">{{ctx.Locale.Tr "repo.issues.no_content"}}</span>
  59. {{end}}
  60. </div>
  61. <div id="issue-{{.Issue.ID}}-raw" class="raw-content tw-hidden">{{.Issue.Content}}</div>
  62. <div class="edit-content-zone tw-hidden" 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>
  63. {{if .Issue.Attachments}}
  64. {{template "repo/issue/view_content/attachments" dict "Attachments" .Issue.Attachments "RenderedContent" .Issue.RenderedContent}}
  65. {{end}}
  66. </div>
  67. {{$reactions := .Issue.Reactions.GroupByType}}
  68. {{if $reactions}}
  69. {{template "repo/issue/view_content/reactions" dict "ActionURL" (printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index) "Reactions" $reactions}}
  70. {{end}}
  71. </div>
  72. </div>
  73. {{template "repo/issue/view_content/comments" .}}
  74. {{if and .Issue.IsPull (not $.Repository.IsArchived)}}
  75. {{template "repo/issue/view_content/pull".}}
  76. {{end}}
  77. {{if .IsSigned}}
  78. {{if and (or .IsRepoAdmin .HasIssuesOrPullsWritePermission (not .Issue.IsLocked)) (not .Repository.IsArchived)}}
  79. <div class="timeline-item comment form">
  80. <a class="timeline-avatar" href="{{.SignedUser.HomeLink}}">
  81. {{ctx.AvatarUtils.Avatar .SignedUser 40}}
  82. </a>
  83. <div class="content">
  84. <form class="ui segment form form-fetch-action" id="comment-form" action="{{$.RepoLink}}/issues/{{.Issue.Index}}/comments" method="post">
  85. {{template "repo/issue/comment_tab" .}}
  86. {{.CsrfTokenHtml}}
  87. <div class="field footer">
  88. <div class="text right">
  89. {{if and (or .HasIssuesOrPullsWritePermission .IsIssuePoster) (not .DisableStatusChange)}}
  90. {{if .Issue.IsClosed}}
  91. <button id="status-button" class="ui primary basic button" data-status="{{ctx.Locale.Tr "repo.issues.reopen_issue"}}" data-status-and-comment="{{ctx.Locale.Tr "repo.issues.reopen_comment_issue"}}" name="status" value="reopen">
  92. {{ctx.Locale.Tr "repo.issues.reopen_issue"}}
  93. </button>
  94. {{else}}
  95. {{$closeTranslationKey := "repo.issues.close"}}
  96. {{if .Issue.IsPull}}
  97. {{$closeTranslationKey = "repo.pulls.close"}}
  98. {{end}}
  99. <button id="status-button" class="ui red basic button" data-status="{{ctx.Locale.Tr $closeTranslationKey}}" data-status-and-comment="{{ctx.Locale.Tr "repo.issues.close_comment_issue"}}" name="status" value="close">
  100. {{ctx.Locale.Tr $closeTranslationKey}}
  101. </button>
  102. {{end}}
  103. {{end}}
  104. <button class="ui primary button">
  105. {{ctx.Locale.Tr "repo.issues.create_comment"}}
  106. </button>
  107. </div>
  108. </div>
  109. </form>
  110. </div>
  111. </div>
  112. {{else if .Repository.IsArchived}}
  113. <div class="ui warning message tw-text-center">
  114. {{if .Issue.IsPull}}
  115. {{ctx.Locale.Tr "repo.archive.pull.nocomment"}}
  116. {{else}}
  117. {{ctx.Locale.Tr "repo.archive.issue.nocomment"}}
  118. {{end}}
  119. </div>
  120. {{end}}
  121. {{else}} {{/* not .IsSigned */}}
  122. {{if .Repository.IsArchived}}
  123. <div class="ui warning message tw-text-center">
  124. {{if .Issue.IsPull}}
  125. {{ctx.Locale.Tr "repo.archive.pull.nocomment"}}
  126. {{else}}
  127. {{ctx.Locale.Tr "repo.archive.issue.nocomment"}}
  128. {{end}}
  129. </div>
  130. {{else}}
  131. <div class="ui warning message">
  132. {{ctx.Locale.Tr "repo.issues.sign_in_require_desc" .SignInLink}}
  133. </div>
  134. {{end}}
  135. {{end}}{{/* end if: .IsSigned */}}
  136. </div>
  137. </div>
  138. {{template "repo/issue/view_content/sidebar" .}}
  139. </div>
  140. <template id="issue-comment-editor-template">
  141. <div class="ui comment form">
  142. <div class="field">
  143. {{template "shared/combomarkdowneditor" (dict
  144. "MarkdownPreviewUrl" (print .Repository.Link "/markup")
  145. "MarkdownPreviewContext" .RepoLink
  146. "TextareaName" "content"
  147. "DropzoneParentContainer" ".ui.form"
  148. )}}
  149. </div>
  150. {{if .IsAttachmentEnabled}}
  151. <div class="field">
  152. {{template "repo/upload" .}}
  153. </div>
  154. {{end}}
  155. <div class="field">
  156. <div class="text right edit">
  157. <button class="ui basic cancel button">{{ctx.Locale.Tr "repo.issues.cancel"}}</button>
  158. <button class="ui primary save button">{{ctx.Locale.Tr "repo.issues.save"}}</button>
  159. </div>
  160. </div>
  161. </div>
  162. </template>
  163. {{template "repo/issue/view_content/reference_issue_dialog" .}}
  164. {{template "shared/user/block_user_dialog" .}}
  165. <div class="tw-hidden" id="no-content">
  166. <span class="no-content">{{ctx.Locale.Tr "repo.issues.no_content"}}</span>
  167. </div>
  168. <div class="ui g-modal-confirm delete modal">
  169. <div class="header">
  170. {{svg "octicon-trash"}}
  171. {{ctx.Locale.Tr "repo.branch.delete" .HeadTarget}}
  172. </div>
  173. <div class="content">
  174. <p>{{ctx.Locale.Tr "repo.branch.delete_desc"}}</p>
  175. </div>
  176. {{template "base/modal_actions_confirm" .}}
  177. </div>