* Finish task#44144.

This commit is contained in:
dingguodong
2021-11-09 18:18:06 +08:00
parent 20f94c4e7c
commit 58aef31f15
7 changed files with 69 additions and 42 deletions
+2
View File
@@ -664,6 +664,8 @@ CREATE TABLE IF NOT EXISTS `zt_mr` (
`status` char(30) NOT NULL,
`mergeStatus` char(30) NOT NULL,
`approvalStatus` char(30) NOT NULL,
`needApproved` enum('0','1') NOT NULL DEFAULT '0',
`needPassCI` enum('0','1') NOT NULL DEFAULT '0',
`repoID` mediumint(8) unsigned NOT NULL,
`jobID` mediumint(8) unsigned NOT NULL,
`compileID` mediumint(8) unsigned NOT NULL,
+19 -13
View File
@@ -201,12 +201,30 @@ class mr extends control
{
$MR = $this->mr->getByID($MRID);
/* Judge that if this MR can be accepted. */
if(isset($MR->needPassCI) and $MR->needPassCI == '1')
{
$compileStatus = empty($MR->compileID) ? 'fail' : $this->loadModel('compile')->getByID($MR->compileID)->status;
if(isset($compileStatus) and $compileStatus != 'success')
{
return $this->send(array('result' => 'fail', 'message' => $this->lang->mr->needPassCI, 'locate' => helper::createLink('mr', 'view', "mr={$MRID}")));
}
}
if(isset($MR->needApproved) and $MR->needApproved == '1')
{
if($MR->approvalStatus != 'approved')
{
return $this->send(array('result' => 'fail', 'message' => $this->lang->mr->needApproved, 'locate' => helper::createLink('mr', 'view', "mr={$MRID}")));
}
}
/* Accept MR by using the mapped user in GitLab. */
$sudoUser = $this->mr->getSudoUsername($MR->gitlabID, $MR->targetProject);
if(isset($MR->gitlabID))
{
if(!empty($sudoUser)) $rawMR = $this->mr->apiAcceptMR($MR->gitlabID, $MR->targetProject, $MR->mriid, $sudo = $sudoUser);
if(!empty($sudoUser)) $rawMR = $this->mr->apiAcceptMR($MR->gitlabID, $MR->targetProject, $MR->mriid, $sudoUser);
if(empty($sudoUser)) $rawMR = $this->mr->apiAcceptMR($MR->gitlabID, $MR->targetProject, $MR->mriid);
}
if(isset($rawMR->state) and $rawMR->state == 'merged')
@@ -275,18 +293,6 @@ class mr extends control
$this->display();
}
/**
* Approve this MR. Reject or approve it.
*
* @param int $MRID
* @return void
*/
public function approve($MRID, $action = 'approve')
{
$MR = $this->mr->getByID($MRID);
return $this->send($this->mr->approve($MR, $action));
}
/**
* Approval for this MR.
*
+3
View File
@@ -36,6 +36,9 @@ $lang->mr->approvalResultList = array();
$lang->mr->approvalResultList['approve'] = 'Approve';
$lang->mr->approvalResultList['reject'] = 'Reject';
$lang->mr->needApproved = 'This MR should be approved before merge';
$lang->mr->needPassCI = 'This MR should be passed CI before merge';
$lang->mr->repeatedOperation = 'Do not repeat operations';
$lang->mr->approvalStatus = 'Approve status';
+3
View File
@@ -36,6 +36,9 @@ $lang->mr->approvalResultList = array();
$lang->mr->approvalResultList['approve'] = '通过';
$lang->mr->approvalResultList['reject'] = '拒绝';
$lang->mr->needApproved = '需要通过评审才能合并';
$lang->mr->needPassCI = '需要通过构建才能合并';
$lang->mr->repeatedOperation = '请勿重复操作';
$lang->mr->approvalStatus = '审核状态';
+3
View File
@@ -36,6 +36,9 @@ $lang->mr->approvalResultList = array();
$lang->mr->approvalResultList['approve'] = '通過';
$lang->mr->approvalResultList['reject'] = '拒絕';
$lang->mr->needApproved = '需要通過評審才能合併';
$lang->mr->needPassCI = '需要通過構建才能合併';
$lang->mr->repeatedOperation = '請勿重複操作';
$lang->mr->approvalStatus = '審核狀態';
+1 -1
View File
@@ -93,7 +93,7 @@ class mrModel extends model
$compileStatus = $this->loadModel('compile')->getByID($this->post->compile)->status;
$MR = fixer::input('post')
->add('createdBy', $this->app->user->account)
->add('createdBy', $this->app->user->account)
->add('createdDate', helper::now())
->add('repoID', $repoID)
->add('jobID', $jobID)
+38 -28
View File
@@ -1,4 +1,5 @@
<?php
/**
* The create view file of mr module of ZenTaoPMS.
*
@@ -8,72 +9,81 @@
* @version $Id: create.html.php $
*/
?>
<?php include '../../common/view/header.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->create;?></h2>
<h2><?php echo $lang->mr->create; ?></h2>
</div>
<form id='mrForm' method='post' class='form-ajax'>
<table class='table table-form'>
<tr>
<th><?php echo $lang->gitlab->common;?></th>
<th><?php echo $lang->gitlab->common; ?></th>
<!-- Use `array('') + $gitlabHosts` here because of this field must be changed when creating this MR. -->
<td class='required'><?php echo html::select('gitlabID', array('') + $gitlabHosts, '', "class='form-control'");?></td>
<td class='required'><?php echo html::select('gitlabID', array('') + $gitlabHosts, '', "class='form-control'"); ?></td>
</tr>
<tr>
<th style="white-space: nowrap;"><?php echo $lang->mr->sourceProject;?></th>
<td>
<div class='input-group required'>
<?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>
<th style="white-space: nowrap;"><?php echo $lang->mr->sourceProject; ?></th>
<td>
<div class='input-group required'>
<?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 style="white-space: nowrap;"><?php echo $lang->mr->targetProject;?></th>
<td>
<div class='input-group required'>
<?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>
<th style="white-space: nowrap;"><?php echo $lang->mr->targetProject; ?></th>
<td>
<div class='input-group required'>
<?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><?php echo $lang->mr->title;?></th>
<th><?php echo $lang->mr->title; ?></th>
<td class='required'><?php echo html::input('title', '', "class='form-control'"); ?></td>
</tr>
<tr>
<th><?php echo $lang->mr->description; ?></th>
<td colspan='1'><?php echo html::textarea('description', '', "rows='3' class='form-control'"); ?></td>
</tr>
<tr>
<th></th>
<td colspan='1'>
<div class="checkbox-primary">
<input type="checkbox" name="needPassCI" value="1" id="needPassCI">
<label for="needPassCI"><?php echo $lang->mr->needPassCI; ?></label>
</div>
</td>
</tr>
<tr>
<th><?php echo $lang->devops->repo; ?></th>
<td colspan='1'><?php echo html::select('repo', array(''), '', "class='form-control chosen'");?></td>
<td colspan='1'><?php echo html::select('repo', array(''), '', "class='form-control chosen'"); ?></td>
</tr>
<tr>
<th><?php echo $lang->job->common; ?></th>
<td colspan='1'><?php echo html::select('job', array(''), '', "class='form-control chosen'");?></td>
<td colspan='1'><?php echo html::select('job', array(''), '', "class='form-control chosen'"); ?></td>
</tr>
<tr>
<th><?php echo $lang->compile->result; ?></th>
<td colspan='1'><?php echo html::select('compile', array(''), '', "class='form-control chosen'");?></td>
<td colspan='1'><?php echo html::select('compile', array(''), '', "class='form-control chosen'"); ?></td>
</tr>
<tr>
<th><?php echo $lang->mr->assignee;?></th>
<td><?php echo html::select('assignee', array(''), '', "class='form-control chosen'")?></td>
<th><?php echo $lang->mr->assignee; ?></th>
<td><?php echo html::select('assignee', array(''), '', "class='form-control chosen'") ?></td>
</tr>
<tr>
<th></th>
<td><?php echo $lang->mr->usersTips;?></td>
<td><?php echo $lang->mr->usersTips; ?></td>
</tr>
<tr>
<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"');?>
<?php if (!isonlybody()) echo html::a(inlink('browse', ""), $lang->goback, '', 'class="btn btn-wide"'); ?>
</td>
<td></td>
</tr>