Merge branch 'cyy_repo' into 'master'

Cyy repo

See merge request easycorp/zentaopms!4376
This commit is contained in:
李玉春
2022-07-06 09:01:15 +00:00
16 changed files with 209 additions and 23 deletions
+11 -4
View File
@@ -634,12 +634,19 @@ class gitlab extends control
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browseUser', "gitlabID=$gitlabID")));
}
$userPairs = $this->loadModel('user')->getPairs('noclosed|noletter');
$user = $this->gitlab->apiGetSingleUser($gitlabID, $userID);
$zentaoBindAccount = $this->dao->select('account')->from(TABLE_OAUTH)->where('providerType')->eq('gitlab')->andWhere('providerID')->eq($gitlabID)->andWhere('openID')->eq($user->id)->fetch('account');
$gitlabUser = $this->gitlab->apiGetSingleUser($gitlabID, $userID);
$zentaoBindAccount = $this->dao->select('account')->from(TABLE_OAUTH)->where('providerType')->eq('gitlab')->andWhere('providerID')->eq($gitlabID)->andWhere('openID')->eq($gitlabUser->id)->fetch('account');
$users = $this->loadModel('user')->getList();
$bindedUsers = $this->gitlab->getUserAccountIdPairs($gitlabID);
$userPairs = array('' => '');
foreach($users as $user)
{
if(!isset($bindedUsers[$user->account]) or $u->account == $zentaoBindAccount) $userPairs[$user->account] = $user->realname;
}
$this->view->title = $this->lang->gitlab->common . $this->lang->colon . $this->lang->gitlab->user->edit;
$this->view->user = $user;
$this->view->user = $gitlabUser;
$this->view->userPairs = $userPairs;
$this->view->zentaoBindAccount = $zentaoBindAccount;
$this->view->gitlabID = $gitlabID;
+1 -1
View File
@@ -14,7 +14,7 @@
<div id="mainMenu" class="clearfix">
<?php echo $this->gitlab->getGitlabMenu($gitlabID, 'group');?>
<div class="btn-toolbar pull-left">
<form id='gitlabForm' method='post'>
<form id='gitlabForm' method='post' class="not-watch">
<?php echo html::input('keyword', $keyword, "class='form-control' placeholder='{$lang->gitlab->placeholderSearch}' style='display: inline-block;width:auto;margin:0 10px'");?>
<a id="gitlabSearch" class="btn btn-primary"><?php echo $lang->gitlab->search?></a>
</form>
+2 -2
View File
@@ -16,7 +16,7 @@
<div id="mainMenu" class="clearfix">
<?php echo $this->gitlab->getGitlabMenu($gitlabID, 'project');?>
<div class="btn-toolbar pull-left">
<form id='gitlabForm' method='post'>
<form id='gitlabForm' method='post' class="not-watch">
<?php echo html::input('keyword', $keyword, "class='form-control' placeholder='{$lang->gitlab->placeholderSearch}' style='display: inline-block;width:auto;margin:0 10px'");?>
<a id="gitlabSearch" class="btn btn-primary"><?php echo $lang->gitlab->search?></a>
</form>
@@ -45,7 +45,7 @@
<th class='c-name text-left'><?php common::printOrderLink('name', $orderBy, $vars, $lang->gitlab->project->name);?></th>
<th class='text-left'></th>
<th class='text-left'><?php echo $lang->gitlab->lastUpdate;?></th>
<th class='c-actions-7'><?php echo $lang->actions;?></th>
<th class='c-actions-8'><?php echo $lang->actions;?></th>
</tr>
</thead>
<tbody>
+3 -3
View File
@@ -14,20 +14,20 @@
<div id="mainMenu" class="clearfix">
<?php echo $this->gitlab->getGitlabMenu($gitlabID, 'user');?>
<div class="btn-toolbar pull-left">
<form id='gitlabForm' method='post'>
<form id='gitlabForm' method='post' class="not-watch">
<?php echo html::input('keyword', $keyword, "class='form-control' placeholder='{$lang->gitlab->placeholderSearch}' style='display: inline-block;width:auto;margin:0 10px'");?>
<a id="gitlabSearch" class="btn btn-primary"><?php echo $lang->gitlab->search?></a>
</form>
</div>
<div class="btn-toolbar pull-right">
<?php common::printLink('gitlab', 'createUser', "gitlabID=$gitlabID", "<i class='icon icon-plus'></i> " . $lang->gitlab->user->create, '', "class='btn btn-primary'");?>
<?php if($isAdmin) common::printLink('gitlab', 'createUser', "gitlabID=$gitlabID", "<i class='icon icon-plus'></i> " . $lang->gitlab->user->create, '', "class='btn btn-primary'");?>
</div>
</div>
<?php if(empty($gitlabUserList)):?>
<div class="table-empty-tip">
<p>
<span class="text-muted"><?php echo $lang->noData;?></span>
<?php echo html::a($this->createLink('gitlab', 'createProject', "gitlabID=$gitlabID"), "<i class='icon icon-plus'></i> " . $lang->gitlab->user->create, '', "class='btn btn-info'");?>
<?php if($isAdmin) echo html::a($this->createLink('gitlab', 'createProject', "gitlabID=$gitlabID"), "<i class='icon icon-plus'></i> " . $lang->gitlab->user->create, '', "class='btn btn-info'");?>
</p>
</div>
<?php else:?>
+2
View File
@@ -1146,6 +1146,7 @@ $lang->resource->repo->download = 'downloadAction';
$lang->resource->repo->maintain = 'maintain';
$lang->resource->repo->setRules = 'setRules';
$lang->resource->repo->apiGetRepoByUrl = 'apiGetRepoByUrl';
$lang->resource->repo->downloadCode = 'downloadCode';
$lang->repo->methodOrder[5] = 'create';
$lang->repo->methodOrder[10] = 'edit';
@@ -1161,6 +1162,7 @@ $lang->repo->methodOrder[55] = 'blame';
$lang->repo->methodOrder[60] = 'download';
$lang->repo->methodOrder[65] = 'setRules';
$lang->repo->methodOrder[70] = 'apiGetRepoByUrl';
$lang->repo->methodOrder[75] = 'downloadCode';
$lang->resource->ci = new stdclass();
$lang->resource->ci->commitResult = 'commitResult';
+2
View File
@@ -86,6 +86,7 @@ class pipelineModel extends model
$this->dao->insert(TABLE_PIPELINE)->data($pipeline)
->batchCheck($this->config->pipeline->create->requiredFields, 'notempty')
->batchCheck("url", 'URL')
->check('name', 'unique', "`type` = '$type'")
->autoCheck()
->exec();
if(dao::isError()) return false;
@@ -116,6 +117,7 @@ class pipelineModel extends model
$this->dao->update(TABLE_PIPELINE)->data($pipeline)
->batchCheck($this->config->pipeline->edit->requiredFields, 'notempty')
->batchCheck("url", 'URL')
->check('name', 'unique', "`type` = '$type' and id <> $id")
->autoCheck()
->where('id')->eq($id)
->exec();
+18
View File
@@ -497,6 +497,7 @@ class repo extends control
$this->view->pager = $pager;
$this->view->path = urldecode($path);
$this->view->logType = $logType;
$this->view->cloneUrl = $this->repo->getCloneUrl($repo);
$this->view->cacheTime = date('m-d H:i', filemtime($cacheFile));
$this->view->branchOrTag = $branchOrTag;
@@ -1293,4 +1294,21 @@ class repo extends control
$executions = $this->repo->getExecutionPairs($productID, $branch);
echo html::select('execution', array('' => '') + $executions, '', 'class="form-control chosen"');
}
/**
* Download zip code.
*
* @param int $repoID
* @param string $branch
* @access public
* @return void
*/
public function downloadCode($repoID = 0, $branch = '')
{
$repo = $this->repo->getRepoByID($repoID);
if($repo->SCM == 'Gitlab')
{
return '';
}
}
}
+5
View File
@@ -26,3 +26,8 @@
/* Fix bug #21893. */
.in #sidebar>.sidebar-toggle>.icon-angle-left:before {content: "\e315";}
.hide-sidebar #sidebar>.sidebar-toggle>.icon-angle-left:before {content: "\e314";}
.download-popover {width: 400px; max-width: none;}
.popover-content {padding: 0;}
.download-popover .table {margin-bottom: 0;}
.download-popover .table td {padding-right: 0;}
+82
View File
@@ -0,0 +1,82 @@
function getDownload()
{
var content = "<div class='main-col'>";
content += "<div class='center-block'>";
content += "<table class='table table-borderless'>";
if(cloneUrl.ssh)
{
content += "<tr>";
content += "<th>" + lang.sshClone + "</th>";
content += "</tr>";
content += "<tr>";
content += "<td><input type='input' class='form-control' value='" + cloneUrl.ssh + "' readonly></td>";
content += "<td><button type='button' class='btn copy-btn'><i class='icon-common-copy icon-copy' title='" + lang.copy + "'></i></button></td>";
content += "</tr>";
content += "<tr>";
}
if(cloneUrl.http)
{
content += "<th>" + lang.httpClone + "</th>";
content += "</tr>";
content += "<tr>";
content += "<td><input type='input' class='form-control' value='" + cloneUrl.http + "' readonly></td>";
content += "<td><button type='button' class='btn copy-btn'><i class='icon-common-copy icon-copy' title='" + lang.copy + "'></i></button></td>";
content += "</tr>";
}
content += "<tr>";
content += "<td><button type='button' class='btn download-btn'><i class='icon-down-circle'></i> <span>" + lang.downloadZip + "</span></button></td>";
content += "<td>";
content += "</td>";
content += "</tr>";
content += "</table>";
content += "</div>";
content += "</div>";
return content;
}
$(function()
{
/* Init popover. */
var options = {
container: 'body',
content: getDownload(),
html: true,
placement: 'bottom',
template: '<div class="popover"><h3 class="popover-title"></h3><div class="popover-content"></div></div',
tipClass: 'download-popover',
trigger: 'manual'
};
$('#downloadCode').popover(options);
$('#downloadCode').click(function()
{
if($('.download-popover').css('display') == 'block')
{
$('#downloadCode').popover('hide');
}
else
{
$('#downloadCode').popover('show');
/* Set popover area. */
var left = parseFloat($('.download-popover').css('left')) - 155;
$('.download-popover').css('left', left + 'px')
}
})
$('.copy-btn').live('click', function()
{
var copyText = $(this).parent().parent().find('input');
copyText .select();
document.execCommand("Copy");
alert(lang.copied);
})
$('.download-btn').live('click', function()
{
var link = createLink('repo', 'downloadCode', 'repoID=' + repoID);
window.open(link);
})
})
+18 -12
View File
@@ -8,9 +8,9 @@ $lang->repo->create = 'Create';
$lang->repo->maintain = 'Repo List';
$lang->repo->edit = 'Edit';
$lang->repo->delete = 'Delete Repo';
$lang->repo->showSyncCommit = 'Display Synchronization';
$lang->repo->showSyncCommit = 'Display Sync';
$lang->repo->ajaxSyncCommit = 'Interface: Ajax Sync Note';
$lang->repo->setRules = 'Set rules';
$lang->repo->setRules = 'Set Rules';
$lang->repo->download = 'Download File';
$lang->repo->downloadDiff = 'Download Diff';
$lang->repo->addBug = 'Add Review';
@@ -30,16 +30,22 @@ $lang->repo->apiGetRepoByUrl = 'API: Get repo by URL';
$lang->repo->browseAction = 'Browse Repo';
$lang->repo->createAction = 'Create Repo';
$lang->repo->editAction = 'Edit Repo';
$lang->repo->diffAction = 'Revision Diff';
$lang->repo->diffAction = 'Diff Revision';
$lang->repo->downloadAction = 'Download File';
$lang->repo->revisionAction = 'Revision Detail';
$lang->repo->blameAction = 'Repo Blame';
$lang->repo->blameAction = 'Blame';
$lang->repo->reviewAction = 'Review List';
$lang->repo->downloadCode = 'Download Code';
$lang->repo->downloadZip = 'Download Zip file';
$lang->repo->sshClone = 'Clone by SSH';
$lang->repo->httpClone = 'Clone by HTTP';
$lang->repo->submit = 'Submit';
$lang->repo->cancel = 'Cancel';
$lang->repo->addComment = 'Add Comment';
$lang->repo->copy = 'Click to copy';
$lang->repo->copied = 'Copy successful';
$lang->repo->module = 'Module';
$lang->repo->type = 'Type';
$lang->repo->assign = 'AssignTo';
@@ -106,7 +112,7 @@ $lang->repo->openedDate = 'CreatedDate';
$lang->repo->latestRevision = 'Latest Revision';
$lang->repo->actionInfo = "Add by %s in %s";
$lang->repo->changes = "Change Log";
$lang->repo->reviewLocation = "File: %s@%s, line:%s - %s";
$lang->repo->reviewLocation = "File: %s@%s, Line: %s - %s";
$lang->repo->commentEdit = '<i class="icon-pencil"></i>';
$lang->repo->commentDelete = '<i class="icon-remove"></i>';
$lang->repo->allChanges = "Other Changes";
@@ -119,7 +125,7 @@ $lang->repo->objectIdRule = 'Object ID Rule';
$lang->repo->actionRule = 'Action Rule';
$lang->repo->manHourRule = 'Man-hour Rule';
$lang->repo->ruleUnit = "Unit";
$lang->repo->ruleSplit = "Multiple keywords are divided by ';'. For example: task multiple keywords: Task;task";
$lang->repo->ruleSplit = "Multiple keywords are divided by ';', e.g. task multiple keywords: Task;task";
$lang->repo->viewDiffList['inline'] = 'Inline';
$lang->repo->viewDiffList['appose'] = 'Parallel';
@@ -136,7 +142,7 @@ $lang->repo->encodingList['gbk'] = 'GBK';
$lang->repo->scmList['Gitlab'] = 'GitLab';
$lang->repo->scmList['Git'] = 'Git';
$lang->repo->scmList['Subversion'] = 'Subversion';
$lang->repo->scmList['Subversion'] = 'SVN';
$lang->repo->gitlabHost = 'GitLab Host';
$lang->repo->gitlabToken = 'GitLab Token';
@@ -149,12 +155,12 @@ $lang->repo->notice = new stdclass();
$lang->repo->notice->syncing = 'Synchronizing. Please wait ...';
$lang->repo->notice->syncComplete = 'Synchronized. Now redirecting ...';
$lang->repo->notice->syncedCount = 'The number of records synchronized is ';
$lang->repo->notice->delete = 'Are you sure delete this repo?';
$lang->repo->notice->delete = 'Do you want to delete this repo?';
$lang->repo->notice->successDelete = 'Repository is removed.';
$lang->repo->notice->commentContent = 'Comment';
$lang->repo->notice->deleteReview = 'Do you want to delete this review?';
$lang->repo->notice->deleteBug = 'Are you sure to delete this bug?';
$lang->repo->notice->deleteComment = 'Are you sure to delete this comment?';
$lang->repo->notice->deleteBug = 'Do you want to delete this bug?';
$lang->repo->notice->deleteComment = 'Do you want to delete this comment?';
$lang->repo->notice->lastSyncTime = 'Last Sync:';
$lang->repo->rules = new stdclass();
@@ -182,14 +188,14 @@ $lang->repo->error->noFile = '%s does not exist.';
$lang->repo->error->noPriv = 'The program does not have the privilege to switch to %s';
$lang->repo->error->output = "The command is: %s\nThe error is(%s): %s\n";
$lang->repo->error->clientVersion = "Client version is too low, please upgrade or change SVN client";
$lang->repo->error->encoding = "The encoding maybe wrong. Please change the encoding and try again.";
$lang->repo->error->encoding = "The encoding might be wrong. Please change the encoding and try again.";
$lang->repo->error->deleted = "Deletion of the repository failed. The current repository has a commit record associated with the design.";
$lang->repo->error->linkedJob = "Deletion of the repository failed. The current repository has associated with the Compile.";
$lang->repo->error->clientPath = "The client installation directory cannot have spaces!";
$lang->repo->error->notFound = "The repository %s’s URL %s does not exist. Please confirm if this repository has been deleted from the local server.";
$lang->repo->syncTips = '<strong>You may find the reference about how to set Git sync from <a target="_blank" href="https://www.zentao.pm/book/zentaomanual/free-open-source-project-management-software-git-105.html">here</a>.</strong>';
$lang->repo->encodingsTips = "The encodings of commit comments, can be comma separated values,e.g. utf-8";
$lang->repo->encodingsTips = "The encodings of comments can be comma separated values, e.g. utf-8.";
$lang->repo->pathTipsForGitlab = "GitLab Project URL";
$lang->repo->example = new stdclass();
+6
View File
@@ -35,11 +35,17 @@ $lang->repo->downloadAction = 'Download File';
$lang->repo->revisionAction = 'Revision Detail';
$lang->repo->blameAction = 'Blame';
$lang->repo->reviewAction = 'Review List';
$lang->repo->downloadCode = 'Download Code';
$lang->repo->downloadZip = 'Download compressed package';
$lang->repo->sshClone = 'Clone by SSH';
$lang->repo->httpClone = 'Clone by HTTP';
$lang->repo->submit = 'Submit';
$lang->repo->cancel = 'Cancel';
$lang->repo->addComment = 'Add Comment';
$lang->repo->copy = 'Click to copy';
$lang->repo->copied = 'Copy successful';
$lang->repo->module = 'Module';
$lang->repo->type = 'Type';
$lang->repo->assign = 'AssignTo';
+6
View File
@@ -35,11 +35,17 @@ $lang->repo->downloadAction = 'Download File';
$lang->repo->revisionAction = 'Détail Révision';
$lang->repo->blameAction = 'Blâme du Référentiel';
$lang->repo->reviewAction = 'Review List';
$lang->repo->downloadCode = 'Download Code';
$lang->repo->downloadZip = 'Download compressed package';
$lang->repo->sshClone = 'Clone by SSH';
$lang->repo->httpClone = 'Clone by HTTP';
$lang->repo->submit = 'Soumettre';
$lang->repo->cancel = 'Annuler';
$lang->repo->addComment = 'Ajout Comment.';
$lang->repo->copy = 'Click to copy';
$lang->repo->copied = 'Copy successful';
$lang->repo->module = 'Module';
$lang->repo->type = 'Type';
$lang->repo->assign = 'Assigner à';
+15
View File
@@ -27,10 +27,25 @@ $lang->repo->tag = 'Tag';
$lang->repo->addWebHook = 'Add Webhook';
$lang->repo->apiGetRepoByUrl = 'API: Get repo by URL';
$lang->repo->browseAction = 'Browse Repo';
$lang->repo->createAction = 'Create Repo';
$lang->repo->editAction = 'Edit Repo';
$lang->repo->diffAction = 'Diff Revision';
$lang->repo->downloadAction = 'Download File';
$lang->repo->revisionAction = 'Revision Detail';
$lang->repo->blameAction = 'Blame';
$lang->repo->reviewAction = 'Review List';
$lang->repo->downloadCode = 'Download Code';
$lang->repo->downloadZip = 'Download compressed package';
$lang->repo->sshClone = 'Clone by SSH';
$lang->repo->httpClone = 'Clone by HTTP';
$lang->repo->submit = 'Gửi';
$lang->repo->cancel = 'Hủy';
$lang->repo->addComment = 'Thêm nhận xét';
$lang->repo->copy = 'Click to copy';
$lang->repo->copied = 'Copy successful';
$lang->repo->module = 'Module';
$lang->repo->type = 'Loại';
$lang->repo->assign = 'Giao cho';
+6
View File
@@ -35,11 +35,17 @@ $lang->repo->downloadAction = '下载代码库文件';
$lang->repo->revisionAction = '版本详情';
$lang->repo->blameAction = '版本追溯';
$lang->repo->reviewAction = '评审列表';
$lang->repo->downloadCode = '下载代码';
$lang->repo->downloadZip = '下载压缩包';
$lang->repo->sshClone = '使用SSH克隆';
$lang->repo->httpClone = '使用HTTP克隆';
$lang->repo->submit = '提交';
$lang->repo->cancel = '取消';
$lang->repo->addComment = '添加评论';
$lang->repo->copy = '点击复制';
$lang->repo->copied = '复制成功';
$lang->repo->module = '模块';
$lang->repo->type = '类型';
$lang->repo->assign = '指派';
+25
View File
@@ -2131,4 +2131,29 @@ class repoModel extends model
foreach($executions as $execution) $pairs[$execution->id] = $execution->name;
return $pairs;
}
/**
* Get clone url.
*
* @param object $repo
* @access public
* @return object
*/
public function getCloneUrl($repo)
{
if(empty($repo)) return null;
$url = new stdClass();
if($repo->SCM == 'Gitlab')
{
$project = $this->loadModel('gitlab')->apiGetSingleProject($repo->gitlab, $repo->project);
if(isset($project->id))
{
$url->http = $project->http_url_to_repo;
$url->ssh = $project->ssh_url_to_repo;
}
}
return $url;
}
}
+7 -1
View File
@@ -9,6 +9,10 @@
*/
?>
<?php include '../../common/view/header.html.php';?>
<?php js::set('repoID', $repoID);?>
<?php js::set('branch', $branchID);?>
<?php js::set('lang', $lang->repo);?>
<?php js::set('cloneUrl', $cloneUrl);?>
<div id='mainMenu' class='clearfix'>
<div class='btn-toolbar pull-left'>
<?php if(!empty($branchesAndTags)):?>
@@ -82,7 +86,9 @@
<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'");?>
<?php if(common::hasPriv('repo', 'downloadCode')): ?>
<button type="button" class="btn btn-primary" data-toggle="popover" id="downloadCode" title="<?php echo $lang->repo->downloadCode;?>"><i class='icon icon-sm icon-download'></i> <?php echo $lang->repo->download;?> <i class='icon icon-sm icon-caret-down'></i></button>
<?php endif;?>
</div>
</div>
<div id="mainContent" class="main-row fade">