diff --git a/module/mr/control.php b/module/mr/control.php index 53b84ee298..4589882398 100644 --- a/module/mr/control.php +++ b/module/mr/control.php @@ -40,6 +40,22 @@ class mr extends control public function create() { + $this->loadModel('repo'); + if($_POST) + { + $mrID = $this->mr->create(); + + if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); + + if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $repoID)); + $link = helper::createLink('mr', 'browse', '', '', false); + return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $link)); + } + + $this->view->title = $this->lang->mr->create; + $this->view->gitlabHosts = $this->loadModel('gitlab')->getPairs(); + + $this->display(); } public function delete() diff --git a/module/mr/js/create.js b/module/mr/js/create.js new file mode 100644 index 0000000000..e2df836950 --- /dev/null +++ b/module/mr/js/create.js @@ -0,0 +1,23 @@ +$(function() +{ + $('#gitlabID').change(function() + { + host = $('#gitlabID').val(); + url = createLink('repo', 'ajaxgetgitlabprojects', "host=" + host); + if(host == '') return false; + + $.get(url, function(response) + { + $('#projectID').html('').append(response); + $('#projectID').chosen().trigger("chosen:updated");; + }); + }); + + $('#projectID').change(function() + { + $option = $(this).find('option:selected'); + $('#name').val($option.data('name')); + }); + +}); + diff --git a/module/mr/lang/zh-cn.php b/module/mr/lang/zh-cn.php index d853f2844f..bad4505a98 100644 --- a/module/mr/lang/zh-cn.php +++ b/module/mr/lang/zh-cn.php @@ -1,13 +1,27 @@ mr->common = "合并请求"; $lang->mr->create = "创建{$lang->mr->common}"; +$lang->mr->browse = "浏览{$lang->mr->common}"; +$lang->mr->list = $lang->mr->browse; +$lang->mr->edit = "编辑{$lang->mr->common}"; +$lang->mr->delete = "删除{$lang->mr->common}"; $lang->mr->add = "添加GitLab项目"; -$lang->mr->id = 'ID'; -$lang->mr->name = '名称'; -$lang->mr->source = '源项目分支'; -$lang->mr->targer = '目标分支'; -$lang->mr->pipeline = '流水线'; -$lang->mr->audit = '审核状态'; -$lang->mr->execute = '执行状态'; +$lang->mr->id = 'ID'; +$lang->mr->name = '名称'; +$lang->mr->source = '源项目分支'; +$lang->mr->targer = '目标分支'; +$lang->mr->pipeline = '流水线'; +$lang->mr->audit = '审核状态'; +$lang->mr->execute = '执行状态'; + +$lang->mr->sourceProject = '源项目'; +$lang->mr->sourceBranch = '源分支'; +$lang->mr->targetProject = '目标项目'; +$lang->mr->targetBranch = '目标分支'; + +$lang->mr->compareBranch = '比较分支'; +$lang->mr->and = '并'; +$lang->mr->continue = '继续'; +$lang->mr->cmpAndContinue = $lang->mr->compareBranch . $lang->mr->and . $lang->mr->continue; diff --git a/module/mr/model.php b/module/mr/model.php index 1d205cc85a..3554ee895a 100644 --- a/module/mr/model.php +++ b/module/mr/model.php @@ -82,6 +82,19 @@ class mrModel extends model return array('' => '') + $mr; } + public function create() + { + $gitlabID = $this->post->gitlabID; + $projectID = $this->post->projectID; + + $sourceProject = $this->post->sourceProject; + $sourceBranch = $this->post->sourceBranch; + $targetProject = $this->post->targetProject; + $targetBranch = $this->post->targetBranch; + + + } + /** * Get gitlab api base url by gitlab ID. * @@ -94,6 +107,22 @@ class mrModel extends model return $this->gitlab->getApiRoot($gitlabID); } + /** + * Get Forks of a project. + * + * @param int $gitlabID + * @param int $projectID + * @access public + * @return object + * @docs https://docs.gitlab.com/ee/api/projects.html#list-forks-of-a-project + */ + public function apiGetForks($gitlabID, $projectID) + { + $url = sprintf($this->getApiRoot($gitlabID), "/projects/$projectID/forks"); + $mr = new stdclass; + return json_decode(commonModel::http($url)); + } + /** * Create MR by API. * diff --git a/module/mr/view/browse.html.php b/module/mr/view/browse.html.php index 7636aacabf..dbf0992872 100644 --- a/module/mr/view/browse.html.php +++ b/module/mr/view/browse.html.php @@ -38,9 +38,10 @@