* Finish task#45500

This commit is contained in:
zenggang
2021-12-07 08:15:04 +00:00
parent 3d1d34e383
commit b4685be3de
6 changed files with 125 additions and 0 deletions
+46
View File
@@ -712,6 +712,52 @@ class gitlab extends control
die(js::alert($reponse->message));
}
/**
* Browse gitlab branch.
*
* @param int $gitlabID
* @param int $projectID
* @param string $orderBy
* @param int $recTotal
* @param int $recPerPage
* @param int $pageID
* @access public
* @return void
*/
public function browseBranch($gitlabID, $projectID, $orderBy = 'name_desc', $recTotal = 0, $recPerPage = 15, $pageID = 1)
{
$branchList = array();
$result = $this->gitlab->apiGetBranches($gitlabID, $projectID);
foreach($result as $gitlabBranch)
{
$branch = new stdClass();
$branch->name = $gitlabBranch->name;
$branch->lastCommitter = $gitlabBranch->commit->committer_name;
$branch->lastCommittedDate = date('Y-m-d H:i:s', strtotime($gitlabBranch->commit->committed_date));
$branchList[] = $branch;
}
/* Data sort. */
list($order, $sort) = explode('_', $orderBy);
array_multisort(array_column($branchList, $order), $sort == 'desc' ? SORT_DESC : SORT_ASC, $branchList);
/* Pager. */
$this->app->loadClass('pager', $static = true);
$recTotal = count($branchList);
$pager = new pager($recTotal, $recPerPage, $pageID);
$branchList = array_chunk($branchList, $pager->recPerPage);
$this->view->gitlab = $this->gitlab->getByID($gitlabID);
$this->view->pager = $pager;
$this->view->title = $this->lang->gitlab->common . $this->lang->colon . $this->lang->gitlab->browseBranch;
$this->view->gitlabID = $gitlabID;
$this->view->projectID = $projectID;
$this->view->gitlabBranchList = empty($branchList) ? $branchList: $branchList[$pageID - 1];
$this->view->orderBy = $orderBy;
$this->display();
}
/**
* Import gitlab issue to zentaopms.
*
+6
View File
@@ -30,6 +30,7 @@ $lang->gitlab->gitlabProject = "GitLab Project";
$lang->gitlab->browseProject = "GitLab Project List";
$lang->gitlab->browseUser = "User List";
$lang->gitlab->browseGroup = "Group List";
$lang->gitlab->browseBranch = "Branch List";
$lang->gitlab->gitlabIssue = "GitLab Issue";
$lang->gitlab->zentaoProduct = 'Zentao Product';
$lang->gitlab->objectType = 'Type'; // task, bug, story
@@ -43,6 +44,7 @@ $lang->gitlab->deleteGroup = 'Delete group';
$lang->gitlab->createUser = 'Create user';
$lang->gitlab->editUser = 'Edit user';
$lang->gitlab->deleteUser = 'Delete user';
$lang->gitlab->createBranch = 'Add branch';
$lang->gitlab->manageGroupMembers = 'Manage group member';
$lang->gitlab->createWebhook = 'Create Webhook';
@@ -58,6 +60,10 @@ $lang->gitlab->desc = 'Description';
$lang->gitlab->tokenFirst = 'When the Token is not empty, the Token will be used first';
$lang->gitlab->tips = 'When using a password, please disable the "Prevent cross-site request forgery" option in the GitLab global security settings.';
$lang->gitlab->branchName = 'Branch Name';
$lang->gitlab->branchLastCommitter = 'Last Committer';
$lang->gitlab->branchLastCommittedDate = 'Last Committed Date';
$lang->gitlab->placeholder = new stdclass;
$lang->gitlab->placeholder->name = '';
$lang->gitlab->placeholder->url = "Please fill in the access address of the GitLab Server homepage, as: https://gitlab.zentao.net.";
+6
View File
@@ -30,6 +30,7 @@ $lang->gitlab->gitlabProject = "{$lang->gitlab->common}项目";
$lang->gitlab->browseProject = "{$lang->gitlab->common}项目列表";
$lang->gitlab->browseUser = "用户列表";
$lang->gitlab->browseGroup = "群组列表";
$lang->gitlab->browseBranch = "分支列表";
$lang->gitlab->gitlabIssue = "{$lang->gitlab->common} issue";
$lang->gitlab->zentaoProduct = '禅道产品';
$lang->gitlab->objectType = '类型'; // task, bug, story
@@ -43,6 +44,7 @@ $lang->gitlab->deleteGroup = '删除群组';
$lang->gitlab->createUser = '添加用户';
$lang->gitlab->editUser = '编辑用户';
$lang->gitlab->deleteUser = '删除用户';
$lang->gitlab->createBranch = '添加分支';
$lang->gitlab->manageGroupMembers = '群组成员管理';
$lang->gitlab->createWebhook = '创建Webhook';
@@ -58,6 +60,10 @@ $lang->gitlab->desc = '描述';
$lang->gitlab->tokenFirst = 'Token不为空时,优先使用Token。';
$lang->gitlab->tips = '使用密码时,请在GitLab全局安全设置中禁用"防止跨站点请求伪造"选项。';
$lang->gitlab->branchName = '分支名';
$lang->gitlab->branchLastCommitter = '最后提交';
$lang->gitlab->branchLastCommittedDate = '最后修改时间';
$lang->gitlab->placeholder = new stdclass;
$lang->gitlab->placeholder->name = '';
$lang->gitlab->placeholder->url = "请填写GitLab Server首页的访问地址,如:https://gitlab.zentao.net。";
+64
View File
@@ -0,0 +1,64 @@
<?php
/**
* The browse view file of gitlab module of ZenTaoPMS.
*
* @copyright Copyright 2009-2017 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
* @license ZPL (http://zpl.pub/page/zplv12.html)
* @author Gang Liu <liugang@cnezsoft.com>
* @package gitlab
* @version $Id$
* @link http://www.zentao.net
*/
?>
<?php include '../../common/view/header.html.php';?>
<?php js::set('vars', "keyword=%s&orderBy=id_desc&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID=1")?>
<?php js::set('gitlabID', $gitlabID)?>
<div id="mainMenu" class="clearfix">
<div class='pull-left'>
<?php echo html::backButton('<i class="icon icon-back icon-sm"></i> ' . $lang->goback, '', 'btn btn-secondary');?>
</div>
<div class="btn-toolbar pull-right">
<?php if(common::hasPriv('gitlab', 'createBranch')) common::printLink('gitlab', 'createBranch', "gitlabID=$gitlabID", "<i class='icon icon-plus'></i> " . $lang->gitlab->createBranch, '', "class='btn btn-primary'");?>
</div>
</div>
<?php if(empty($gitlabBranchList)):?>
<div class="table-empty-tip">
<p>
<span class="text-muted"><?php echo $lang->noData;?></span>
<?php if(empty($keyword) and common::hasPriv('gitlab', 'createBranch')):?>
<?php echo html::a($this->createLink('gitlab', 'createBranch', "gitlabID=$gitlabID"), "<i class='icon icon-plus'></i> " . $lang->gitlab->createBranch, '', "class='btn btn-info'");?>
<?php endif;?>
</p>
</div>
<?php else:?>
<div id='mainContent' class='main-row'>
<form class='main-table' id='ajaxForm' method='post'>
<table id='gitlabBranchList' class='table has-sort-head table-fixed'>
<?php $vars = "gitlabID={$gitlabID}&projectID={$projectID}&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}";?>
<thead>
<tr>
<th class='c-name text-left'><?php common::printOrderLink('name', $orderBy, $vars, $lang->gitlab->branchName);?></th>
<th class='text-left'><?php echo $lang->gitlab->branchLastCommitter;?></th>
<th class='text-left'><?php common::printOrderLink('lastCommittedDate', $orderBy, $vars, $lang->gitlab->branchLastCommittedDate);?></th>
<th class='c-actions-4'><?php echo $lang->actions;?></th>
</tr>
</thead>
<tbody>
<?php foreach ($gitlabBranchList as $id => $gitlabBranch): ?>
<tr class='text'>
<td class='text-c-name' title='<?php echo $gitlabBranch->name;?>'><?php echo $gitlabBranch->name;?></td>
<td class='text'><?php echo $gitlabBranch->lastCommitter;?></td>
<td class='text'><?php echo $gitlabBranch->lastCommittedDate?></td>
<td class='c-actions text-left'>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<?php if($gitlabBranchList):?>
<div class='table-footer'><?php $pager->show('right', 'pagerjs');?></div>
<?php endif;?>
</form>
</div>
<?php endif;?>
<?php include '../../common/view/footer.html.php';?>
@@ -67,6 +67,7 @@
<td class='text' title='<?php echo substr($gitlabProject->last_activity_at, 0, 10);?>'><?php echo substr($gitlabProject->last_activity_at, 0, 10);?></td>
<td class='c-actions text-left'>
<?php
common::printLink('gitlab', 'browseBranch', "gitlabID=$gitlabID&projectID=$gitlabProject->id", "<i class='icon icon-treemap'></i> ", '', "title={$lang->gitlab->browseBranch} class='btn btn-primary'");
common::printLink('gitlab', 'editProject', "gitlabID=$gitlabID&projectID=$gitlabProject->id", "<i class='icon icon-edit'></i> ", '', "title={$lang->gitlab->project->edit} class='btn btn-primary'");
if(common::hasPriv('gitlab', 'delete')) echo html::a($this->createLink('gitlab', 'deleteProject', "gitlabID=$gitlabID&projectID=$gitlabProject->id"), '<i class="icon-trash"></i>', 'hiddenwin', "title='{$lang->gitlab->deleteProject}' class='btn'");
?>
+2
View File
@@ -1248,6 +1248,7 @@ $lang->resource->gitlab->deleteUser = 'deleteUser';
$lang->resource->gitlab->webhook = 'webhook';
$lang->resource->gitlab->createWebhook = 'createWebhook';
$lang->resource->gitlab->manageProjectMembers = 'manageProjectMembers';
$lang->resource->gitlab->browseBranch = 'browseBranch';
$lang->gitlab->methodOrder[5] = 'browse';
$lang->gitlab->methodOrder[10] = 'create';
@@ -1272,6 +1273,7 @@ $lang->gitlab->methodOrder[105] = 'deleteUser';
$lang->gitlab->methodOrder[110] = 'webhook';
$lang->gitlab->methodOrder[115] = 'createWebhook';
$lang->gitlab->methodOrder[120] = 'manageProjectMembers';
$lang->gitlab->methodOrder[125] = 'browseBranch';
/* merge request. */
$lang->resource->mr = new stdclass();