Skip to content

Commit f05c9ea

Browse files
authored
Merge pull request #693 from cakephp/route-panel-simple
Hide debugkit routes with a toggle
2 parents 81d0489 + bbecb01 commit f05c9ea

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ php:
99

1010
sudo: false
1111

12+
services:
13+
- postgresql
14+
- mysql
15+
1216
env:
1317
matrix:
1418
- DB=mysql db_dsn='mysql://[email protected]/cakephp_test'

src/Panel/RoutesPanel.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ public function summary()
3636
return 0;
3737
}
3838

39-
return count(Router::routes());
39+
$routes = array_filter(Router::routes(), function ($route) {
40+
return $route->defaults['plugin'] !== 'DebugKit';
41+
});
42+
43+
return count($routes);
4044
}
4145

4246
/**

src/Template/Element/routes_panel.ctp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,32 @@ $routes = Cake\Routing\Router::routes();
1717
</thead>
1818
<tbody>
1919
<?php foreach ($routes as $route): ?>
20-
<tr class="<?= ($matchedRoute === $route->template) ? 'highlighted' : '' ?>">
20+
<?php
21+
$class = '';
22+
if ($matchedRoute === $route->template):
23+
$class = 'highlighted';
24+
elseif ($route->defaults['plugin'] === 'DebugKit'):
25+
$class = 'debugkit-route hidden';
26+
endif;
27+
?>
28+
<tr class="<?= $class ?>">
2129
<td><?= h(Hash::get($route->options, '_name', $route->getName())) ?></td>
2230
<td class="left"><?= h($route->template) ?></td>
2331
<td class="left"><pre><?= json_encode($route->defaults, JSON_PRETTY_PRINT) ?></pre></td>
2432
</tr>
2533
<?php endforeach; ?>
2634
</tbody>
2735
</table>
36+
<button type="button" class="btn-primary" id="toggle-debugkit-routes">
37+
<?= __d('debug_kit', 'Toggle debugkit internal routes') ?>
38+
</button>
39+
40+
<script>
41+
$(document).ready(function() {
42+
$('#toggle-debugkit-routes').on('click', function (event) {
43+
event.preventDefault();
44+
var routes = $('.debugkit-route');
45+
routes.toggleClass('hidden');
46+
});
47+
});
48+
</script>

webroot/css/toolbar.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,7 @@ pre,
501501
color: #fff;
502502
border-radius: 4px;
503503
box-shadow: 0 2px 0 #2a6496;
504+
padding: 4px 10px;
504505
}
505506
.btn-primary:active {
506507
box-shadow: none;

0 commit comments

Comments
 (0)