From c4d0eabcf300ffe186e5ea506f150fc202a961e5 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Thu, 5 Aug 2021 16:03:46 +0800 Subject: [PATCH 1/7] * adjust for show pipeline in trash. --- module/action/config.php | 1 + module/action/lang/en.php | 4 +++- module/action/lang/zh-cn.php | 4 +++- module/action/model.php | 23 ++++++++++++++++++++--- module/action/view/trash.html.php | 2 +- 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/module/action/config.php b/module/action/config.php index 8319fefa2a..568e426ba1 100755 --- a/module/action/config.php +++ b/module/action/config.php @@ -46,3 +46,4 @@ $config->action->majorList['execution'] = array('opened', 'edited'); $config->action->needGetProjectType = 'build,task,bug,case,testcase,caselib,testtask,testsuite,testreport,doc,issue,release,risk,design,opportunity,trainplan,gapanalysis,researchplan,researchreport,'; $config->action->needGetRelateField = ',story,productplan,release,task,build,bug,case,testtask,testreport,doc,doclib,issue,risk,opportunity,trainplan,gapanalysis,team,whitelist,researchplan,researchreport,meeting,'; +$config->action->noLinkModules = ',doclib,module,webhook,gitlab,pipeline,jenkins,'; diff --git a/module/action/lang/en.php b/module/action/lang/en.php index 6c13ef31b2..8ad8254d42 100755 --- a/module/action/lang/en.php +++ b/module/action/lang/en.php @@ -103,7 +103,9 @@ $lang->action->objectTypes['entry'] = 'Entry'; $lang->action->objectTypes['webhook'] = 'Webhook'; $lang->action->objectTypes['team'] = 'Team'; $lang->action->objectTypes['whitelist'] = 'Whitelist'; -$lang->action->objectTypes['pipeline'] = 'GitLib'; +$lang->action->objectTypes['pipeline'] = 'GitLab'; +$lang->action->objectTypes['gitlab'] = 'GitLab'; +$lang->action->objectTypes['jenkins'] = 'Jenkins'; /* Used to describe operation history. */ $lang->action->desc = new stdclass(); diff --git a/module/action/lang/zh-cn.php b/module/action/lang/zh-cn.php index 668e3db99d..ff168d25af 100755 --- a/module/action/lang/zh-cn.php +++ b/module/action/lang/zh-cn.php @@ -103,7 +103,9 @@ $lang->action->objectTypes['entry'] = '应用'; $lang->action->objectTypes['webhook'] = 'Webhook'; $lang->action->objectTypes['team'] = '团队'; $lang->action->objectTypes['whitelist'] = '白名单'; -$lang->action->objectTypes['pipeline'] = 'GitLib'; +$lang->action->objectTypes['pipeline'] = 'GitLab'; +$lang->action->objectTypes['gitlab'] = 'GitLab'; +$lang->action->objectTypes['jenkins'] = 'Jenkins'; /* 用来描述操作历史记录。*/ $lang->action->desc = new stdclass(); diff --git a/module/action/model.php b/module/action/model.php index 7d37907654..e735fcfb39 100755 --- a/module/action/model.php +++ b/module/action/model.php @@ -569,12 +569,29 @@ class actionModel extends model $objectIds = array_unique($objectIds); $table = $this->config->objectTables[$objectType]; $field = $this->config->action->objectNameFields[$objectType]; - - $objectNames[$objectType] = $this->dao->select("id, $field AS name")->from($table)->where('id')->in($objectIds)->fetchPairs(); + if($objectType == 'pipeline') + { + $objectNames['jenkins'] = $this->dao->select("id, $field AS name")->from($table)->where('id')->in($objectIds)->andWhere('type')->eq('jenkins')->fetchPairs(); + $objectNames['gitlab'] = $this->dao->select("id, $field AS name")->from($table)->where('id')->in($objectIds)->andWhere('type')->eq('gitlab')->fetchPairs(); + } + else + { + $objectNames[$objectType] = $this->dao->select("id, $field AS name")->from($table)->where('id')->in($objectIds)->fetchPairs(); + } } /* Add name field to the trashes. */ - foreach($trashes as $trash) $trash->objectName = isset($objectNames[$trash->objectType][$trash->objectID]) ? $objectNames[$trash->objectType][$trash->objectID] : ''; + foreach($trashes as $trash) + { + $objectType = $trash->objectType; + if($objectType == 'pipeline') + { + if(isset($objectNames['gitlab'][$trash->objectID])) $objectType = 'gitlab'; + if(isset($objectNames['jenkins'][$trash->objectID])) $objectType = 'jenkins'; + $trash->objectType = $objectType; + } + $trash->objectName = isset($objectNames[$objectType][$trash->objectID]) ? $objectNames[$objectType][$trash->objectID] : ''; + } return $trashes; } diff --git a/module/action/view/trash.html.php b/module/action/view/trash.html.php index 1e0f21625f..bb1a8d656d 100755 --- a/module/action/view/trash.html.php +++ b/module/action/view/trash.html.php @@ -62,7 +62,7 @@ $flow = $config->action->customFlows[$action->objectType]; $module = $flow->module; } - if(strpos(',doclib,module,webhook,', ",{$module},") !== false) + if(strpos($this->config->action->noLinkModules, ",{$module},") !== false) { echo $action->objectName; } From d80633e29bfb4427372b4c86a5a7fdf6fdf72b3b Mon Sep 17 00:00:00 2001 From: holan20180123 Date: Thu, 5 Aug 2021 16:04:42 +0800 Subject: [PATCH 2/7] * Add go back link in import issue. --- module/gitlab/view/importissue.html.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/module/gitlab/view/importissue.html.php b/module/gitlab/view/importissue.html.php index dfb478ea02..7411bd12a6 100644 --- a/module/gitlab/view/importissue.html.php +++ b/module/gitlab/view/importissue.html.php @@ -14,6 +14,11 @@

gitlab->importIssue;?>

+ +
+ goback, $this->createLink('repo', 'maintain'), 'self', '', 'btn btn-primary');?> +
+
From d90d4580f4ee1d4eee30384a776f66ba78061cc7 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Thu, 5 Aug 2021 16:05:25 +0800 Subject: [PATCH 3/7] * adjust for error. --- module/job/model.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/module/job/model.php b/module/job/model.php index 0493080e36..7a6207ac4e 100644 --- a/module/job/model.php +++ b/module/job/model.php @@ -129,8 +129,8 @@ class jobModel extends model if(strtolower($job->engine) == 'gitlab') { $repo = $this->loadModel('repo')->getRepoByID($job->repo); - $job->server = $repo->gitlab; - $job->pipeline = $repo->project; + $job->server = zget($repo, 'gitlab', ''); + $job->pipeline = zget($repo, 'project', ''); } unset($job->jkServer); @@ -213,8 +213,8 @@ class jobModel extends model if(strtolower($job->engine) == 'gitlab') { $repo = $this->loadModel('repo')->getRepoByID($job->repo); - $job->server = $repo->gitlab; - $job->pipeline = $repo->project; + $job->server = zget($repo, 'gitlab', ''); + $job->pipeline = zget($repo, 'project', ''); } unset($job->jkServer); From 98c0e920b44625e21d76e94d45a5d361c5f9d2f7 Mon Sep 17 00:00:00 2001 From: hufangzhou Date: Thu, 5 Aug 2021 16:10:56 +0800 Subject: [PATCH 4/7] * Fix bug #13887. --- module/todo/view/edit.html.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/module/todo/view/edit.html.php b/module/todo/view/edit.html.php index 44f7d0dbdc..4d754ab2a7 100644 --- a/module/todo/view/edit.html.php +++ b/module/todo/view/edit.html.php @@ -181,7 +181,8 @@
-
+ +
From 34fca03d67eabba3c2d2ee5995a999839162d942 Mon Sep 17 00:00:00 2001 From: holan20180123 Date: Thu, 5 Aug 2021 16:11:04 +0800 Subject: [PATCH 5/7] * Fix bug #13967. --- module/gitlab/control.php | 2 +- module/gitlab/view/importissue.html.php | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/module/gitlab/control.php b/module/gitlab/control.php index 7b57720e1b..22d0ed511f 100644 --- a/module/gitlab/control.php +++ b/module/gitlab/control.php @@ -345,7 +345,7 @@ class gitlab extends control $options = ""; foreach($executions as $index =>$execution) { - $options .= ""; + $options .= ""; } return $this->send($options); } diff --git a/module/gitlab/view/importissue.html.php b/module/gitlab/view/importissue.html.php index 7411bd12a6..dd9f474128 100644 --- a/module/gitlab/view/importissue.html.php +++ b/module/gitlab/view/importissue.html.php @@ -11,6 +11,9 @@ */ ?> +

gitlab->importIssue;?>

From 2adb370548d12ceb35f53241ed6ef742862898ad Mon Sep 17 00:00:00 2001 From: holan20180123 Date: Thu, 5 Aug 2021 16:13:53 +0800 Subject: [PATCH 6/7] * Adjust style of job browse. --- module/job/view/browse.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/job/view/browse.html.php b/module/job/view/browse.html.php index 2d99b02251..9171422730 100644 --- a/module/job/view/browse.html.php +++ b/module/job/view/browse.html.php @@ -60,7 +60,7 @@ pipeline) . '@' . $job->jenkinsName;?> job->getTriggerConfig($job);?> - + lastStatus) echo zget($lang->compile->statusList, $job->lastStatus);?> lastStatus) echo $job->lastExec;?> From 3fc2eecb3c3f7b3416f4afafd794b0d469e2d8cc Mon Sep 17 00:00:00 2001 From: wangyidong Date: Thu, 5 Aug 2021 16:25:08 +0800 Subject: [PATCH 7/7] * adjust for show dao error. --- module/job/control.php | 50 ++++++++++++++++++++++++++++++++++++++++-- module/repo/model.php | 1 + 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/module/job/control.php b/module/job/control.php index 477133b475..f433b00804 100644 --- a/module/job/control.php +++ b/module/job/control.php @@ -64,7 +64,30 @@ class job extends control if($_POST) { $jobID = $this->job->create(); - if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); + if(dao::isError()) + { + $errors = dao::getError(); + if($this->post->engine == 'gitlab' and isset($errors['server'])) + { + $errors['gitlabRepo'][] = sprintf($this->lang->error->notempty, $this->lang->job->repo); + unset($errors['server']); + unset($errors['pipeline']); + } + elseif($this->post->engine == 'jenkins') + { + if(isset($errors['server'])) + { + $errors['jkServer'] = $errors['server']; + unset($errors['server']); + } + if(isset($errors['pipeline'])) + { + $errors['jkTask'] = $errors['pipeline']; + unset($errors['pipeline']); + } + } + return $this->send(array('result' => 'fail', 'message' => $errors)); + } if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $jobID)); return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse'))); } @@ -108,7 +131,30 @@ class job extends control if($_POST) { $this->job->update($id); - if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); + if(dao::isError()) + { + $errors = dao::getError(); + if($this->post->engine == 'gitlab' and isset($errors['server'])) + { + $errors['gitlabRepo'][] = sprintf($this->lang->error->notempty, $this->lang->job->repo); + unset($errors['server']); + unset($errors['pipeline']); + } + elseif($this->post->engine == 'jenkins') + { + if(isset($errors['server'])) + { + $errors['jkServer'] = $errors['server']; + unset($errors['server']); + } + if(isset($errors['pipeline'])) + { + $errors['jkTask'] = $errors['pipeline']; + unset($errors['pipeline']); + } + } + return $this->send(array('result' => 'fail', 'message' => $errors)); + } return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse'))); } diff --git a/module/repo/model.php b/module/repo/model.php index f693c6dec3..56eadabe71 100644 --- a/module/repo/model.php +++ b/module/repo/model.php @@ -606,6 +606,7 @@ class repoModel extends model public function getProductsByRepo($repoID) { $repo = $this->getRepoByID($repoID); + if(empty($repo)) return array(); return $this->dao->select('id,name')->from(TABLE_PRODUCT) ->where('id')->in($repo->product) ->andWhere('deleted')->eq(0)