Skip to content
This repository was archived by the owner on Feb 15, 2025. It is now read-only.

Commit 0e7679b

Browse files
JoolsMcFlyDan Cryer
authored andcommitted
adding a setting to display branch names in Dashboard (#1295)
* adding a setting to display branch names in Dashboard * changing method name to be camel caps * fixed Code Sniffer and Dockblock Checker errors in TapParser * removed white space in TapParser docblock and added new line in css file * fixed branch name
1 parent a7ec2c7 commit 0e7679b

File tree

9 files changed

+102
-6
lines changed

9 files changed

+102
-6
lines changed

PHPCI/Controller/HomeController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ public function index()
5959
$build = BuildFactory::getBuild($build);
6060
}
6161

62+
$this->view->display_branch = $this->config->get('phpci.latest_builds.show_branch', false);
63+
6264
$this->view->builds = $builds;
6365
$this->view->groups = $this->getGroupInfo();
6466

PHPCI/Controller/SettingsController.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ public function index()
6666
$buildSettings = $this->settings['phpci']['build'];
6767
}
6868

69+
$latestBuildsSettings = array();
70+
if (isset($this->settings['phpci']['latest_builds'])) {
71+
$latestBuildsSettings = $this->settings['phpci']['latest_builds'];
72+
}
73+
6974
$emailSettings = array();
7075
if (isset($this->settings['phpci']['email_settings'])) {
7176
$emailSettings = $this->settings['phpci']['email_settings'];
@@ -78,6 +83,7 @@ public function index()
7883

7984
$this->view->configFile = PHPCI_CONFIG_FILE;
8085
$this->view->basicSettings = $this->getBasicForm($basicSettings);
86+
$this->view->latestBuildsSettings = $this->getLatestBuildsForm($latestBuildsSettings);
8187
$this->view->buildSettings = $this->getBuildForm($buildSettings);
8288
$this->view->github = $this->getGithubForm();
8389
$this->view->emailSettings = $this->getEmailForm($emailSettings);
@@ -178,6 +184,26 @@ public function basic()
178184

179185
return $response;
180186
}
187+
/**
188+
* Save basic settings.
189+
*/
190+
public function latestBuilds()
191+
{
192+
$this->requireAdmin();
193+
194+
$this->settings['phpci']['latest_builds'] = $this->getParams();
195+
$error = $this->storeSettings();
196+
197+
$response = new b8\Http\Response\RedirectResponse();
198+
199+
if ($error) {
200+
$response->setHeader('Location', PHPCI_URL . 'settings?saved=2');
201+
} else {
202+
$response->setHeader('Location', PHPCI_URL . 'settings?saved=1');
203+
}
204+
205+
return $response;
206+
}
181207

182208
/**
183209
* Handle authentication settings
@@ -427,6 +453,40 @@ protected function getBuildForm($values = array())
427453
return $form;
428454
}
429455

456+
/**
457+
* Get the Build settings form.
458+
* @param array $values
459+
* @return Form
460+
*/
461+
protected function getLatestBuildsForm($values = array())
462+
{
463+
$form = new Form();
464+
$form->setMethod('POST');
465+
$form->setAction(PHPCI_URL . 'settings/latestBuilds');
466+
467+
$field = new Form\Element\Checkbox('show_branch');
468+
$field->setRequired(false);
469+
$field->setLabel(Lang::get('show_branch'));
470+
$field->setContainerClass('form-group');
471+
$field->setClass('ml20px');
472+
$field->setCheckedValue(1);
473+
474+
if (isset($values['show_branch'])) {
475+
$field->setValue((int)$values['show_branch']);
476+
}
477+
478+
$form->addField($field);
479+
480+
$field = new Form\Element\Submit();
481+
$field->setValue(Lang::get('save'));
482+
$field->setClass('btn btn-success pull-right');
483+
$form->addField($field);
484+
485+
$form->setValues($values);
486+
487+
return $form;
488+
}
489+
430490
/**
431491
* Get the Basic settings form.
432492
* @param array $values
@@ -474,6 +534,7 @@ protected function getAuthenticationForm($values = array())
474534
$field = new Form\Element\Checkbox('disable_authentication');
475535
$field->setCheckedValue(1);
476536
$field->setRequired(false);
537+
$field->setClass('ml20px');
477538
$field->setLabel('Disable Authentication?');
478539
$field->setContainerClass('form-group');
479540
$field->setValue(0);

PHPCI/Languages/lang.en.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,9 @@
282282
'1_hour' => '1 Hour',
283283
'3_hours' => '3 Hours',
284284

285+
// Latest Builds
286+
'show_branch' => 'Display branches',
287+
285288
// Plugins
286289
'cannot_update_composer' => 'PHPCI cannot update composer.json for you as it is not writable.',
287290
'x_has_been_removed' => '%s has been removed.',
@@ -373,7 +376,7 @@
373376
'commit_id_option' => 'Commit ID to build',
374377
'branch_name_option' => 'Branch to build',
375378
'add_to_queue_failed' => 'Build created successfully, but failed to add to build queue. This usually happens
376-
when PHPCI is set to use a beanstalkd server that does not exist,
379+
when PHPCI is set to use a beanstalkd server that does not exist,
377380
or your beanstalkd server has stopped.',
378381

379382
// Run Command

PHPCI/Languages/lang.es.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@
265265
'1_hour' => '1 Hora',
266266
'3_hours' => '3 Horas',
267267

268+
'show_branch' => 'Mostrar las ramas',
269+
268270
// Plugins
269271
'cannot_update_composer' => 'PHPCI no puede actualizar composer.json porque no tiene permisos de escritura.',
270272
'x_has_been_removed' => '%s ha sido elimiando.',

PHPCI/Languages/lang.fr.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,8 @@
282282
'1_hour' => '1 Heure',
283283
'3_hours' => '3 Heures',
284284

285+
'show_branch' => 'Afficher les branches',
286+
285287
// Plugins
286288
'cannot_update_composer' => 'PHPCI ne peut pas mettre à jour le fichier composer.json pour vous, il n\'est pas modifiable.',
287289
'x_has_been_removed' => '%s a été supprimé.',

PHPCI/Plugin/Util/TapParser.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,21 @@ protected function testLine($line)
149149
return false;
150150
}
151151

152-
protected function testDepends($line) {
152+
/**
153+
*
154+
* @param string $line
155+
*
156+
* @return boolean
157+
*/
158+
protected function testDepends($line)
159+
{
153160
if (preg_match(self::TEST_DEPENDS_PATTERN, $line)) {
154161
$this->skippedTests++;
155162

156-
return TRUE;
163+
return true;
157164
}
158165

159-
return FALSE;
166+
return false;
160167
}
161168

162169
/**

PHPCI/View/Home/index.phtml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,17 @@
7474
<span class="time"><i class="fa fa-clock-o"></i> <?php print Lang::formatDateTime($updated, 'LT'); ?></span>
7575
<h3 class="timeline-header">
7676
<a href="<?php print PHPCI_URL; ?>project/view/<?php print $build->getProjectId(); ?>">
77-
<?php print $build->getProject()->getTitle(); ?>
77+
<?php echo $build->getProject()->getTitle()?>
7878
</a>
79-
-
79+
<?php
80+
if ($display_branch) {
81+
?>
82+
(
83+
<a href="<?php echo $build->getBranchLink();?>"><?php echo $build->getBranch(); ?></a>
84+
)
85+
<?php
86+
}
87+
?>
8088
<a href="<?php print PHPCI_URL; ?>build/view/<?php print $build->getId(); ?>">
8189
Build #<?php print $build->getId(); ?>
8290
</a>

PHPCI/View/Settings/index.phtml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@
3636
</div>
3737
</div>
3838

39+
<div class="box box-primary">
40+
<div class="box-header"><h3 class="box-title"><?php Lang::out('latest_builds'); ?></h3></div>
41+
<div class="box-body clearfix">
42+
<?php print $latestBuildsSettings; ?>
43+
</div>
44+
</div>
45+
3946
<div class="box box-primary">
4047
<div class="box-header"><h3 class="box-title"><?php Lang::out('build_settings'); ?></h3></div>
4148
<div class="box-body clearfix">

public/assets/css/AdminLTE-custom.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,7 @@
8282
#phpunit-data .error td { background: none; color: #f56954; }
8383
#phpunit-data .skipped td { background: none; color: #e08e0b; }
8484
#phpunit-data .todo td { background: none; color: #00c0ef; }
85+
86+
.ml20px {
87+
margin-left: 20px
88+
}

0 commit comments

Comments
 (0)