Fixed build buttons block in project page

This commit is contained in:
Dmitry Khomutov 2017-04-09 22:39:20 +07:00
parent 8a5f15ad78
commit 1b11ec18ac
No known key found for this signature in database
GPG key ID: 7EB36C9576F9ECB9
2 changed files with 80 additions and 93 deletions

View file

@ -53,13 +53,19 @@ class ProjectController extends PHPCensor\Controller
}
/**
* View a specific project.
*/
* View a specific project.
*
* @param integer $projectId
*
* @throws NotFoundException
*
* @return string
*/
public function view($projectId)
{
$branch = $this->getParam('branch', '');
$branch = $this->getParam('branch', '');
$environment = $this->getParam('environment', '');
$project = $this->projectStore->getById($projectId);
$project = $this->projectStore->getById($projectId);
if (empty($project)) {
throw new NotFoundException(Lang::get('project_x_not_found', $projectId));
@ -76,18 +82,18 @@ class ProjectController extends PHPCensor\Controller
return $response;
}
$this->view->builds = $builds[0];
$this->view->total = $builds[1];
$this->view->project = $project;
$this->view->branch = urldecode($branch);
$this->view->branches = $this->projectStore->getKnownBranches($projectId);
$this->view->environment = urldecode($environment);
$this->view->builds = $builds[0];
$this->view->total = $builds[1];
$this->view->project = $project;
$this->view->branch = urldecode($branch);
$this->view->branches = $this->projectStore->getKnownBranches($projectId);
$this->view->environment = urldecode($environment);
$this->view->environments = $project->getEnvironmentsNames();
$this->view->page = $page;
$this->view->pages = $pages;
$this->view->perPage = $perPage;
$this->view->page = $page;
$this->view->pages = $pages;
$this->view->perPage = $perPage;
$this->layout->title = $project->getTitle();
$this->layout->title = $project->getTitle();
if (!empty($this->view->environment)) {
$this->layout->subtitle = $this->view->environment;
} else {
@ -98,8 +104,17 @@ class ProjectController extends PHPCensor\Controller
}
/**
* Create a new pending build for a project.
*/
* Create a new pending build for a project.
*
* @param integer $projectId
* @param string $type Build type: 'environment'|'branch'
* @param string $id Build type id: environment name or branch name
*
* @throws NotFoundException
*
* @return b8\Http\Response\RedirectResponse
*
*/
public function build($projectId, $type = null, $id = null)
{
/* @var \PHPCensor\Model\Project $project */

View file

@ -1,13 +1,13 @@
<?php use PHPCensor\Helper\Lang; ?>
<script>
var PROJECT_ID = <?php print $project->getId(); ?>;
var PROJECT_ENVIRONMENT = '<?php print $environment; ?>';
var PROJECT_BRANCH = '<?php print $branch; ?>';
var PER_PAGE = <?php print $perPage; ?>;
var PROJECT_ID = <?= $project->getId(); ?>;
var PROJECT_ENVIRONMENT = '<?= $environment; ?>';
var PROJECT_BRANCH = '<?= $branch; ?>';
var PER_PAGE = <?= $perPage; ?>;
</script>
<div class="clearfix" style="margin-bottom: 20px;">
<a class="btn btn-default" href="<?php print APP_URL . 'project/edit/' . $project->getId(); ?>">
<a class="btn btn-default" href="<?= APP_URL . 'project/edit/' . $project->getId(); ?>">
<?php Lang::out('edit_project'); ?>
</a>
@ -17,85 +17,57 @@
<div class="pull-right btn-group">
<?php if (!$project->getArchived()): ?>
<?php if($this->User()->getIsAdmin()): ?>
<div class="btn-group build-btn">
<button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown">
<?php Lang::out('build_now_debug'); ?>&nbsp;&nbsp;<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<?php if(!empty($environments)): ?>
<?php foreach ($environments as $currentEnvironment) : ?>
<li <?php echo ($currentEnvironment == $environment) ? 'class="active"' : ''?>>
<a href="<?php echo APP_URL ?>project/build/<?php print $project->getId(); ?>/environment/<?php echo urlencode($currentEnvironment) ?>?debug=1">
<i class="fa fa-cog"></i><?php echo $currentEnvironment ?>
</a>
</li>
<?php endforeach; ?>
<li class="divider"></li>
<?php endif; ?>
<?php foreach ($branches as $currentBranch) : ?>
<li <?php echo ($currentBranch == $branch) ? 'class="active"' : ''?>>
<a href="<?php echo APP_URL ?>project/build/<?php print $project->getId(); ?>/branch/<?php echo urlencode($currentBranch) ?>?debug=1">
<i class="fa fa-code-fork"></i><?php echo $currentBranch ?>
</a>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php if ($this->User()->getIsAdmin()): ?>
<?php if (!empty($environment)): ?>
<a class="btn btn-danger" href="<?= APP_URL . 'project/build/' . $project->getId(); ?>/environment/<?= urlencode($environment); ?>?debug=1">
<?php Lang::out('build_now_debug'); ?>
</a>
<?php elseif (!empty($branch)): ?>
<a class="btn btn-danger" href="<?= APP_URL . 'project/build/' . $project->getId(); ?>/branch/<?= urlencode($branch); ?>?debug=1">
<?php Lang::out('build_now_debug'); ?>
</a>
<?php else: ?>
<a class="btn btn-danger" href="<?= APP_URL . 'project/build/' . $project->getId(); ?>?debug=1">
<?php Lang::out('build_now_debug'); ?>
</a>
<?php endif; ?>
<?php endif; ?>
<div class="btn-group build-btn">
<button type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown">
<?php Lang::out('build_now'); ?>&nbsp;&nbsp;<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<?php if(!empty($environments)): ?>
<?php foreach ($environments as $currentEnvironment) : ?>
<li <?php echo ($currentEnvironment == $environment) ? 'class="active"' : ''?>>
<a href="<?php echo APP_URL ?>project/build/<?php print $project->getId(); ?>/environment/<?php echo urlencode($currentEnvironment) ?>">
<i class="fa fa-cog"></i><?php echo $currentEnvironment ?>
</a>
</li>
<?php endforeach; ?>
<li class="divider"></li>
<?php endif; ?>
<?php foreach ($branches as $currentBranch) : ?>
<li <?php echo ($currentBranch == $branch) ? 'class="active"' : ''?>>
<a href="<?php echo APP_URL ?>project/build/<?php print $project->getId(); ?>/branch/<?php echo urlencode($currentBranch) ?>">
<i class="fa fa-code-fork"></i><?php echo $currentBranch ?>
</a>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php if (!empty($environment)): ?>
<a class="btn btn-success" href="<?= APP_URL . 'project/build/' . $project->getId(); ?>/environment/<?= urlencode($environment); ?>">
<?php Lang::out('build_now'); ?>
</a>
<?php elseif (!empty($branch)): ?>
<a class="btn btn-success" href="<?= APP_URL . 'project/build/' . $project->getId(); ?>/branch/<?= urlencode($branch); ?>">
<?php Lang::out('build_now'); ?>
</a>
<?php else: ?>
<a class="btn btn-success" href="<?= APP_URL . 'project/build/' . $project->getId(); ?>">
<?php Lang::out('build_now'); ?>
</a>
<?php endif; ?>
<?php endif; ?>
<div class="btn-group environment-btn pull-right">
<div class="btn-group branch-btn pull-right">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<?php
if (!empty($environment)) {
print Lang::get('environment_x', $environment);
<?php if (!empty($environment)) {
Lang::out('environment_x', $environment);
} elseif (!empty($branch)) {
print Lang::get('branch_x', $branch);
Lang::out('branch_x', $branch);
} else {
print Lang::get('all');
}
?>&nbsp;&nbsp;<span class="caret"></span>
Lang::out('all');
} ?>&nbsp;&nbsp;<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="<?php echo APP_URL ?>project/view/<?php print $project->getId(); ?>"><?php Lang::out('all'); ?></a></li>
<li><a href="<?= APP_URL; ?>project/view/<?= $project->getId(); ?>"><?php Lang::out('all'); ?></a></li>
<li class="divider"></li>
<?php if(!empty($environments)): ?>
<?php foreach ($environments as $currentEnvironment) : ?>
<li <?php echo ($currentEnvironment == $environment) ? 'class="active"' : ''?>>
<a href="<?php echo APP_URL ?>project/view/<?php print $project->getId(); ?>?environment=<?php echo urlencode($currentEnvironment) ?>">
<i class="fa fa-cog"></i><?php echo $currentEnvironment ?>
<li <?= ($currentEnvironment == $environment) ? 'class="active"' : ''; ?>>
<a href="<?= APP_URL; ?>project/view/<?= $project->getId(); ?>?environment=<?= urlencode($currentEnvironment); ?>">
<i class="fa fa-cog"></i><?= $currentEnvironment; ?>
</a>
</li>
<?php endforeach; ?>
@ -103,9 +75,9 @@
<?php endif; ?>
<?php foreach ($branches as $currentBranch) : ?>
<li <?php echo ($currentBranch == $branch) ? 'class="active"' : ''?>>
<a href="<?php echo APP_URL ?>project/view/<?php print $project->getId(); ?>?branch=<?php echo urlencode($currentBranch) ?>">
<i class="fa fa-code-fork"></i><?php echo $currentBranch ?>
<li <?= ($currentBranch == $branch) ? 'class="active"' : ''; ?>>
<a href="<?= APP_URL; ?>project/view/<?= $project->getId(); ?>?branch=<?= urlencode($currentBranch); ?>">
<i class="fa fa-code-fork"></i><?= $currentBranch; ?>
</a>
</li>
<?php endforeach; ?>
@ -119,7 +91,7 @@
<div class="col-lg-9 col-md-8 col-sm-8">
<div class="box">
<div class="box-header">
<h3 class="box-title"><?php Lang::out('builds'); ?> (<?php print $total; ?>)</h3>
<h3 class="box-title"><?php Lang::out('builds'); ?> (<?= $total; ?>)</h3>
</div>
<table class="table table-hover">
<thead>
@ -135,7 +107,7 @@
</tr>
</thead>
<tbody id="latest-builds">
<?php print $builds; ?>
<?= $builds; ?>
</tbody>
</table>
</div>
@ -253,7 +225,7 @@
break;
}
?>
<br><br><strong style="word-wrap: break-word;"><?php print $url; ?></strong>
<br><br><strong style="word-wrap: break-word;"><?= $url; ?></strong>
</div>
</div>
<?php endif; ?>
@ -268,7 +240,7 @@
</button>
</div>
</div>
<div class="box-body" style="word-break: break-all;"><?php print $project->getSshPublicKey(); ?></div>
<div class="box-body" style="word-break: break-all;"><?= $project->getSshPublicKey(); ?></div>
</div>
<?php endif; ?>
</div>