view.html.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <?php
  2. /**
  3. * The view file of mr module of ZenTaoPMS.
  4. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  5. * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  6. * @author Zeng Gang<zenggang@easycorp.ltd>
  7. * @package mr
  8. * @link https://www.zentao.net
  9. */
  10. namespace zin;
  11. $app->loadLang('productplan');
  12. $module = $app->tab == 'devops' ? 'repo' : $app->tab;
  13. dropmenu
  14. (
  15. set::module($module),
  16. set::tab($module),
  17. set::url(createLink($module, 'ajaxGetDropMenu', "objectID=$objectID&module={$app->rawModule}&method={$app->rawMethod}"))
  18. );
  19. include 'header.html.php';
  20. $hasNoChange = $MR->synced && empty($rawMR->changes_count) ? true : false;
  21. $hasConflict = $MR->synced === '1' ? $rawMR->has_conflicts : !$MR->hasNoConflict;
  22. $sourceDisabled = ($MR->status == 'merged' && $MR->removeSourceBranch == '1') ? 'disabled' : '';
  23. $branchPath = $sourceProject->path_with_namespace . '-' . $MR->sourceBranch;
  24. $mergeStatus = !empty($rawMR->merge_status) ? $rawMR->merge_status : $MR->mergeStatus;
  25. if($MR->compileID)
  26. {
  27. $job = tableData
  28. (
  29. item
  30. (
  31. set::name($lang->job->common),
  32. $compile->name
  33. ),
  34. item
  35. (
  36. set::name($lang->compile->atTime),
  37. $compile->createdDate
  38. ),
  39. !empty($MR->jobID) ? item
  40. (
  41. set::name($lang->compile->result),
  42. zget($lang->compile->statusList, $compile->status),
  43. in_array($compile->status, array('success', 'failure')) ? h::a
  44. (
  45. setClass('ml-1'),
  46. set::href($this->createLink('job', 'view', "jobID={$MR->jobID}&compileID={$compile->id}")),
  47. set('data-toggle', 'modal'),
  48. icon('search'),
  49. $lang->compile->logs
  50. ) : h::a
  51. (
  52. setClass('ml-1 ajax-submit'),
  53. set::href(helper::createLink('mr', 'ajaxSyncCompile', "compileID={$compile->id}")),
  54. set::hint($lang->refresh),
  55. icon('refresh'),
  56. $lang->refresh
  57. )
  58. ) : null
  59. );
  60. }
  61. elseif($MR->needCI)
  62. {
  63. $compileUrl = $this->createLink('job', 'view', "jobID={$MR->jobID}");
  64. $job = div
  65. (
  66. h::a
  67. (
  68. set::href($compileUrl),
  69. set::target('_blank'),
  70. $lang->compile->statusList[$MR->compileStatus]
  71. )
  72. );
  73. }
  74. else
  75. {
  76. $job = div
  77. (
  78. setClass('text-center'),
  79. $lang->mr->noCompileJob
  80. );
  81. }
  82. detailHeader
  83. (
  84. to::title
  85. (
  86. entityLabel
  87. (
  88. set::entityID($MR->id),
  89. set::level(1),
  90. set::text($MR->title)
  91. ),
  92. h::span
  93. (
  94. setClass('label gray-pale size-lg'),
  95. h::a
  96. (
  97. setClass('text-primary'),
  98. set::href($rawMR->web_url),
  99. set::target('_blank'),
  100. $lang->mr->viewInGit
  101. )
  102. )
  103. )
  104. );
  105. panel
  106. (
  107. div
  108. (
  109. set::id('mrMenu'),
  110. $headers
  111. ),
  112. div
  113. (
  114. setClass('flex items-center mt-4'),
  115. cell
  116. (
  117. setClass('mr-4 mr-view-cell'),
  118. set::grow(1),
  119. set::align('flex-start'),
  120. cell
  121. (
  122. setClass('cell mb-2'),
  123. h::span
  124. (
  125. setClass('font-bold mt-2 mb-2 inline-block'),
  126. setID('mrBranches'),
  127. $lang->mr->from,
  128. h::a
  129. (
  130. setClass('font-normal ml-2 mr-2'),
  131. set::href($sourceBranch),
  132. set::target('_blank'),
  133. set::disabled($sourceDisabled),
  134. $sourceProject->name_with_namespace . ':' . $MR->sourceBranch
  135. ),
  136. $lang->mr->to,
  137. h::a
  138. (
  139. setClass('font-normal ml-2 mr-2'),
  140. set::href($targetBranch),
  141. set::target('_blank'),
  142. $targetProject->name_with_namespace . ':' . $MR->targetBranch
  143. )
  144. ),
  145. tableData
  146. (
  147. item
  148. (
  149. set::trClass('mr-status-tr'),
  150. set::name($lang->mr->status),
  151. (!empty($MR->syncError) && $MR->synced === '0') ? h::span
  152. (
  153. setClass('danger'),
  154. $MR->status
  155. ) : span
  156. (
  157. setClass("status-{$MR->status}"),
  158. zget($lang->mr->statusList, (string)$MR->status)
  159. )
  160. ),
  161. item
  162. (
  163. set::name($lang->mr->reviewer),
  164. $reviewer ? zget($reviewer, 'realname', $MR->assignee) : $MR->assignee
  165. ),
  166. $MR->status == 'opened' ? item
  167. (
  168. set::name($lang->mr->mergeStatus),
  169. $hasNoChange || $hasConflict ? span
  170. (
  171. setClass('status-cannot_be_merged'),
  172. $lang->mr->cantMerge
  173. ) : span
  174. (
  175. setClass("status-{$mergeStatus}"),
  176. zget($lang->mr->mergeStatusList, $mergeStatus)
  177. ),
  178. $hasNoChange || $hasConflict ? span
  179. (
  180. setClass('ml-2'),
  181. '(' . ($hasConflict ? $lang->mr->hasConflicts : $lang->mr->hasNoChanges) . ')'
  182. ) : null
  183. ) : null,
  184. item
  185. (
  186. set::name($lang->mr->description),
  187. !empty($MR->description) ? html(nl2br($MR->description)) : $lang->noData
  188. )
  189. )
  190. ),
  191. ($MR->synced && $rawMR->state == 'opened' && $hasConflict) ? cell
  192. (
  193. setClass('cell mb-2'),
  194. html(sprintf($lang->mr->commandDocument, $sourceProject->http_url_to_repo, $MR->sourceBranch, $branchPath, $MR->targetBranch, $branchPath, $MR->targetBranch))
  195. ) : null,
  196. cell
  197. (
  198. setClass('cell cell-history'),
  199. history
  200. (
  201. set::objectID($MR->id),
  202. set::commentUrl(createLink('action', 'comment', array('objectType' => $app->rawModule, 'objectID' => $MR->id)))
  203. )
  204. )
  205. ),
  206. cell
  207. (
  208. setClass('cell'),
  209. setID('mrJob'),
  210. set::width('30%'),
  211. set::align('baseline'),
  212. div
  213. (
  214. setClass('text-lg font-bold flex justify-between'),
  215. $lang->mr->jobID,
  216. div
  217. (
  218. setClass('text-base font-thin'),
  219. $hasNewCommit ? span
  220. (
  221. setClass('mr-2'),
  222. $lang->mr->branchUpdateTip
  223. ) : null,
  224. !empty($MR->jobID) && hasPriv('job', 'exec') ? btn
  225. (
  226. setClass('label primary size-lg ajax-submit'),
  227. set::url(helper::createLink('mr', 'ajaxExecJob', "MRID={$MR->id}&jobID={$MR->jobID}")),
  228. set::hint($lang->mr->execJobTip),
  229. $lang->mr->execJob
  230. ) : null
  231. )
  232. ),
  233. $job
  234. )
  235. )
  236. );
  237. h::js("$.get($.createLink('mr', 'ajaxLinkObjects', 'MRID={$MR->id}'));");
  238. include 'actions.html.php';