From 0044a55b76e5531081e200c6e781e1d9b836affe Mon Sep 17 00:00:00 2001
From: liyuchun <563917701@qq.com>
Date: Tue, 5 Jul 2022 05:48:02 +0000
Subject: [PATCH] * Finish task #59439.
---
module/ci/model.php | 2 +
module/common/lang/menu.php | 2 +-
module/compile/control.php | 19 +++++--
module/compile/model.php | 4 +-
module/compile/view/browse.html.php | 4 +-
module/compile/view/logs.html.php | 2 +-
module/job/control.php | 12 +++--
module/job/model.php | 6 ++-
module/job/view/browse.html.php | 4 +-
module/job/view/edit.html.php | 2 +-
module/mr/control.php | 3 +-
module/mr/view/browse.html.php | 8 ---
module/repo/config.php | 3 ++
module/repo/control.php | 31 +++++++++---
module/repo/css/common.css | 18 -------
module/repo/model.php | 59 ++--------------------
module/repo/view/ajaxgetdropmenu.html.php | 60 +++++++++++++++++++++++
17 files changed, 131 insertions(+), 108 deletions(-)
create mode 100644 module/repo/view/ajaxgetdropmenu.html.php
diff --git a/module/ci/model.php b/module/ci/model.php
index 076a2fc22c..2f5bf854b0 100644
--- a/module/ci/model.php
+++ b/module/ci/model.php
@@ -25,6 +25,8 @@ class ciModel extends model
session_write_close();
}
common::setMenuVars('devops', $this->session->repoID);
+
+ $this->lang->switcherMenu = $this->loadModel('repo')->getSwitcher($this->session->repoID);
}
/**
diff --git a/module/common/lang/menu.php b/module/common/lang/menu.php
index dd835b63c3..ce828790b9 100644
--- a/module/common/lang/menu.php
+++ b/module/common/lang/menu.php
@@ -396,7 +396,7 @@ $lang->qa->dividerMenu = ',bug,testtask,caselib,';
$lang->devops->menu = new stdclass();
$lang->devops->menu->code = array('link' => "{$lang->repo->common}|repo|browse|repoID=%s", 'alias' => 'diff,view,revision,log,blame,showsynccommit');
$lang->devops->menu->mr = array('link' => "{$lang->devops->mr}|mr|browse|repoID=%s");
-$lang->devops->menu->compile = array('link' => "{$lang->devops->compile}|job|browse", 'subModule' => 'compile,job');
+$lang->devops->menu->compile = array('link' => "{$lang->devops->compile}|job|browse|repoID=%s", 'subModule' => 'compile,job');
$lang->devops->menu->app = array('link' => "{$lang->app}|devops|app|%s");
$lang->devops->menu->set = array('link' => "{$lang->devops->set}|repo|maintain", 'subModule' => 'gitlab,jenkins,sonarqube', 'alias' => 'setrules,create,edit');
diff --git a/module/compile/control.php b/module/compile/control.php
index 8c37b3a7b6..c17fa7d59a 100644
--- a/module/compile/control.php
+++ b/module/compile/control.php
@@ -22,12 +22,13 @@ class compile extends control
public function __construct($moduleName = '', $methodName = '')
{
parent::__construct($moduleName, $methodName);
- $this->loadModel('ci')->setMenu();
+ if($methodName != 'browse') $this->loadModel('ci')->setMenu();
}
/**
* Browse jenkins build.
*
+ * @param int $repoID
* @param int $jobID
* @param string $orderBy
* @param int $recTotal
@@ -36,8 +37,17 @@ class compile extends control
* @access public
* @return void
*/
- public function browse($jobID = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
+ public function browse($repoID = 0, $jobID = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
{
+ if($jobID)
+ {
+ $job = $this->loadModel('job')->getById($jobID);
+ $repoID = $job->repo;
+
+ $this->view->job = $job;
+ }
+ $this->loadModel('ci')->setMenu($repoID);
+
$this->app->loadClass('pager', $static = true);
$pager = new pager($recTotal, $recPerPage, $pageID);
@@ -45,10 +55,9 @@ class compile extends control
$this->view->position[] = html::a($this->createLink('job', 'browse'), $this->lang->ci->job);
$this->view->position[] = $this->lang->compile->browse;
- $this->loadModel('job');
- if($jobID) $this->view->job = $this->job->getById($jobID);
+ $this->view->repoID = $repoID;
$this->view->jobID = $jobID;
- $this->view->buildList = $this->compile->getList($jobID, $orderBy, $pager);
+ $this->view->buildList = $this->compile->getList($repoID, $jobID, $orderBy, $pager);
$this->view->orderBy = $orderBy;
$this->view->pager = $pager;
$this->display();
diff --git a/module/compile/model.php b/module/compile/model.php
index 6cb2376f93..7ffbae88c1 100644
--- a/module/compile/model.php
+++ b/module/compile/model.php
@@ -38,13 +38,14 @@ class compileModel extends model
/**
* Get build list.
*
+ * @param int $repoID
* @param int $jobID
* @param string $orderBy
* @param object $pager
* @access public
* @return array
*/
- public function getList($jobID, $orderBy = 'id_desc', $pager = null)
+ public function getList($repoID, $jobID, $orderBy = 'id_desc', $pager = null)
{
return $this->dao->select('t1.id, t1.name, t1.job, t1.status, t1.createdDate, t1.testtask, t2.pipeline, t2.triggerType, t2.comment, t2.atDay, t2.atTime, t2.engine, t3.name as repoName, t4.name as jenkinsName')->from(TABLE_COMPILE)->alias('t1')
->leftJoin(TABLE_JOB)->alias('t2')->on('t1.job=t2.id')
@@ -52,6 +53,7 @@ class compileModel extends model
->leftJoin(TABLE_PIPELINE)->alias('t4')->on('t2.server=t4.id')
->where('t1.deleted')->eq('0')
->andWhere('t1.job')->ne('0')
+ ->beginIF(!empty($repoID))->andWhere('t3.id')->eq($repoID)->fi()
->beginIF(!empty($jobID))->andWhere('t1.job')->eq($jobID)->fi()
->orderBy($orderBy)
->page($pager)
diff --git a/module/compile/view/browse.html.php b/module/compile/view/browse.html.php
index 0ddae35387..2880e83ba1 100644
--- a/module/compile/view/browse.html.php
+++ b/module/compile/view/browse.html.php
@@ -14,8 +14,8 @@
createLink('job', 'browse'), "{$lang->ci->task}", '', "class='btn btn-link'");
- echo html::a($this->createLink('compile', 'browse'), "" . ($jobID ? $job->name : '') . " {$lang->ci->history}", '', "class='btn btn-link btn-active-text'");
+ echo html::a($this->createLink('job', 'browse', "repoID=$repoID"), "{$lang->ci->task}", '', "class='btn btn-link'");
+ echo html::a($this->createLink('compile', 'browse', "repoID=$repoID&jobID=$jobID"), "" . ($jobID ? $job->name : '') . " {$lang->ci->history}", '', "class='btn btn-link btn-active-text'");
?>
diff --git a/module/compile/view/logs.html.php b/module/compile/view/logs.html.php
index 52655ee355..7e1353da7b 100644
--- a/module/compile/view/logs.html.php
+++ b/module/compile/view/logs.html.php
@@ -19,7 +19,7 @@
engine == 'gitlab') echo html::a(helper::createLink('ci', "checkCompileStatus", "compileID={$build->id}"), " ". $lang->compile->refresh, '', "class='btn btn-secondary' id='refreshBtn'");?>
- job"), " ". $lang->goback, '', "class='btn btn-secondary'");?>
+ repo}&jobID={$build->job}"), " ". $lang->goback, '', "class='btn btn-secondary'");?>
diff --git a/module/job/control.php b/module/job/control.php
index 967db36bd7..8b834d7008 100644
--- a/module/job/control.php
+++ b/module/job/control.php
@@ -22,7 +22,7 @@ class job extends control
public function __construct($moduleName = '', $methodName = '')
{
parent::__construct($moduleName, $methodName);
- $this->loadModel('ci')->setMenu();
+ if($methodName != 'browse') $this->loadModel('ci')->setMenu();
$this->projectID = isset($_GET['project']) ? $_GET['project'] : 0;
}
@@ -36,17 +36,21 @@ class job extends control
* @access public
* @return void
*/
- public function browse($orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
+ public function browse($repoID = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
{
+ /* Set session. */
+ $this->loadModel('ci')->setMenu($repoID);
+
$this->app->loadClass('pager', $static = true);
$pager = new pager($recTotal, $recPerPage, $pageID);
$this->app->loadLang('compile');
- $this->view->jobList = $this->job->getList($orderBy, $pager);
+ $this->view->jobList = $this->job->getList($repoID, $orderBy, $pager);
$this->view->title = $this->lang->ci->job . $this->lang->colon . $this->lang->job->browse;
$this->view->position[] = $this->lang->ci->job;
$this->view->position[] = $this->lang->job->browse;
+ $this->view->repoID = $repoID;
$this->view->orderBy = $orderBy;
$this->view->pager = $pager;
@@ -167,7 +171,7 @@ class job extends control
}
$this->loadModel('action')->create('job', $id, 'edited');
- return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse')));
+ return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse', "repoID={$job->repo}")));
}
$repo = $this->loadModel('repo')->getRepoByID($job->repo);
diff --git a/module/job/model.php b/module/job/model.php
index 6d6a85b99d..b8b0933748 100644
--- a/module/job/model.php
+++ b/module/job/model.php
@@ -36,17 +36,21 @@ class jobModel extends model
/**
* Get job list.
*
+ * @param int $repoID
* @param string $orderBy
* @param object $pager
+ * @param string $engine
+ * @param string $pipeline
* @access public
* @return array
*/
- public function getList($orderBy = 'id_desc', $pager = null, $engine = '', $pipeline = '')
+ public function getList($repoID = 0, $orderBy = 'id_desc', $pager = null, $engine = '', $pipeline = '')
{
return $this->dao->select('t1.*, t2.name as repoName, t3.name as jenkinsName')->from(TABLE_JOB)->alias('t1')
->leftJoin(TABLE_REPO)->alias('t2')->on('t1.repo=t2.id')
->leftJoin(TABLE_PIPELINE)->alias('t3')->on('t1.server=t3.id')
->where('t1.deleted')->eq('0')
+ ->beginIF($repoID)->andWhere('t1.repo')->eq($repoID)->fi()
->beginIF($engine)->andWhere('t1.engine')->eq($engine)->fi()
->beginIF($pipeline)->andWhere('t1.pipeline')->eq($pipeline)->fi()
->orderBy($orderBy)
diff --git a/module/job/view/browse.html.php b/module/job/view/browse.html.php
index eac0cb5328..ec44c6dd42 100644
--- a/module/job/view/browse.html.php
+++ b/module/job/view/browse.html.php
@@ -13,8 +13,8 @@
- createLink('job', 'browse'), "{$lang->ci->task}", '', "class='btn btn-link btn-active-text'");?>
- createLink('compile', 'browse'), "{$lang->ci->history}", '', "class='btn btn-link'");?>
+ createLink('job', 'browse', "repoID=$repoID"), "{$lang->ci->task}", '', "class='btn btn-link btn-active-text'");?>
+ createLink('compile', 'browse', "repoID=$repoID"), "{$lang->ci->history}", '', "class='btn btn-link'");?>