Merge branch 'jihuMR' of https://gitlab.zcorp.cc/easycorp/zentaopms into jihuMR
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
?>
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
|
||||
<?php js::set('repoTypes', $repoTypes)?>
|
||||
<?php js::set('repoTypes', $repoTypes);?>
|
||||
<?php js::set('triggerType', $job->triggerType);?>
|
||||
<?php js::set('pipeline', $job->pipeline);?>
|
||||
<?php js::set('dirChange', $lang->job->dirChange);?>
|
||||
|
||||
@@ -3,3 +3,6 @@ $config->MR = new stdclass();
|
||||
$config->MR->create = new stdclass();
|
||||
$config->MR->create->requiredFields = 'gitlabID,projectID,mrID,title';
|
||||
$config->MR->create->skippedFields = 'sourceProject,sourceBranch,targetProject,targetBranch';
|
||||
|
||||
$config->MR->edit = new stdclass();
|
||||
$config->MR->edit->requiredFields = 'title';
|
||||
|
||||
@@ -48,22 +48,25 @@ class mr extends control
|
||||
}
|
||||
|
||||
/**
|
||||
* Update/Edit MR function.
|
||||
* Edit MR function.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function update($MRID)
|
||||
public function edit($MRID)
|
||||
{
|
||||
if($_POST)
|
||||
{
|
||||
$this->mr->update();
|
||||
$this->mr->edit($MRID);
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse')));
|
||||
}
|
||||
|
||||
$this->view->MR = $this->mr->getByID($MRID);
|
||||
$this->view->title = $this->lang->mr->update;
|
||||
$MR = $this->mr->getByID($MRID);
|
||||
$this->view->MR = $MR;
|
||||
$this->view->title = $this->lang->mr->edit;
|
||||
$this->view->users = array("" => "") + $this->loadModel('gitlab')->getUserIdRealnamePairs($MR->gitlabID); /* Get user list for assignee and reviewer. */
|
||||
|
||||
$this->display();
|
||||
}
|
||||
|
||||
|
||||
+34
-9
@@ -27,13 +27,16 @@ class mrModel extends model
|
||||
* Get a MR by id.
|
||||
*
|
||||
* @param int $id
|
||||
* @param bool $process
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function getByID($id)
|
||||
public function getByID($id, $process = true)
|
||||
{
|
||||
$MR = $this->dao->select('*')->from(TABLE_MR)->where('id')->eq($id)->fetch();
|
||||
return $this->processMR($MR);
|
||||
|
||||
if($process) return $this->processMR($MR);
|
||||
return $MR;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,7 +62,7 @@ class mrModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* Process MR info by api.
|
||||
* Process MR info by api. Append extra attributes in GitLab.
|
||||
*
|
||||
* @param object $MR
|
||||
* @access public
|
||||
@@ -115,7 +118,7 @@ class mrModel extends model
|
||||
* Create MR function.
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
* @return int|bool|object
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
@@ -161,14 +164,36 @@ class mrModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* Update MR function.
|
||||
* Edit MR function.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function update()
|
||||
public function edit($MRID)
|
||||
{
|
||||
}
|
||||
/* Get MR in zentao database and do not append extra attributes in GitLab. */
|
||||
$MR = $this->getByID($MRID, $process = false);
|
||||
$MR->title = $this->post->title;
|
||||
$MR->description = $this->post->description;
|
||||
$MR->assignee = $this->post->assignee;
|
||||
$MR->reviewer = $this->post->reviewer;
|
||||
|
||||
/* Update MR in GitLab. */
|
||||
$newMR = new stdclass;
|
||||
$newMR->title = $MR->title;
|
||||
$newMR->description = $MR->description;
|
||||
$newMR->assignee = $MR->assignee;
|
||||
$newMR->reviewer = $MR->reviewer;
|
||||
$newMR->targetBranch = $this->post->targetBranch;
|
||||
$this->apiUpdateMR($MR->gitlabID, $MR->projectID, $MR->mrID, $newMR);
|
||||
|
||||
/* Update MR in Zentao database. */
|
||||
$this->dao->update(TABLE_MR)->data($MR)
|
||||
->batchCheck($this->config->MR->edit->requiredFields, 'notempty')
|
||||
->autoCheck()
|
||||
->exec();
|
||||
if(dao::isError()) return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create MR by API.
|
||||
@@ -224,11 +249,11 @@ class mrModel extends model
|
||||
* @param int $gitlabID
|
||||
* @param int $projectID
|
||||
* @param int $MRID
|
||||
* @param object $params
|
||||
* @param object $MR
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function apiUpdateMR($gitlabID, $projectID, $MRID, $params)
|
||||
public function apiUpdateMR($gitlabID, $projectID, $MRID, $MR)
|
||||
{
|
||||
$url = sprintf($this->gitlab->getApiRoot($gitlabID), "/projects/$projectID/merge_requests/$MRID");
|
||||
return json_decode(commonModel::http($url, $MR, $options = array(CURLOPT_CUSTOMREQUEST => 'PUT')));
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
<td class='text-left c-actions'>
|
||||
<?php
|
||||
common::printLink('mr', 'list', "mr={$mr->id}", '<i class="icon icon-review"></i>', '', "title='{$lang->mr->list}' class='btn btn-info'");
|
||||
common::printLink('mr', 'update', "mrID=$mr->id", '<i class="icon icon-edit"></i>', '', "title='{$lang->mr->edit}' class='btn btn-info'");
|
||||
common::printLink('mr', 'edit', "mrID=$mr->id", '<i class="icon icon-edit"></i>', '', "title='{$lang->mr->edit}' class='btn btn-info'");
|
||||
if(common::hasPriv('mr', 'delete')) echo html::a($this->createLink('mr', 'delete', "id=$mr->id"), '<i class="icon-trash"></i>', 'hiddenwin', "title='{$lang->mr->delete}' class='btn'");
|
||||
?>
|
||||
</td>
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
<?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'>
|
||||
<div class='main-header'>
|
||||
<h2><?php echo $lang->mr->edit;?></h2>
|
||||
</div>
|
||||
<form id='mrForm' method='post' class='form-ajax'>
|
||||
<table class='table table-form'>
|
||||
<tr>
|
||||
<th><?php echo $lang->gitlab->common;?></th>
|
||||
<td><?php echo $this->loadModel('gitlab')->getByID($MR->gitlabID)->name;?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->mr->sourceProject;?></th>
|
||||
<td>
|
||||
<div class='input-group'>
|
||||
<?php echo $this->loadModel('gitlab')->apiGetSingleProject($MR->gitlabID, $MR->sourceProject)->name_with_namespace; ?>
|
||||
<span class='input-group-addon fix-border'><?php echo $lang->mr->sourceBranch ?></span>
|
||||
<?php echo $MR->sourceBranch;?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->mr->targetProject;?></th>
|
||||
<td class='required'>
|
||||
<div class='input-group'>
|
||||
<?php echo $this->loadModel('gitlab')->apiGetSingleProject($MR->gitlabID, $MR->targetProject)->name_with_namespace;?>
|
||||
<span class='input-group-addon fix-border'><?php echo $lang->mr->targetBranch ?></span>
|
||||
<?php echo html::select('targetBranch', $this->loadModel('gitlab')->getBranches($MR->gitlabID, $MR->targetProject), '', "class='form-control chosen'");?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->mr->name;?></th>
|
||||
<td class='required'><?php echo html::input('title', $MR->name, "class='form-control'"); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->mr->description; ?></th>
|
||||
<td colspan='1'><?php echo html::textarea('description', $MR->description, "rows='3' class='form-control'"); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->mr->assignee;?></th>
|
||||
<td><?php echo html::select('assignee', $users, $MR->assignee, "class='form-control chosen'")?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->mr->reviewer;?></th>
|
||||
<td><?php echo html::select('reviewer', $users, $MR->reviewer, "class='form-control chosen'")?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td><?php echo $lang->mr->usersTips;?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td colspan='2' class='text-center form-actions'>
|
||||
<?php echo html::submitButton(); ?>
|
||||
<?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'; ?>
|
||||
Reference in New Issue
Block a user