Merge branch 'devops24_50697' into 'devops24'

Code for task#50697,50685

See merge request easycorp/zentaopms!2328
This commit is contained in:
李玉春
2022-03-17 05:57:15 +00:00
13 changed files with 59 additions and 21 deletions
+2
View File
@@ -55,3 +55,5 @@ ALTER TABLE `zt_kanbancard` CHANGE `order` `order` mediumint NOT NULL DEFAULT '0
ALTER TABLE `zt_kanbanregion` CHANGE `order` `order` mediumint NOT NULL DEFAULT '0' AFTER `name`;
ALTER TABLE `zt_kanbanspace` CHANGE `order` `order` mediumint NOT NULL DEFAULT '0' AFTER `status`;
ALTER TABLE `zt_projectstory` CHANGE `branch` `branch` mediumint unsigned NOT NULL AFTER `product`;
ALTER TABLE `zt_mr` ADD `squash` ENUM('0','1') NOT NULL DEFAULT '0' AFTER `removeSourceBranch`;
+1
View File
@@ -875,6 +875,7 @@ CREATE TABLE IF NOT EXISTS `zt_mr` (
`compileID` mediumint(8) unsigned NOT NULL,
`compileStatus` char(30) NOT NULL,
`removeSourceBranch` enum('0','1') NOT NULL DEFAULT '0',
`squash` enum('0','1') NOT NULL DEFAULT '0',
`synced` enum('0','1') COLLATE 'utf8_general_ci' NOT NULL DEFAULT '1',
`syncError` varchar(255) NOT NULL,
`hasNoConflict` enum('0','1') COLLATE 'utf8_general_ci' NOT NULL DEFAULT '0',
+2 -2
View File
@@ -344,7 +344,8 @@ $lang->action->label->importedrelease = 'imported';
$lang->action->label->importedexecution = 'imported';
$lang->action->label->importedbuild = 'imported';
$lang->action->label->fromsonarqube = 'created a bug from SonarQube Issue named:';
$lang->action->label->binduser = 'bind user';
$lang->action->label->bind = 'bound';
$lang->action->label->unbind = 'unbound';
/* Dynamic information is grouped by object. */
$lang->action->dynamicAction = new stdclass;
@@ -824,4 +825,3 @@ $lang->action->desc->deletemr = '$date, <strong>$actor</stro
$lang->action->desc->mergedmr = '$date, <strong>$actor</strong> merged <a href="$extra">code</a>.';
$lang->action->desc->approve = '$date, <strong>$actor</strong> approved.';
$lang->action->desc->reject = '$date, <strong>$actor</strong> rejected.';
$lang->action->desc->binduser = '$date, <strong>$actor</strong> modified bound user.';
+2 -2
View File
@@ -344,7 +344,8 @@ $lang->action->label->importedrelease = '导入了';
$lang->action->label->importedexecution = '导入了';
$lang->action->label->importedbuild = '导入了';
$lang->action->label->fromsonarqube = '由SonarQube问题创建';
$lang->action->label->binduser = '绑定用户了';
$lang->action->label->bind = '绑定了';
$lang->action->label->unbind = '取消绑定了';
/* 动态信息按照对象分组 */
$lang->action->dynamicAction = new stdclass();
@@ -824,4 +825,3 @@ $lang->action->desc->deletemr = '$date, 由 <strong>$actor</
$lang->action->desc->mergedmr = '$date, 由 <strong>$actor</strong> 合并了 <a href="$extra">代码</a>。';
$lang->action->desc->approve = '$date, 由 <strong>$actor</strong> 审核通过。';
$lang->action->desc->reject = '$date, 由 <strong>$actor</strong> 拒绝。';
$lang->action->desc->binduser = '$date, 由 <strong>$actor</strong> 修改了绑定用户。';
+23 -17
View File
@@ -149,9 +149,12 @@ class gitlab extends control
$user = $this->gitlab->apiGetCurrentUser($gitlab->url, $gitlab->token);
if(!isset($user->is_admin) or !$user->is_admin) return print(js::alert($this->lang->gitlab->tokenLimit) . js::locate($this->createLink('gitlab', 'edit', array('gitlabID' => $gitlabID))));
$zentaoUsers = $this->dao->select('account,email,realname')->from(TABLE_USER)->fetchAll('account');
if($_POST)
{
$users = $this->post->zentaoUsers;
$gitlabNames = $this->post->gitlabUserNames;
$accountList = array();
$repeatUsers = array();
foreach($users as $openID => $user)
@@ -167,30 +170,33 @@ class gitlab extends control
$user->providerID = $gitlabID;
$user->providerType = 'gitlab';
/* Delete binded users and save new relationship. */
$this->dao->delete()->from(TABLE_OAUTH)->where('providerType')->eq($user->providerType)->andWhere('providerID')->eq($user->providerID)->exec();
$oldUsers = $this->dao->select('*')->from(TABLE_OAUTH)->where('providerType')->eq($user->providerType)->andWhere('providerID')->eq($user->providerID)->fetchAll('openID');
foreach($users as $openID => $account)
{
if(!$account) continue;
$user->account = $account;
$user->openID = $openID;
$existAccount = isset($oldUsers[$openID]) ? $oldUsers[$openID] : '';
$this->dao->delete()
->from(TABLE_OAUTH)
->where('openID')->eq($user->openID)
->andWhere('providerType')->eq($user->providerType)
->andWhere('providerID')->eq($user->providerID)
->andWhere('account')->eq($user->account)
->exec();
$this->dao->insert(TABLE_OAUTH)->data($user)->exec();
if($existAccount and $existAccount->account != $account)
{
$this->dao->delete()
->from(TABLE_OAUTH)
->where('openID')->eq($openID)
->andWhere('providerType')->eq($user->providerType)
->andWhere('providerID')->eq($user->providerID)
->exec();
$this->loadModel('action')->create('gitlabuser', $openID, 'unbind', '', sprintf($this->lang->gitlab->bindDynamic, $gitlabNames[$openID], $zentaoUsers[$existAccount->account]->realname));
}
if(!$existAccount or $existAccount->account != $account)
{
if(!$account) continue;
$user->account = $account;
$user->openID = $openID;
$this->dao->insert(TABLE_OAUTH)->data($user)->exec();
$this->loadModel('action')->create('gitlabuser', $openID, 'bind', '', sprintf($this->lang->gitlab->bindDynamic, $gitlabNames[$openID], $zentaoUsers[$account]->realname));
}
}
$this->loadModel('action')->create('gitlab', $gitlabID, 'binduser');
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->server->http_referer));
}
$zentaoUsers = $this->dao->select('account,email,realname')->from(TABLE_USER)->fetchAll('account');
$this->view->title = $this->lang->gitlab->bindUser;
$this->view->userPairs = $userPairs;
$this->view->gitlabUsers = $this->gitlab->apiGetUsers($gitlabID);
+1
View File
@@ -18,6 +18,7 @@ $lang->gitlab->bindingStatus = 'Binding Status';
$lang->gitlab->notBind = 'Not bind';
$lang->gitlab->binded = 'Binded';
$lang->gitlab->bindedError = 'The bound user has been deleted or modified. Please bind again.';
$lang->gitlab->bindDynamic = '%s and Zentao user %s';
$lang->gitlab->serverFail = 'Connect to GitLab server failed, please check the GitLab server.';
$lang->gitlab->lastUpdate = 'Last Update';
$lang->gitlab->confirmAddWebhook = 'Are you sure about creating Webhook?';
+1
View File
@@ -18,6 +18,7 @@ $lang->gitlab->bindingStatus = '绑定状态';
$lang->gitlab->notBind = '未绑定';
$lang->gitlab->binded = '已绑定';
$lang->gitlab->bindedError = '绑定的用户已删除或者已修改,请重新绑定';
$lang->gitlab->bindDynamic = '%s与禅道用户%s';
$lang->gitlab->serverFail = '连接GitLab服务器异常,请检查GitLab服务器。';
$lang->gitlab->lastUpdate = '最后更新';
$lang->gitlab->confirmAddWebhook = '您确定创建Webhook吗?';
+2
View File
@@ -28,6 +28,7 @@
<tbody>
<?php foreach($gitlabUsers as $gitlabUser):?>
<?php if(isset($gitlabUser->zentaoAccount)) continue;?>
<?php echo html::hidden("gitlabUserNames[$gitlabUser->id]", $gitlabUser->realname);?>
<tr>
<td class='w-60px'><?php echo html::image($gitlabUser->avatar, "height=40");?></td>
<td class='text-left'>
@@ -42,6 +43,7 @@
<?php endforeach;?>
<?php foreach($gitlabUsers as $gitlabUser):?>
<?php if(!isset($gitlabUser->zentaoAccount)) continue;?>
<?php echo html::hidden("gitlabUserNames[$gitlabUser->id]", $gitlabUser->realname);?>
<tr>
<td class='w-60px'><?php echo html::image($gitlabUser->avatar, "height=40");?></td>
<td>
+1
View File
@@ -60,6 +60,7 @@ $lang->mr->approvalResultList['reject'] = 'Reject';
$lang->mr->needApproved = 'This MR should be approved before merge';
$lang->mr->needCI = 'Merge only after passing CI';
$lang->mr->removeSourceBranch = 'Delete source branch after merge';
$lang->mr->squash = 'Squash commits';
$lang->mr->repeatedOperation = 'Do not repeat operations';
+1
View File
@@ -60,6 +60,7 @@ $lang->mr->approvalResultList['reject'] = '拒绝';
$lang->mr->needApproved = '需要通过评审才能合并';
$lang->mr->needCI = '需要通过构建才能合并';
$lang->mr->removeSourceBranch = '合并后删除源分支';
$lang->mr->squash = '合并提交';
$lang->mr->repeatedOperation = '请勿重复操作';
+4
View File
@@ -162,6 +162,7 @@ class mrModel extends model
->setDefault('repoID', 0)
->setDefault('removeSourceBranch','0')
->setDefault('needCI', 0)
->setDefault('squash', 0)
->add('createdBy', $this->app->user->account)
->add('createdDate', helper::now())
->get();
@@ -197,6 +198,7 @@ class mrModel extends model
$MRObject->title = $MR->title;
$MRObject->description = $MR->description;
$MRObject->remove_source_branch = $MR->removeSourceBranch == '1' ? true : false;
$MRObject->squash = $MR->squash == '1' ? 1 : 0;
if($MR->assignee)
{
$gitlabAssignee = $this->gitlab->getUserIDByZentaoAccount($this->post->gitlabID, $MR->assignee);
@@ -340,6 +342,7 @@ class mrModel extends model
->setDefault('repoID', 0)
->setDefault('removeSourceBranch','0')
->setDefault('needCI', 0)
->setDefault('squash', 0)
->setDefault('editedBy', $this->app->user->account)
->setDefault('editedDate', helper::now())
->setIF($this->post->needCI == 0, 'jobID', 0)
@@ -368,6 +371,7 @@ class mrModel extends model
$newMR->description = $MR->description;
$newMR->target_branch = $MR->targetBranch;
$newMR->remove_source_branch = $MR->removeSourceBranch == '1' ? true : false;
$newMR->squash = $MR->squash == '1' ? 1 : 0;
if($MR->assignee)
{
$gitlabAssignee = $this->gitlab->getUserIDByZentaoAccount($oldMR->gitlabID, $MR->assignee);
+9
View File
@@ -76,6 +76,15 @@
<th><?php echo $lang->job->common;?></th>
<td colspan='1' class='required'><?php echo html::select('jobID', array(''), '', "class='form-control chosen'");?></td>
</tr>
<tr>
<th><?php echo $lang->mr->squash;?></th>
<td colspan='1'>
<div class="checkbox-primary">
<input type="checkbox" name="squash" value="1" id="squash">
<label for="squash"></label>
</div>
</td>
</tr>
<tr>
<th><?php echo $lang->mr->assignee;?></th>
<td><?php echo html::select('assignee', $users, '', "class='form-control chosen'");?></td>
+10
View File
@@ -100,6 +100,16 @@
<th><?php echo $lang->job->common;?></th>
<td colspan='1' class='required'><?php echo html::select('jobID', $jobList, $MR->jobID, "class='form-control chosen'");?></td>
</tr>
<tr>
<th><?php echo $lang->mr->squash;?></th>
<td colspan='1'>
<div class="checkbox-primary">
<?php $checked = $MR->squash == '1' ? 'checked' : '' ?>
<input type="checkbox" <?php echo $checked;?> name="squash" value="1" id="squash">
<label for="squash"></label>
</div>
</td>
</tr>
<tr>
<th><?php echo $lang->mr->assignee;?></th>
<td><?php echo html::select('assignee', $users, $assignee, "class='form-control chosen'");?></td>