Making commit links work throughout the UI
This commit is contained in:
parent
d2d966ee69
commit
0193f07de2
5 changed files with 33 additions and 10 deletions
|
|
@ -9,10 +9,8 @@
|
|||
|
||||
namespace PHPCI;
|
||||
|
||||
use b8\Store\Factory;
|
||||
use PHPCI\Model\Build;
|
||||
use PHPCI\Model\Build\LocalBuild;
|
||||
use PHPCI\Model\Build\GithubBuild;
|
||||
use PHPCI\Model\Build\BitbucketBuild;
|
||||
|
||||
/**
|
||||
* PHPCI Build Factory - Takes in a generic "Build" and returns a type-specific build model.
|
||||
|
|
@ -20,9 +18,21 @@ use PHPCI\Model\Build\BitbucketBuild;
|
|||
*/
|
||||
class BuildFactory
|
||||
{
|
||||
/**
|
||||
* @param $buildId
|
||||
* @return Build
|
||||
*/
|
||||
public static function getBuildById($buildId)
|
||||
{
|
||||
$build = Factory::getStore('Build')->getById($buildId);
|
||||
|
||||
return self::getBuild($build);
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a generic build and returns a type-specific build model.
|
||||
* @return \PHPCI\Model\Build\LocalBuild|\PHPCI\Model\Build\GithubBuild|\PHPCI\Model\Build\BitbucketBuild
|
||||
* @param Build $base The build from which to get a more specific build type.
|
||||
* @return Build
|
||||
*/
|
||||
public static function getBuild(Build $base)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
namespace PHPCI\Controller;
|
||||
|
||||
use b8;
|
||||
use PHPCI\BuildFactory;
|
||||
use PHPCI\Model\Build;
|
||||
|
||||
/**
|
||||
|
|
@ -35,7 +36,7 @@ class BuildController extends \PHPCI\Controller
|
|||
*/
|
||||
public function view($buildId)
|
||||
{
|
||||
$build = $this->buildStore->getById($buildId);
|
||||
$build = BuildFactory::getBuildById($buildId);
|
||||
$this->view->plugins = $this->getUiPlugins();
|
||||
$this->view->build = $build;
|
||||
$this->view->data = $this->getBuildData($build);
|
||||
|
|
@ -63,7 +64,7 @@ class BuildController extends \PHPCI\Controller
|
|||
*/
|
||||
public function data($buildId)
|
||||
{
|
||||
die($this->getBuildData($this->buildStore->getById($buildId)));
|
||||
die($this->getBuildData(BuildFactory::getBuildById($buildId)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -71,7 +72,7 @@ class BuildController extends \PHPCI\Controller
|
|||
*/
|
||||
public function meta($buildId)
|
||||
{
|
||||
$build = $this->buildStore->getById($buildId);
|
||||
$build = BuildFactory::getBuildById($buildId);
|
||||
$key = $this->getParam('key', null);
|
||||
$numBuilds = $this->getParam('num_builds', 1);
|
||||
$data = null;
|
||||
|
|
@ -104,7 +105,7 @@ class BuildController extends \PHPCI\Controller
|
|||
*/
|
||||
public function rebuild($buildId)
|
||||
{
|
||||
$copy = $this->buildStore->getById($buildId);
|
||||
$copy = BuildFactory::getBuildById($buildId);
|
||||
|
||||
$build = new Build();
|
||||
$build->setProjectId($copy->getProjectId());
|
||||
|
|
@ -128,7 +129,7 @@ class BuildController extends \PHPCI\Controller
|
|||
throw new \Exception('You do not have permission to do that.');
|
||||
}
|
||||
|
||||
$build = $this->buildStore->getById($buildId);
|
||||
$build = BuildFactory::getBuildById($buildId);
|
||||
|
||||
if (!$build) {
|
||||
$this->response->setResponseCode(404);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
namespace PHPCI\Controller;
|
||||
|
||||
use b8;
|
||||
use PHPCI\BuildFactory;
|
||||
|
||||
/**
|
||||
* Home Controller - Displays the PHPCI Dashboard.
|
||||
|
|
@ -73,6 +74,11 @@ class HomeController extends \PHPCI\Controller
|
|||
{
|
||||
$builds = $this->buildStore->getWhere(array(), 5, 0, array(), array('id' => 'DESC'));
|
||||
$view = new b8\View('BuildsTable');
|
||||
|
||||
foreach ($builds['items'] as &$build) {
|
||||
$build = BuildFactory::getBuild($build);
|
||||
}
|
||||
|
||||
$view->builds = $builds['items'];
|
||||
|
||||
return $view->render();
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
namespace PHPCI\Controller;
|
||||
|
||||
use PHPCI\BuildFactory;
|
||||
use PHPCI\Model\Build;
|
||||
use PHPCI\Model\Project;
|
||||
use b8;
|
||||
|
|
@ -113,6 +114,11 @@ class ProjectController extends \PHPCI\Controller
|
|||
$order = array('id' => 'DESC');
|
||||
$builds = $this->buildStore->getWhere($criteria, 10, $start, array(), $order);
|
||||
$view = new b8\View('BuildsTable');
|
||||
|
||||
foreach ($builds['items'] as &$build) {
|
||||
$build = BuildFactory::getBuild($build);
|
||||
}
|
||||
|
||||
$view->builds = $builds['items'];
|
||||
|
||||
return array($view->render(), $builds['count']);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<div id="title">
|
||||
<h1 style="display: inline-block">Build #<?php print $build->getId(); ?></h1>
|
||||
<h1 style="display: inline-block"><?php print $build->getProject()->getTitle(); ?> - Build #<?php print $build->getId(); ?></h1>
|
||||
|
||||
<div id="build-info">
|
||||
<strong>Branch: </strong> <?php print $build->getBranch(); ?><br>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue