maintain.html.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <?php
  2. /**
  3. * The maintain view file of repo 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 repo
  8. * @link https://www.zentao.net
  9. */
  10. namespace zin;
  11. jsVar('deleteConfirm', $lang->repo->notice->deleteConfirm);
  12. jsVar('defaultServer', empty($defaultServer) ? 0 : $defaultServer->id);
  13. $createItem = array('text' => $lang->repo->createAction, 'url' => createLink('repo', 'create'));
  14. $createRepoItem = array('text' => $lang->repo->createRepoAction, 'url' => createLink('repo', 'createRepo'));
  15. $batchCreateItem = array('text' => $lang->repo->batchCreate, 'url' => createLink('repo', 'import'));
  16. foreach($repoList as $repo)
  17. {
  18. $jobID = 0;
  19. $repo->exec = 'disabled';
  20. $repo->report = 'disabled';
  21. if(isset($sonarRepoList[$repo->id]))
  22. {
  23. $repo->exec = '';
  24. $repo->job = $sonarRepoList[$repo->id]->id;
  25. if(in_array($repo->job, $successJobs)) $repo->report = '';
  26. }
  27. $productNames = array();
  28. $productList = explode(',', str_replace(' ', '', $repo->product));
  29. foreach($productList as $productID)
  30. {
  31. if(!isset($products[$productID])) continue;
  32. $productNames[] = zget($products, $productID, $productID);
  33. }
  34. $repo->productNames = implode(',', $productNames);
  35. $projectNames = array();
  36. $projectList = explode(',', str_replace(' ', '', $repo->projects));
  37. foreach($projectList as $projectID)
  38. {
  39. if(!isset($projects[$projectID])) continue;
  40. $projectNames[] = zget($projects, $projectID, $projectID);
  41. }
  42. $repo->projectNames = implode(',', $projectNames);
  43. if(is_object($repo->lastSubmitTime)) $repo->lastSubmitTime = $repo->lastSubmitTime->time;
  44. }
  45. $config->repo->dtable->fieldList['name']['link'] = $this->createLink('repo', 'browse', "repoID={id}&branchID=&objectID={$objectID}");
  46. $config->repo->dtable->fieldList['actions']['list']['edit']['url'] = $this->createLink('repo', 'edit', "repoID={id}&objectID={$objectID}");
  47. if(empty($config->repo->maintain->showRepoPath))
  48. {
  49. unset($config->repo->dtable->fieldList['path']);
  50. $config->repo->dtable->fieldList['product']['width'] = '0.2';
  51. $config->repo->dtable->fieldList['scm']['width'] = '0.2';
  52. $config->repo->dtable->fieldList['lastSubmit']['width'] = '0.2';
  53. }
  54. /* Set 'repo-visit' action as one open method, so any user can use it. */
  55. if(empty($config->repo->maintain->disableVisit)) $config->logonMethods[] = 'repo.visit';
  56. $repos = initTableData($repoList, $config->repo->dtable->fieldList, $this->repo);
  57. $queryMenuLink = createLink('repo', 'maintain', "objectID=$objectID&orderBy=&recTotal={$pager->recTotal}&pageID={$pager->pageID}&type=bySearch&param={queryID}");
  58. /* Process data which the function initTableData() not provided. */
  59. foreach($repos as $repo)
  60. {
  61. if(!empty($repo->actions[0]['name']) && $repo->actions[0]['name'] != 'visit') break;
  62. /* Set the url and check status for visiting the repo. */
  63. $repo->actions[0]['disabled'] = strpos($repo->path, 'http') === false;
  64. $repo->actions[0]['url'] = $repo->path;
  65. if(in_array($repo->SCM, array('Gogs', 'Gitea')))
  66. {
  67. $resp = $this->loadModel('pipeline')->getByID((int)$repo->serviceHost);
  68. if(!empty($resp->url))
  69. {
  70. $repo->actions[0]['disabled'] = false;
  71. $repo->actions[0]['url'] = $resp->url . '/' . $repo->serviceProject;
  72. }
  73. }
  74. }
  75. \zin\featureBar
  76. (
  77. set::current('all'),
  78. set::queryMenuLinkCallback(array(function ($key) use ($queryMenuLink) {
  79. return str_replace('{queryID}', (string)$key, $queryMenuLink);
  80. })),
  81. li(searchToggle(set::module('repo'), set::open($type == 'bySearch')))
  82. );
  83. if($config->inCompose && empty($repoServers))
  84. {
  85. toolBar(hasPriv('repo', 'createRepo') && $serverPairs ? item(set($createRepoItem + array
  86. (
  87. 'icon' => 'plus',
  88. 'class' => 'btn primary'
  89. ))) : null);
  90. }
  91. else
  92. {
  93. toolBar(hasPriv('repo', 'createRepo') && $serverPairs ? item(set($createRepoItem + array
  94. (
  95. 'icon' => 'plus',
  96. 'class' => 'btn primary'
  97. ))) : null, !hasPriv('repo', 'create') && hasPriv('repo', 'import') && $serverPairs ? item(set($batchCreateItem + array
  98. (
  99. 'icon' => 'plus',
  100. 'class' => 'btn primary'
  101. ))) : null, !hasPriv('repo', 'import') && hasPriv('repo', 'create') ? item(set($createItem + array
  102. (
  103. 'icon' => 'plus',
  104. 'class' => 'btn primary'
  105. ))) : null, hasPriv('repo', 'import') && hasPriv('repo', 'create') ? btnGroup
  106. (
  107. btn(setClass('btn primary'), set::icon('plus'), set::url(createLink('repo', 'create')), $lang->repo->createAction),
  108. $serverPairs ? dropDown
  109. (
  110. btn(setClass('btn primary dropdown-toggle'),
  111. setStyle(array('padding' => '6px', 'border-radius' => '0 2px 2px 0'))),
  112. set::placement('bottom-end'),
  113. set::items(array($createItem, $batchCreateItem))
  114. ) : null
  115. ) : null);
  116. }
  117. dtable
  118. (
  119. set::cols($config->repo->dtable->fieldList),
  120. set::data($repos),
  121. set::sortLink(createLink('repo', 'maintain', "objectID=$objectID&orderBy={name}_{sortType}&recTotal={$pager->recTotal}&pageID={$pager->pageID}")),
  122. set::orderBy($orderBy),
  123. set::footPager(usePager()),
  124. set::actionItemCreator(jsRaw('window.renderActions'))
  125. );