diff --git a/module/job/control.php b/module/job/control.php index f6440f3af3..3a2b28a1e1 100644 --- a/module/job/control.php +++ b/module/job/control.php @@ -49,12 +49,24 @@ class job extends control $pager = new pager($recTotal, $recPerPage, $pageID); $this->app->loadLang('compile'); - $this->view->jobList = $this->job->getList($repoID, $orderBy, $pager); + $jobList = $this->job->getList($repoID, $orderBy, $pager); + $this->loadModel('gitlab'); + foreach($jobList as $job) + { + $job->canExec = true; + if($job->engine == 'gitlab') + { + $pipeline = json_decode($job->pipeline); + $branch = $this->gitlab->apiGetSingleBranch($job->server, $pipeline->project, $pipeline->reference); + if($branch and isset($branch->can_push) and !$branch->can_push) $job->canExec = false; + } + } $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->jobList = $jobList; $this->view->orderBy = $orderBy; $this->view->pager = $pager; diff --git a/module/job/view/browse.html.php b/module/job/view/browse.html.php index 0a1e92e209..34daa1d6bc 100644 --- a/module/job/view/browse.html.php +++ b/module/job/view/browse.html.php @@ -74,7 +74,7 @@ repo}&jobID=$id", '', 'list', 'history'); common::printIcon('job', 'edit', "jobID=$id", '', 'list', 'edit'); - common::printIcon('job', 'exec', "jobID=$id", '', 'list', 'play'); + common::printIcon('job', 'exec', "jobID=$id", '', 'list', 'play', '', $job->canExec ? '' : 'disabled'); if(common::hasPriv('job', 'delete')) echo html::a($this->createLink('job', 'delete', "jobID=$id"), '', 'hiddenwin', "title='{$lang->job->delete}' class='btn'"); ?>