* Finish task #45491.
This commit is contained in:
@@ -121,6 +121,7 @@ $lang->action->objectTypes['mr'] = 'Merge Request';
|
||||
$lang->action->objectTypes['gitlabproject'] = 'GitLab Project';
|
||||
$lang->action->objectTypes['gitlabuser'] = 'GitLab User';
|
||||
$lang->action->objectTypes['gitlabgroup'] = 'GitLab Group';
|
||||
$lang->action->objectTypes['gitlabbranch'] = 'GitLab Branch';
|
||||
|
||||
/* Used to describe operation history. */
|
||||
$lang->action->desc = new stdclass();
|
||||
|
||||
@@ -121,6 +121,7 @@ $lang->action->objectTypes['mr'] = '合并请求';
|
||||
$lang->action->objectTypes['gitlabproject'] = 'GitLab项目';
|
||||
$lang->action->objectTypes['gitlabuser'] = 'GitLab用户';
|
||||
$lang->action->objectTypes['gitlabgroup'] = 'GitLab群组';
|
||||
$lang->action->objectTypes['gitlabbranch'] = 'GitLab分支';
|
||||
|
||||
/* 用来描述操作历史记录。*/
|
||||
$lang->action->desc = new stdclass();
|
||||
|
||||
@@ -91,6 +91,7 @@ $lang->block->refresh = 'Refresh';
|
||||
$lang->block->nbsp = ' ';
|
||||
$lang->block->hidden = 'Hide';
|
||||
$lang->block->dynamicInfo = "<span class='timeline-tag'>%s</span> <span class='timeline-text'>%s <em>%s</em> %s <a href='%s' title='%s'>%s</a></span>";
|
||||
$lang->block->noLinkDynamic = "<span class='timeline-tag'>%s</span> <span class='timeline-text' title='%s'>%s <em>%s</em> %s %s</span>";
|
||||
$lang->block->cannotPlaceInLeft = 'Cannot place the block at left side.';
|
||||
$lang->block->cannotPlaceInRight = 'Cannot place the block at right side.';
|
||||
|
||||
|
||||
@@ -91,6 +91,7 @@ $lang->block->refresh = '刷新';
|
||||
$lang->block->nbsp = '';
|
||||
$lang->block->hidden = '隐藏';
|
||||
$lang->block->dynamicInfo = "<span class='timeline-tag'>%s</span> <span class='timeline-text'>%s <em>%s</em> %s <a href='%s' title='%s'>%s</a></span>";
|
||||
$lang->block->noLinkDynamic = "<span class='timeline-tag'>%s</span> <span class='timeline-text' title='%s'>%s <em>%s</em> %s %s</span>";
|
||||
$lang->block->cannotPlaceInLeft = '此区块无法放置在左侧。';
|
||||
$lang->block->cannotPlaceInRight = '此区块无法放置在右侧。';
|
||||
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
if($action->action == 'login' or $action->action == 'logout') $action->objectName = $action->objectLabel = '';
|
||||
$class = $action->major ? "class='active'" : '';
|
||||
echo "<li $class><div>";
|
||||
printf($lang->block->dynamicInfo, $action->date, $user, $action->actionLabel, $action->objectLabel, $action->objectLink, $action->objectName, $action->objectName);
|
||||
if($action->objectLink) printf($lang->block->dynamicInfo, $action->date, $user, $action->actionLabel, $action->objectLabel, $action->objectLink, $action->objectName, $action->objectName);
|
||||
if(!$action->objectLink) printf($lang->block->noLinkDynamic, $action->date, $action->objectName, $user, $action->actionLabel, $action->objectLabel, $action->objectName);
|
||||
echo "</div></li>";
|
||||
$i++;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,9 @@ $config->gitlab->create->requiredFields = 'name,url,token';
|
||||
$config->gitlab->edit = new stdclass;
|
||||
$config->gitlab->edit->requiredFields = 'name,url,token';
|
||||
|
||||
$config->gitlab->createbranch = new stdclass;
|
||||
$config->gitlab->createbranch->requiredFields = 'branch,ref';
|
||||
|
||||
$config->gitlab->labelPattern = new stdclass;
|
||||
$config->gitlab->labelPattern->task = '/^zentao_task\/\d+$/';
|
||||
$config->gitlab->labelPattern->bug = '/^zentao_bug\/\d+$/';
|
||||
|
||||
@@ -712,6 +712,39 @@ class gitlab extends control
|
||||
die(js::alert($reponse->message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creat a gitlab branch.
|
||||
*
|
||||
* @param int $gitlabID
|
||||
* @param int $projectID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function createBranch($gitlabID, $projectID)
|
||||
{
|
||||
if($_POST)
|
||||
{
|
||||
$this->gitlab->createBranch($gitlabID, $projectID);
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
|
||||
$locate = $this->session->gitlabBranchList ? $this->session->gitlabBranchList : inlink('browseBranch', "gitlibID=$gitlabID&projectID=$projectID");
|
||||
return $this->send(array('result' => 'success', 'message' => $this->lang->gitlab->createSuccess, 'locate' => $locate));
|
||||
}
|
||||
|
||||
/* Get branches by api. */
|
||||
$branches = $this->gitlab->apiGetBranches($gitlabID, $projectID);
|
||||
if(!is_array($branches)) $branches= array();
|
||||
|
||||
$branchPairs = array();
|
||||
foreach($branches as $branch) $branchPairs[$branch->name] = $branch->name;
|
||||
|
||||
$this->view->title = $this->lang->gitlab->common . $this->lang->colon . $this->lang->gitlab->createBranch;
|
||||
$this->view->gitlabID = $gitlabID;
|
||||
$this->view->projectID = $projectID;
|
||||
$this->view->branchPairs = $branchPairs;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Import gitlab issue to zentaopms.
|
||||
*
|
||||
|
||||
@@ -37,6 +37,7 @@ $lang->gitlab->manageProjectMembers = 'Manage project member';
|
||||
$lang->gitlab->createProject = 'Create GitLab project';
|
||||
$lang->gitlab->editProject = 'Eidt GitLab project';
|
||||
$lang->gitlab->deleteProject = 'Delete GitLab project';
|
||||
$lang->gitlab->createBranch = 'Create Branch';
|
||||
$lang->gitlab->createGroup = 'Create group';
|
||||
$lang->gitlab->editGroup = 'Edit group';
|
||||
$lang->gitlab->deleteGroup = 'Delete group';
|
||||
@@ -53,10 +54,12 @@ $lang->gitlab->token = 'Token';
|
||||
$lang->gitlab->defaultProject = 'Default Project';
|
||||
$lang->gitlab->private = 'MD5 Verify';
|
||||
|
||||
$lang->gitlab->lblCreate = 'Create GitLab Server';
|
||||
$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->lblCreate = 'Create GitLab Server';
|
||||
$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->emptyError = "cannot be empty";
|
||||
$lang->gitlab->createSuccess = "Create success";
|
||||
|
||||
$lang->gitlab->placeholder = new stdclass;
|
||||
$lang->gitlab->placeholder->name = '';
|
||||
@@ -82,11 +85,13 @@ $lang->gitlab->apiError[0] = 'internal is not allowed in a private group.';
|
||||
$lang->gitlab->apiError[1] = 'public is not allowed in a private group.';
|
||||
$lang->gitlab->apiError[2] = 'is too short (minimum is 8 characters)';
|
||||
$lang->gitlab->apiError[3] = "can contain only letters, digits, '_', '-' and '.'. Cannot start with '-', end in '.git' or end in '.atom'";
|
||||
$lang->gitlab->apiError[4] = 'Branch already exists';
|
||||
|
||||
$lang->gitlab->errorLang[0] = 'You cannot set Internal as its Visibility Level, if it is private in GitLab.';
|
||||
$lang->gitlab->errorLang[1] = 'You cannot set Public as its Visibility Level, if it is private in GitLab.';
|
||||
$lang->gitlab->errorLang[2] = 'Password is too short (minimum is 8 characters)';
|
||||
$lang->gitlab->errorLang[3] = 'It should contain only letters, digits, underscore, hyphen and period. It should not start with hypen, or end with .git or .atom.';
|
||||
$lang->gitlab->errorLang[4] = 'Branch already exists.';
|
||||
|
||||
$lang->gitlab->project = new stdclass;
|
||||
$lang->gitlab->project->id = "Project ID";
|
||||
@@ -171,3 +176,8 @@ $lang->gitlab->group->memberName = 'Account';
|
||||
$lang->gitlab->group->memberAccessLevel = 'Access Level';
|
||||
$lang->gitlab->group->memberExpiresAt = 'Expiration time';
|
||||
$lang->gitlab->group->repeatError = "Group members cannot be added repeatedly";
|
||||
|
||||
$lang->gitlab->branch = new stdclass();
|
||||
$lang->gitlab->branch->name = 'Branch Name';
|
||||
$lang->gitlab->branch->from = 'Create from';
|
||||
$lang->gitlab->branch->create = 'Create';
|
||||
|
||||
@@ -37,6 +37,7 @@ $lang->gitlab->manageProjectMembers = '项目成员管理';
|
||||
$lang->gitlab->createProject = '添加GitLab项目';
|
||||
$lang->gitlab->editProject = '编辑GitLab项目';
|
||||
$lang->gitlab->deleteProject = '删除GitLab项目';
|
||||
$lang->gitlab->createBranch = '添加分支';
|
||||
$lang->gitlab->createGroup = '添加群组';
|
||||
$lang->gitlab->editGroup = '编辑群组';
|
||||
$lang->gitlab->deleteGroup = '删除群组';
|
||||
@@ -53,10 +54,12 @@ $lang->gitlab->token = 'Token';
|
||||
$lang->gitlab->defaultProject = '默认项目';
|
||||
$lang->gitlab->private = 'MD5验证';
|
||||
|
||||
$lang->gitlab->lblCreate = '添加GitLab服务器';
|
||||
$lang->gitlab->desc = '描述';
|
||||
$lang->gitlab->tokenFirst = 'Token不为空时,优先使用Token。';
|
||||
$lang->gitlab->tips = '使用密码时,请在GitLab全局安全设置中禁用"防止跨站点请求伪造"选项。';
|
||||
$lang->gitlab->lblCreate = '添加GitLab服务器';
|
||||
$lang->gitlab->desc = '描述';
|
||||
$lang->gitlab->tokenFirst = 'Token不为空时,优先使用Token。';
|
||||
$lang->gitlab->tips = '使用密码时,请在GitLab全局安全设置中禁用"防止跨站点请求伪造"选项。';
|
||||
$lang->gitlab->emptyError = "不能为空";
|
||||
$lang->gitlab->createSuccess = "创建成功";
|
||||
|
||||
$lang->gitlab->placeholder = new stdclass;
|
||||
$lang->gitlab->placeholder->name = '';
|
||||
@@ -82,11 +85,13 @@ $lang->gitlab->apiError[0] = 'internal is not allowed in a private group.';
|
||||
$lang->gitlab->apiError[1] = 'public is not allowed in a private group.';
|
||||
$lang->gitlab->apiError[2] = 'is too short (minimum is 8 characters)';
|
||||
$lang->gitlab->apiError[3] = "can contain only letters, digits, '_', '-' and '.'. Cannot start with '-', end in '.git' or end in '.atom'";
|
||||
$lang->gitlab->apiError[4] = 'Branch already exists';
|
||||
|
||||
$lang->gitlab->errorLang[0] = '私有分组的项目,可见性级别不能设为内部。';
|
||||
$lang->gitlab->errorLang[1] = '私有分组的项目,可见性级别不能设为公开。';
|
||||
$lang->gitlab->errorLang[2] = '密码太短(最少8个字符)';
|
||||
$lang->gitlab->errorLang[3] = "只能包含字母、数字、'.'-'和'.'。不能以'-'开头、以'.git'结尾或以'.atom'结尾。";
|
||||
$lang->gitlab->errorLang[4] = '分支名已存在。';
|
||||
|
||||
$lang->gitlab->project = new stdclass;
|
||||
$lang->gitlab->project->id = "项目ID";
|
||||
@@ -171,3 +176,8 @@ $lang->gitlab->group->memberName = '账号';
|
||||
$lang->gitlab->group->memberAccessLevel = '角色权限';
|
||||
$lang->gitlab->group->memberExpiresAt = '过期时间';
|
||||
$lang->gitlab->group->repeatError = "群组成员不能重复添加";
|
||||
|
||||
$lang->gitlab->branch = new stdclass();
|
||||
$lang->gitlab->branch->name = '分支名';
|
||||
$lang->gitlab->branch->from = '创建自';
|
||||
$lang->gitlab->branch->create = '创建';
|
||||
|
||||
@@ -896,6 +896,24 @@ class gitlabModel extends model
|
||||
return json_decode(commonModel::http($url, array(), $options = array(CURLOPT_CUSTOMREQUEST => 'DELETE')));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a gitab user by api.
|
||||
*
|
||||
* @param int $gitlabID
|
||||
* @param int $projectID
|
||||
* @param object $branch
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function apiCreateBranch($gitlabID, $projectID, $branch)
|
||||
{
|
||||
if(empty($branch->branch) or empty($branch->ref)) return false;
|
||||
|
||||
$apiRoot = $this->getApiRoot($gitlabID);
|
||||
$url = sprintf($apiRoot, "/projects/{$projectID}/repository/branches");
|
||||
return json_decode(commonModel::http($url, $branch));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get single project by API.
|
||||
*
|
||||
@@ -2236,6 +2254,33 @@ class gitlabModel extends model
|
||||
return $this->apiErrorHandling($reponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a gitlab branch.
|
||||
*
|
||||
* @param int $gitlabID
|
||||
* @param int $projectID
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function createBranch($gitlabID, $projectID)
|
||||
{
|
||||
$branch = fixer::input('post')->get();
|
||||
|
||||
if(empty($branch->branch)) dao::$errors['branch'][] = $this->lang->gitlab->branch->name . $this->lang->gitlab->emptyError;
|
||||
if(empty($branch->ref)) dao::$errors['ref'][] = $this->lang->gitlab->branch->from . $this->lang->gitlab->emptyError;
|
||||
if(dao::isError()) return false;
|
||||
|
||||
$reponse = $this->apiCreateBranch($gitlabID, $projectID, $branch);
|
||||
|
||||
if(!empty($reponse->name))
|
||||
{
|
||||
$this->loadModel('action')->create('gitlabbranch', 0, 'created', '', $reponse->name);
|
||||
return true;
|
||||
}
|
||||
|
||||
return $this->apiErrorHandling($reponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* Api error handling.
|
||||
*
|
||||
|
||||
44
module/gitlab/view/createbranch.html.php
Normal file
44
module/gitlab/view/createbranch.html.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* The create branch view file of gitlab module of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2021 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
|
||||
* @license ZPL (http://zpl.pub/page/zplv12.html)
|
||||
* @author Yuchun Li <liyuchun@zcorp.ltd>
|
||||
* @package gitlab
|
||||
* @version $Id$
|
||||
* @link https://www.zentao.net
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<div id='mainContent' class='main-row'>
|
||||
<div class='main-col main-content'>
|
||||
<div class='center-block'>
|
||||
<div class='main-header'>
|
||||
<h2><?php echo $lang->gitlab->createBranch;?></h2>
|
||||
</div>
|
||||
<form id='gitlabForm' method='post' class='form-ajax'>
|
||||
<table class='table table-form'>
|
||||
<tr>
|
||||
<th><?php echo $lang->gitlab->branch->name;?></th>
|
||||
<td><?php echo html::input('branch', '', "class='form-control' placeholder='{$lang->gitlab->branch->name}'");?></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->gitlab->branch->from;?></th>
|
||||
<td><?php echo html::select('ref', $branchPairs, '', "class='form-control chosen'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td class='text-center form-actions'>
|
||||
<?php echo html::submitButton($lang->gitlab->branch->create);?>
|
||||
<?php $backLink = $this->session->gitlabBranchList ? $this->session->gitlabBranchList : inlink('browseBranch', "gitlibID=$gitlabID&projectID=$projectID");?>
|
||||
<?php if(!isonlybody()) echo html::a($backLink, $lang->goback, '', 'class="btn btn-wide"');?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
@@ -1245,6 +1245,7 @@ $lang->resource->gitlab->browseUser = 'browseUser';
|
||||
$lang->resource->gitlab->createUser = 'createUser';
|
||||
$lang->resource->gitlab->editUser = 'editUser';
|
||||
$lang->resource->gitlab->deleteUser = 'deleteUser';
|
||||
$lang->resource->gitlab->createBranch = 'createBranch';
|
||||
$lang->resource->gitlab->webhook = 'webhook';
|
||||
$lang->resource->gitlab->createWebhook = 'createWebhook';
|
||||
$lang->resource->gitlab->manageProjectMembers = 'manageProjectMembers';
|
||||
|
||||
@@ -357,6 +357,7 @@ class repo extends control
|
||||
|
||||
session_start();
|
||||
$this->session->set('revisionList', $this->app->getURI(true));
|
||||
$this->session->set('gitlabBranchList', $this->app->getURI(true));
|
||||
session_write_close();
|
||||
|
||||
/* Get repo and synchronous commit. */
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
<div class="btn-toolbar pull-right">
|
||||
<span class='last-sync-time'><?php echo $lang->repo->notice->lastSyncTime . $cacheTime?></span>
|
||||
<?php echo html::a($this->repo->createLink('browse', "repoID=$repoID&branchID=$base64BranchID&objectID=$objectID&path=" . $this->repo->encodePath($path) . "&revision=$revision&refresh=1"), "<i class='icon icon-refresh'></i> " . $lang->refresh, '', "class='btn btn-primary' data-app={$app->tab}");?>
|
||||
<?php if($repo->SCM == 'Gitlab' and common::hasPriv('gitlab', 'createBranch')) echo html::a($this->createLink('gitlab', 'createBranch', "gitlabID={$repo->gitlab}&projectID={$repo->project}"), "<i class='icon icon-sm icon-plus'></i> " . $lang->gitlab->createBranch, '', "class='btn btn-primary'");?>
|
||||
</div>
|
||||
</div>
|
||||
<div id="mainContent" class="main-row fade">
|
||||
|
||||
Reference in New Issue
Block a user