* Create MR view.

This commit is contained in:
dingguodong
2021-08-16 14:37:04 +08:00
parent 753fb1b2cd
commit fa062b6b84
6 changed files with 150 additions and 10 deletions
+16
View File
@@ -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()
+23
View File
@@ -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'));
});
});
+21 -7
View File
@@ -1,13 +1,27 @@
<?php
$lang->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;
+29
View File
@@ -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.
*
+4 -3
View File
@@ -38,9 +38,10 @@
</td>
<td class='text-left c-actions'>
<?php
common::printIcon('mr', 'create', "repo={$repo->id}", $lang->mr->common, 'list', 'review');
common::printIcon('repo', 'edit', "repoID=$repo->id&objectID=$objectID", '', 'list', 'edit');
if(common::hasPriv('repo', 'delete')) echo html::a($this->createLink('repo', 'delete', "repoID=$repo->id&objectID=$objectID"), '<i class="icon-trash"></i>', 'hiddenwin', "title='{$lang->repo->delete}' class='btn'");
common::printLink('mr', 'list', "repo={$repo->id}", '<i class="icon icon-review"></i>', '', "title='{$lang->mr->list}' class='btn btn-info'");
common::printLink('mr', 'create', "repo={$repo->id}", '<i class="icon icon-plus"></i>', '', "title='{$lang->mr->create}' class='btn btn-info'");
common::printLink('repo', 'edit', "repoID=$repo->id&objectID=$objectID", '<i class="icon icon-edit"></i>', '', "title='{$lang->mr->edit}' class='btn btn-info'");
if(common::hasPriv('repo', 'delete')) echo html::a($this->createLink('repo', 'delete', "repoID=$repo->id&objectID=$objectID"), '<i class="icon-trash"></i>', 'hiddenwin', "title='{$lang->mr->delete}' class='btn'");
?>
</td>
</tr>
+57
View File
@@ -0,0 +1,57 @@
<?php
/**
* The create view file of mr module of ZenTaoPMS.
*
* @copyright Copyright 2009-2012 青岛易软天创网络科技有限公司 (QingDao Nature Easy Soft Network Technology Co,LTD www.cnezsoft.com)
* @author Wang Yidong, Zhu Jinyong
* @package mr
* @version $Id: create.html.php $
*/
?>
<?php include '../../common/view/header.html.php';?>
<div id='mainContent' class='main-row'>
<div class='main-col main-content'>
<div class='center-block'>
<form id='mrForm' method='post' class='form-ajax'>
<table class='table table-form'>
<tr>
<th><?php echo $lang->repo->gitlabHost;?></th>
<td class='required'><?php echo html::select('gitlabID', $gitlabHosts, '', "class='form-control' placeholder='{$lang->repo->placeholder->gitlabHost}'");?>
</tr>
<tr>
<th><?php echo $lang->repo->gitlabProject;?></th>
<td class='required'><?php echo html::select('projectID', array(''), '', "class='form-control chosen'");?>
</tr>
<tr>
<th><?php echo $lang->mr->sourceProject;?></th>
<td class='required'>
<div class='input-group'>
<?php echo html::select('sourceProject', array(''), '', "class='form-control chosen'");?>
<span class='input-group-addon fix-border'><?php echo $lang->mr->sourceBranch ?></span>
<?php echo html::select('sourceBranch', array(''), '', "class='form-control chosen'");?>
</div>
</td>
</tr>
<tr>
<th><?php echo $lang->mr->targetProject;?></th>
<td class='required'>
<div class='input-group'>
<?php echo html::select('targetProject', array(''), '', "class='form-control chosen'");?>
<span class='input-group-addon fix-border'><?php echo $lang->mr->targetBranch ?></span>
<?php echo html::select('targetBranch', array(''), '', "class='form-control chosen'");?>
</div>
</td>
</tr>
<tr>
<th></th>
<td colspan='2' class='text-center form-actions'>
<?php echo html::submitButton($lang->mr->cmpAndContinue); ?>
<?php if(!isonlybody()) echo html::a(inlink('browse', ""), $lang->goback, '', 'class="btn btn-wide"');?>
</td>
</tr>
</table>
</form>
</div>
</div>
</div>
<?php include '../../common/view/footer.html.php'; ?>