* code for task #46552.
This commit is contained in:
@@ -937,4 +937,19 @@ class mr extends control
|
||||
foreach($compileList as $compile) $options .= "<option value='{$compile->id}' data-name='{$compile->name}'>[{$compile->id}] [{$this->lang->compile->statusList[$compile->status]}] {$compile->name}</option>";
|
||||
$this->send($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax check opened mr.
|
||||
*
|
||||
* @param int $gitlabID
|
||||
* @param int $projectID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxCheckOpened($gitlabID, $projectID)
|
||||
{
|
||||
$sourceBranch = $this->post->sourceBranch;
|
||||
$result = $this->mr->hasOpened($gitlabID, $projectID, $sourceBranch);
|
||||
die(json_encode($result));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,25 @@ $(function()
|
||||
});
|
||||
});
|
||||
|
||||
$('#sourceBranch').change(function()
|
||||
{
|
||||
var gitlabID = $('#gitlabID').val();
|
||||
var sourceProject = $('#sourceProject').val();
|
||||
repoUrl = createLink('mr', 'ajaxCheckOpened', "gitlabID=" + gitlabID + "&projectID=" + sourceProject);
|
||||
|
||||
var sourceBranch = $(this).val();
|
||||
$.post(repoUrl, {"sourceBranch": sourceBranch}, function(response)
|
||||
{
|
||||
response = $.parseJSON(response);
|
||||
if(response.result == 'fail')
|
||||
{
|
||||
alert(response.message);
|
||||
$('#sourceBranch').val('').trigger('chosen:updated');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/*
|
||||
$('#targetProject').change(function()
|
||||
{
|
||||
|
||||
+10
-10
@@ -1,26 +1,26 @@
|
||||
$(function ()
|
||||
{
|
||||
{
|
||||
$('#repoID').change(function ()
|
||||
{
|
||||
{
|
||||
repoID = $(this).val();
|
||||
jobUrl = createLink('mr', 'ajaxGetJobList', "repoID=" + repoID);
|
||||
$.get(jobUrl, function (response)
|
||||
{
|
||||
{
|
||||
$('#jobID').html('').append(response);
|
||||
$('#jobID').chosen().trigger("chosen:updated");;
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$('#jobID').change(function ()
|
||||
{
|
||||
{
|
||||
jobID = $(this).val();
|
||||
compileUrl = createLink('mr', 'ajaxGetCompileList', "job=" + jobID);
|
||||
$.get(compileUrl, function (response)
|
||||
{
|
||||
{
|
||||
$('#compile').html('').append(response);
|
||||
$('#compile').chosen().trigger("chosen:updated");;
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$("#needCI").change(function()
|
||||
{
|
||||
@@ -28,4 +28,4 @@ $(function ()
|
||||
if(this.checked == true) $("#jobID").parent().parent().removeClass('hidden');
|
||||
});
|
||||
$("#needCI").trigger('change');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -105,6 +105,7 @@ $lang->mr->apiError->createMR = "Failed to create a merge request through API. R
|
||||
$lang->mr->apiError->sudo = "Unable to operate with the GitLab account bound to the current user. Reason: %s";
|
||||
|
||||
$lang->mr->createFailedFromAPI = "Failed to create Merge Request.";
|
||||
$lang->mr->hasOpenedMR = "There are other unclosed merge requests in the current source branch.";
|
||||
$lang->mr->accessGitlabFailed = "Unable to connect to the GitLab server.";
|
||||
$lang->mr->reopenSuccess = "The merge request was reopened.";
|
||||
$lang->mr->closeSuccess = "Merge request closed.";
|
||||
@@ -119,11 +120,11 @@ $lang->mr->from = "from";
|
||||
$lang->mr->to = "to";
|
||||
$lang->mr->at = "at";
|
||||
|
||||
$lang->mr->pipeline = "Pipeline";
|
||||
$lang->mr->pipelineSuccess = "Success";
|
||||
$lang->mr->pipelineFailed = "Failed";
|
||||
$lang->mr->pipeline = "Pipeline";
|
||||
$lang->mr->pipelineSuccess = "Success";
|
||||
$lang->mr->pipelineFailed = "Failed";
|
||||
$lang->mr->pipelineCanceled = "Canceled";
|
||||
$lang->mr->pipelineUnknown = "Unknown";
|
||||
$lang->mr->pipelineUnknown = "Unknown";
|
||||
|
||||
$lang->mr->pipelineStatus = array();
|
||||
$lang->mr->pipelineStatus['success'] = "success";
|
||||
|
||||
@@ -105,6 +105,7 @@ $lang->mr->apiError->createMR = "通过API创建合并请求失败,失败原
|
||||
$lang->mr->apiError->sudo = "无法以当前用户绑定的GitLab账户进行操作,失败原因:%s";
|
||||
|
||||
$lang->mr->createFailedFromAPI = "创建合并请求失败。";
|
||||
$lang->mr->hasOpenedMR = "当前源分支存在其他未关闭的合并请求";
|
||||
$lang->mr->accessGitlabFailed = "当前无法连接到GitLab服务器。";
|
||||
$lang->mr->reopenSuccess = "已重新打开合并请求。";
|
||||
$lang->mr->closeSuccess = "已关闭合并请求。";
|
||||
@@ -119,11 +120,11 @@ $lang->mr->from = "从";
|
||||
$lang->mr->to = "合并到";
|
||||
$lang->mr->at = "于";
|
||||
|
||||
$lang->mr->pipeline = "流水线";
|
||||
$lang->mr->pipelineSuccess = "已通过";
|
||||
$lang->mr->pipelineFailed = "未通过";
|
||||
$lang->mr->pipeline = "流水线";
|
||||
$lang->mr->pipelineSuccess = "已通过";
|
||||
$lang->mr->pipelineFailed = "未通过";
|
||||
$lang->mr->pipelineCanceled = "已取消";
|
||||
$lang->mr->pipelineUnknown = "未知";
|
||||
$lang->mr->pipelineUnknown = "未知";
|
||||
|
||||
$lang->mr->pipelineStatus = array();
|
||||
$lang->mr->pipelineStatus['success'] = "已通过";
|
||||
@@ -136,6 +137,7 @@ $lang->mr->hasNoConflict = "可以合并";
|
||||
$lang->mr->acceptMR = "合并";
|
||||
$lang->mr->mergeFailed = "无法合并,请核对合并请求状态";
|
||||
$lang->mr->mergeSuccess = "已成功合并";
|
||||
$lang->mr->mergeSuccess = "已成功合并";
|
||||
|
||||
$lang->mr->todomessage = "项目中指派给你了";
|
||||
|
||||
|
||||
@@ -93,6 +93,9 @@ class mrModel extends model
|
||||
->add('createdDate', helper::now())
|
||||
->get();
|
||||
|
||||
$result = $this->hasOpened($MR->gitlabID, $MR->sourceProject, $MR->sourceBranch);
|
||||
if($result['result'] == 'fail') return $result;
|
||||
|
||||
/* Exec Job */
|
||||
if(isset($MR->jobID) && $MR->jobID)
|
||||
{
|
||||
@@ -1398,4 +1401,33 @@ class mrModel extends model
|
||||
$this->action->create('task', $task->id, 'mergedmr', '', helper::createLink('mr', 'view', "mr={$MR->id}"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check has opened mr
|
||||
*
|
||||
* @param int $gitlabID
|
||||
* @param int $projectID
|
||||
* @param string $sourceBranch
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function hasOpened($gitlabID, $projectID, $sourceBranch)
|
||||
{
|
||||
if(empty($sourceBranch)) return array('result' => 'success');
|
||||
|
||||
$dbOpenedCount = $this->dao->select('count(*) as count')->from(TABLE_MR)
|
||||
->where('gitlabID')->eq($gitlabID)
|
||||
->andWhere('sourceProject')->eq($projectID)
|
||||
->andWhere('sourceBranch')->eq($sourceBranch)
|
||||
->andWhere('status')->eq('opened')
|
||||
->andWhere('deleted')->eq('0')
|
||||
->fetch('count');
|
||||
if($dbOpenedCount > 0) return array('result' => 'fail', 'message' => $this->lang->mr->hasOpenedMR);
|
||||
|
||||
$url = sprintf($this->loadModel('gitlab')->getApiRoot($gitlabID), "/projects/$projectID/merge_requests") . "&view=simple&state=opened&source_branch={$sourceBranch}";
|
||||
$response = json_decode(commonModel::http($url));
|
||||
if(!empty($response)) return array('result' => 'fail', 'message' => $this->lang->mr->hasOpenedMR);
|
||||
|
||||
return array('result' => 'success');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -852,7 +852,7 @@ class productModel extends model
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getStories($productID, $branch, $browseType, $queryID, $moduleID, $type = 'story', $sort, $pager)
|
||||
public function getStories($productID, $branch, $browseType, $queryID, $moduleID, $type = 'story', $sort = 'id_desc', $pager = null)
|
||||
{
|
||||
if(defined('TUTORIAL')) return $this->loadModel('tutorial')->getStories();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user