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.

405 lines
17 KiB

  1. {{if gt (len .PullReviewers) 0}}
  2. <div class="comment box">
  3. <div class="content">
  4. <div class="ui segment">
  5. <h4>{{$.i18n.Tr "repo.issues.review.reviewers"}}</h4>
  6. {{range .PullReviewers}}
  7. {{ $createdStr:= TimeSinceUnix .UpdatedUnix $.Lang }}
  8. <div class="ui divider"></div>
  9. <div class="review-item">
  10. <div class="review-item-left">
  11. <a class="ui avatar image" href="{{.Reviewer.HomeLink}}">
  12. <img src="{{.Reviewer.RelAvatarLink}}">
  13. </a>
  14. <span class="text grey"><a href="{{.Reviewer.HomeLink}}">{{.Reviewer.Name}}</a>
  15. {{if eq .Type 1}}
  16. {{$.i18n.Tr "repo.issues.review.approve" $createdStr | Safe}}
  17. {{else if eq .Type 2}}
  18. {{$.i18n.Tr "repo.issues.review.comment" $createdStr | Safe}}
  19. {{else if eq .Type 3}}
  20. {{$.i18n.Tr "repo.issues.review.reject" $createdStr | Safe}}
  21. {{else if eq .Type 4}}
  22. {{$.i18n.Tr "repo.issues.review.wait" $createdStr | Safe}}
  23. {{else}}
  24. {{$.i18n.Tr "repo.issues.review.comment" $createdStr | Safe}}
  25. {{end}}
  26. </span>
  27. </div>
  28. <div class="review-item-right">
  29. {{if .Stale}}
  30. <span class="ui poping up type-icon text grey" data-content="{{$.i18n.Tr "repo.issues.is_stale"}}">
  31. <i class="octicon icon fa-hourglass-end"></i>
  32. </span>
  33. {{end}}
  34. <span class="type-icon text {{if eq .Type 1}}green
  35. {{- else if eq .Type 2}}grey
  36. {{- else if eq .Type 3}}red
  37. {{- else if eq .Type 4}}yellow
  38. {{else}}grey{{end}}">
  39. {{$canChoose := false}}
  40. {{if eq .Type 4}}
  41. {{if or (eq .ReviewerID $.SignedUserID) $.Permission.IsAdmin}}
  42. {{$canChoose = true}}
  43. {{end}}
  44. {{else}}
  45. {{if and (or $.IsIssuePoster $.CanChooseReviewer) (not (eq $.SignedUserID .ReviewerID))}}
  46. {{$canChoose = true}}
  47. {{end}}
  48. {{end}}
  49. {{if $canChoose }}
  50. <a href="#" class="ui poping up icon re-request-review" data-is-checked="{{if eq .Type 4}}true{{else}}false{{end}}" data-issue-id="{{$.Issue.ID}}" data-content="{{ if eq .Type 4 }} {{$.i18n.Tr "repo.issues.remove_request_review"}} {{else}} {{$.i18n.Tr "repo.issues.re_request_review"}} {{end}}" data-id="{{.ReviewerID}}" data-update-url="{{$.RepoLink}}/issues/request_review">
  51. {{svg "octicon-sync"}}
  52. </a>
  53. {{end}}
  54. {{svg (printf "octicon-%s" .Type.Icon)}}
  55. </span>
  56. </div>
  57. </div>
  58. {{end}}
  59. </div>
  60. </div>
  61. </div>
  62. {{end}}
  63. <div class="timeline-item comment merge box">
  64. <a class="timeline-avatar text {{if .Issue.PullRequest.HasMerged}}purple
  65. {{- else if .Issue.IsClosed}}grey
  66. {{- else if .IsPullWorkInProgress}}grey
  67. {{- else if .IsFilesConflicted}}grey
  68. {{- else if .IsPullRequestBroken}}red
  69. {{- else if .IsBlockedByApprovals}}red
  70. {{- else if .IsBlockedByRejection}}red
  71. {{- else if .IsBlockedByOutdatedBranch}}red
  72. {{- else if and .EnableStatusCheck (or .RequiredStatusCheckState.IsFailure .RequiredStatusCheckState.IsError)}}red
  73. {{- else if and .EnableStatusCheck (or (not $.LatestCommitStatus) .RequiredStatusCheckState.IsPending .RequiredStatusCheckState.IsWarning)}}yellow
  74. {{- else if and .AllowMerge .RequireSigned (not .WillSign)}}red
  75. {{- else if .Issue.PullRequest.IsChecking}}yellow
  76. {{- else if .Issue.PullRequest.CanAutoMerge}}green
  77. {{- else}}red{{end}}">{{svg "octicon-git-merge" 32}}</a>
  78. <div class="content">
  79. {{template "repo/pulls/status" .}}
  80. {{$canAutoMerge := false}}
  81. <div class="ui attached merge-section segment {{if not $.LatestCommitStatus}}no-header{{end}}">
  82. {{if .Issue.PullRequest.HasMerged}}
  83. <div class="item text purple">
  84. {{if .Issue.PullRequest.MergedCommitID}}
  85. {{$link := printf "%s/commit/%s" $.Repository.HTMLURL .Issue.PullRequest.MergedCommitID}}
  86. {{$.i18n.Tr "repo.pulls.merged_as" $link (ShortSha .Issue.PullRequest.MergedCommitID) | Safe}}
  87. {{else}}
  88. {{$.i18n.Tr "repo.pulls.has_merged"}}
  89. {{end}}
  90. </div>
  91. {{if .IsPullBranchDeletable}}
  92. <div class="ui divider"></div>
  93. <div>
  94. <a class="delete-button ui red button" href="" data-url="{{.DeleteBranchLink}}">{{$.i18n.Tr "repo.branch.delete" .HeadTarget}}</a>
  95. </div>
  96. {{end}}
  97. {{else if .Issue.IsClosed}}
  98. <div class="item text grey">
  99. {{if .IsPullRequestBroken}}
  100. {{$.i18n.Tr "repo.pulls.cant_reopen_deleted_branch"}}
  101. {{else}}
  102. {{$.i18n.Tr "repo.pulls.reopen_to_merge"}}
  103. {{end}}
  104. </div>
  105. {{if and .IsPullBranchDeletable ( not .IsPullRequestBroken )}}
  106. <div class="ui divider"></div>
  107. <div>
  108. <a class="delete-button ui red button" href="" data-url="{{.DeleteBranchLink}}">{{$.i18n.Tr "repo.branch.delete" .HeadTarget}}</a>
  109. </div>
  110. {{end}}
  111. {{else if .IsPullFilesConflicted}}
  112. <div class="item text grey">
  113. {{svg "octicon-x"}}
  114. {{$.i18n.Tr "repo.pulls.files_conflicted"}}
  115. {{range .ConflictedFiles}}
  116. <div>{{.}}</div>
  117. {{end}}
  118. </div>
  119. {{else if .IsPullRequestBroken}}
  120. <div class="item text red">
  121. <i class="icon icon-octicon">{{svg "octicon-x"}}</i>
  122. {{$.i18n.Tr "repo.pulls.data_broken"}}
  123. </div>
  124. {{else if .IsPullWorkInProgress}}
  125. <div class="item text grey">
  126. <i class="icon icon-octicon">{{svg "octicon-x"}}</i>
  127. {{$.i18n.Tr "repo.pulls.cannot_merge_work_in_progress" (.WorkInProgressPrefix|Escape) | Str2html}}
  128. </div>
  129. {{else if .Issue.PullRequest.IsChecking}}
  130. <div class="item text yellow">
  131. <i class="icon icon-octicon">{{svg "octicon-sync"}}</i>
  132. {{$.i18n.Tr "repo.pulls.is_checking"}}
  133. </div>
  134. {{else if .Issue.PullRequest.CanAutoMerge}}
  135. {{if .IsBlockedByApprovals}}
  136. <div class="item text red">
  137. <i class="icon icon-octicon">{{svg "octicon-x"}}</i>
  138. {{$.i18n.Tr "repo.pulls.blocked_by_approvals" .GrantedApprovals .Issue.PullRequest.ProtectedBranch.RequiredApprovals}}
  139. </div>
  140. {{else if .IsBlockedByRejection}}
  141. <div class="item text red">
  142. <i class="icon icon-octicon">{{svg "octicon-x"}}</i>
  143. {{$.i18n.Tr "repo.pulls.blocked_by_rejection"}}
  144. </div>
  145. {{else if .IsBlockedByOutdatedBranch}}
  146. <div class="item text red">
  147. <i class="icon icon-octicon">{{svg "octicon-x"}}</i>
  148. {{$.i18n.Tr "repo.pulls.blocked_by_outdated_branch"}}
  149. </div>
  150. {{else if and .EnableStatusCheck (or .RequiredStatusCheckState.IsError .RequiredStatusCheckState.IsFailure)}}
  151. <div class="item text red">
  152. <i class="icon icon-octicon">{{svg "octicon-x"}}</i>
  153. {{$.i18n.Tr "repo.pulls.required_status_check_failed"}}
  154. </div>
  155. {{else if and .EnableStatusCheck (not .RequiredStatusCheckState.IsSuccess)}}
  156. <div class="item text red">
  157. <i class="icon icon-octicon">{{svg "octicon-x"}}</i>
  158. {{$.i18n.Tr "repo.pulls.required_status_check_missing"}}
  159. </div>
  160. {{else if and .AllowMerge .RequireSigned (not .WillSign)}}
  161. <div class="item text red">
  162. <i class="icon icon-octicon">{{svg "octicon-x"}}</i>
  163. {{$.i18n.Tr "repo.pulls.require_signed_wont_sign"}}
  164. </div>
  165. <div class="item text yellow">
  166. <i class="icon unlock"></i>
  167. {{$.i18n.Tr (printf "repo.signing.wont_sign.%s" .WontSignReason) }}
  168. </div>
  169. {{end}}
  170. {{$notAllOverridableChecksOk := or .IsBlockedByApprovals .IsBlockedByRejection .IsBlockedByOutdatedBranch (and .EnableStatusCheck (not .RequiredStatusCheckState.IsSuccess))}}
  171. {{if and (or $.IsRepoAdmin (not $notAllOverridableChecksOk)) (or (not .AllowMerge) (not .RequireSigned) .WillSign)}}
  172. {{if $notAllOverridableChecksOk}}
  173. <div class="item text yellow">
  174. <i class="icon icon-octicon">{{svg "octicon-dot-fill"}}</i>
  175. {{$.i18n.Tr "repo.pulls.required_status_check_administrator"}}
  176. </div>
  177. {{else}}
  178. <div class="item text green">
  179. <i class="icon icon-octicon">{{svg "octicon-check"}}</i>
  180. {{$.i18n.Tr "repo.pulls.can_auto_merge_desc"}}
  181. </div>
  182. {{end}}
  183. {{if .WillSign}}
  184. <div class="item text green">
  185. <i class="icon lock green"></i>
  186. {{$.i18n.Tr "repo.signing.will_sign" .SigningKey}}
  187. </div>
  188. {{else if .IsSigned}}
  189. <div class="item text">
  190. <i class="icon unlock"></i>
  191. {{$.i18n.Tr (printf "repo.signing.wont_sign.%s" .WontSignReason) }}
  192. </div>
  193. {{end}}
  194. {{end}}
  195. {{$canAutoMerge = true}}
  196. {{if (gt .Issue.PullRequest.CommitsBehind 0)}}
  197. <div class="ui divider"></div>
  198. <div class="item item-section text grey">
  199. <div class="item-section-left">
  200. <i class="icon icon-octicon">{{svg "octicon-alert"}}</i>
  201. {{$.i18n.Tr "repo.pulls.outdated_with_base_branch"}}
  202. </div>
  203. <div class="item-section-right">
  204. {{if .UpdateAllowed}}
  205. <form action="{{.Link}}/update" method="post" class="ui update-branch-form">
  206. {{.CsrfTokenHtml}}
  207. <button class="ui compact button" data-do="update">
  208. <span class="ui text">{{$.i18n.Tr "repo.pulls.update_branch"}}</span>
  209. </button>
  210. </form>
  211. {{end}}
  212. </div>
  213. </div>
  214. {{end}}
  215. {{if and (or $.IsRepoAdmin (not $notAllOverridableChecksOk)) (or (not .AllowMerge) (not .RequireSigned) .WillSign)}}
  216. {{if .AllowMerge}}
  217. {{$prUnit := .Repository.MustGetUnit $.UnitTypePullRequests}}
  218. {{$approvers := .Issue.PullRequest.GetApprovers}}
  219. {{if or $prUnit.PullRequestsConfig.AllowMerge $prUnit.PullRequestsConfig.AllowRebase $prUnit.PullRequestsConfig.AllowRebaseMerge $prUnit.PullRequestsConfig.AllowSquash}}
  220. <div class="ui divider"></div>
  221. {{if $prUnit.PullRequestsConfig.AllowMerge}}
  222. <div class="ui form merge-fields" style="display: none">
  223. <form action="{{.Link}}/merge" method="post">
  224. {{.CsrfTokenHtml}}
  225. <div class="field">
  226. <input type="text" name="merge_title_field" value="{{.Issue.PullRequest.GetDefaultMergeMessage}}">
  227. </div>
  228. <div class="field">
  229. <textarea name="merge_message_field" rows="5" placeholder="{{$.i18n.Tr "repo.editor.commit_message_desc"}}">Reviewed-on: {{$.Issue.HTMLURL}}&#13;&#10;{{$approvers}}</textarea>
  230. </div>
  231. <button class="ui green button" type="submit" name="do" value="merge">
  232. {{$.i18n.Tr "repo.pulls.merge_pull_request"}}
  233. </button>
  234. <button class="ui button merge-cancel">
  235. {{$.i18n.Tr "cancel"}}
  236. </button>
  237. </form>
  238. </div>
  239. {{end}}
  240. {{if $prUnit.PullRequestsConfig.AllowRebase}}
  241. <div class="ui form rebase-fields" style="display: none">
  242. <form action="{{.Link}}/merge" method="post">
  243. {{.CsrfTokenHtml}}
  244. <button class="ui green button" type="submit" name="do" value="rebase">
  245. {{$.i18n.Tr "repo.pulls.rebase_merge_pull_request"}}
  246. </button>
  247. <button class="ui button merge-cancel">
  248. {{$.i18n.Tr "cancel"}}
  249. </button>
  250. </form>
  251. </div>
  252. {{end}}
  253. {{if $prUnit.PullRequestsConfig.AllowRebaseMerge}}
  254. <div class="ui form rebase-merge-fields" style="display: none">
  255. <form action="{{.Link}}/merge" method="post">
  256. {{.CsrfTokenHtml}}
  257. <div class="field">
  258. <input type="text" name="merge_title_field" value="{{.Issue.PullRequest.GetDefaultMergeMessage}}">
  259. </div>
  260. <div class="field">
  261. <textarea name="merge_message_field" rows="5" placeholder="{{$.i18n.Tr "repo.editor.commit_message_desc"}}">Reviewed-on: {{$.Issue.HTMLURL}}&#13;&#10;{{$approvers}}</textarea>
  262. </div>
  263. <button class="ui green button" type="submit" name="do" value="rebase-merge">
  264. {{$.i18n.Tr "repo.pulls.rebase_merge_commit_pull_request"}}
  265. </button>
  266. <button class="ui button merge-cancel">
  267. {{$.i18n.Tr "cancel"}}
  268. </button>
  269. </form>
  270. </div>
  271. {{end}}
  272. {{if $prUnit.PullRequestsConfig.AllowSquash}}
  273. <div class="ui form squash-fields" style="display: none">
  274. <form action="{{.Link}}/merge" method="post">
  275. {{.CsrfTokenHtml}}
  276. <div class="field">
  277. <input type="text" name="merge_title_field" value="{{.Issue.PullRequest.GetDefaultSquashMessage}}">
  278. </div>
  279. <div class="field">
  280. <textarea name="merge_message_field" rows="5" placeholder="{{$.i18n.Tr "repo.editor.commit_message_desc"}}">{{.GetCommitMessages}}Reviewed-on: {{$.Issue.HTMLURL}}&#13;&#10;{{$approvers}}</textarea>
  281. </div>
  282. <button class="ui green button" type="submit" name="do" value="squash">
  283. {{$.i18n.Tr "repo.pulls.squash_merge_pull_request"}}
  284. </button>
  285. <button class="ui button merge-cancel">
  286. {{$.i18n.Tr "cancel"}}
  287. </button>
  288. </form>
  289. </div>
  290. {{end}}
  291. <div class="ui {{if $notAllOverridableChecksOk}}red{{else}}green{{end}} buttons merge-button">
  292. <button class="ui button" data-do="{{.MergeStyle}}">
  293. {{svg "octicon-git-merge"}}
  294. <span class="button-text">
  295. {{if eq .MergeStyle "merge"}}
  296. {{$.i18n.Tr "repo.pulls.merge_pull_request"}}
  297. {{end}}
  298. {{if eq .MergeStyle "rebase"}}
  299. {{$.i18n.Tr "repo.pulls.rebase_merge_pull_request"}}
  300. {{end}}
  301. {{if eq .MergeStyle "rebase-merge"}}
  302. {{$.i18n.Tr "repo.pulls.rebase_merge_commit_pull_request"}}
  303. {{end}}
  304. {{if eq .MergeStyle "squash"}}
  305. {{$.i18n.Tr "repo.pulls.squash_merge_pull_request"}}
  306. {{end}}
  307. </span>
  308. </button>
  309. <div class="ui dropdown icon button">
  310. <i class="dropdown icon"></i>
  311. <div class="menu">
  312. {{if $prUnit.PullRequestsConfig.AllowMerge}}
  313. <div class="item{{if eq .MergeStyle "merge"}} active selected{{end}}" data-do="merge">{{$.i18n.Tr "repo.pulls.merge_pull_request"}}</div>
  314. {{end}}
  315. {{if $prUnit.PullRequestsConfig.AllowRebase}}
  316. <div class="item{{if eq .MergeStyle "rebase"}} active selected{{end}}" data-do="rebase">{{$.i18n.Tr "repo.pulls.rebase_merge_pull_request"}}</div>
  317. {{end}}
  318. {{if $prUnit.PullRequestsConfig.AllowRebaseMerge}}
  319. <div class="item{{if eq .MergeStyle "rebase-merge"}} active selected{{end}}" data-do="rebase-merge">{{$.i18n.Tr "repo.pulls.rebase_merge_commit_pull_request"}}</div>
  320. {{end}}
  321. {{if $prUnit.PullRequestsConfig.AllowSquash}}
  322. <div class="item{{if eq .MergeStyle "squash"}} active selected{{end}}" data-do="squash">{{$.i18n.Tr "repo.pulls.squash_merge_pull_request"}}</div>
  323. {{end}}
  324. </div>
  325. </div>
  326. </div>
  327. {{else}}
  328. <div class="ui divider"></div>
  329. <div class="item text red">
  330. {{svg "octicon-x"}}
  331. {{$.i18n.Tr "repo.pulls.no_merge_desc"}}
  332. </div>
  333. <div class="item text grey">
  334. {{svg "octicon-info"}}
  335. {{$.i18n.Tr "repo.pulls.no_merge_helper"}}
  336. </div>
  337. {{end}}
  338. {{else}}
  339. <div class="ui divider"></div>
  340. <div class="item text grey">
  341. {{svg "octicon-info"}}
  342. {{$.i18n.Tr "repo.pulls.no_merge_access"}}
  343. </div>
  344. {{end}}
  345. {{end}}
  346. {{else}}
  347. {{/* Merge conflict without specific file. Suggest manual merge, only if all reviews and status checks OK. */}}
  348. {{if .IsBlockedByApprovals}}
  349. <div class="item text red">
  350. {{svg "octicon-x"}}
  351. {{$.i18n.Tr "repo.pulls.blocked_by_approvals" .GrantedApprovals .Issue.PullRequest.ProtectedBranch.RequiredApprovals}}
  352. </div>
  353. {{else if .IsBlockedByRejection}}
  354. <div class="item text red">
  355. {{svg "octicon-x"}}
  356. {{$.i18n.Tr "repo.pulls.blocked_by_rejection"}}
  357. </div>
  358. {{else if .IsBlockedByOutdatedBranch}}
  359. <div class="item text red">
  360. <i class="icon icon-octicon">{{svg "octicon-x"}}</i>
  361. {{$.i18n.Tr "repo.pulls.blocked_by_outdated_branch"}}
  362. </div>
  363. {{else if and .EnableStatusCheck (not .RequiredStatusCheckState.IsSuccess)}}
  364. <div class="item text red">
  365. {{svg "octicon-x"}}
  366. {{$.i18n.Tr "repo.pulls.required_status_check_failed"}}
  367. </div>
  368. {{else if and .RequireSigned (not .WillSign)}}
  369. <div class="item text red">
  370. {{svg "octicon-x"}}
  371. {{$.i18n.Tr "repo.pulls.require_signed_wont_sign"}}
  372. </div>
  373. {{else}}
  374. <div class="item text red">
  375. {{svg "octicon-x"}}
  376. {{$.i18n.Tr "repo.pulls.cannot_auto_merge_desc"}}
  377. </div>
  378. <div class="item text grey">
  379. {{svg "octicon-info"}}
  380. {{$.i18n.Tr "repo.pulls.cannot_auto_merge_helper"}}
  381. </div>
  382. {{end}}
  383. {{end}}
  384. {{if and (gt .Issue.PullRequest.CommitsBehind 0) (not .Issue.IsClosed) (not .Issue.PullRequest.IsChecking) (not .IsPullFilesConflicted) (not .IsPullRequestBroken) (not $canAutoMerge)}}
  385. <div class="item text grey">
  386. <i class="icon icon-octicon">{{svg "octicon-alert"}}</i>
  387. {{$.i18n.Tr "repo.pulls.outdated_with_base_branch"}}
  388. {{if .UpdateAllowed}}
  389. <form action="{{.Link}}/update" method="post" class="ui floating right">
  390. {{.CsrfTokenHtml}}
  391. <button class="ui compact button" data-do="update">
  392. <span class="ui text">{{$.i18n.Tr "repo.pulls.update_branch"}}</span>
  393. </button>
  394. </form>
  395. {{end}}
  396. </div>
  397. {{end}}
  398. </div>
  399. </div>
  400. </div>