Skip to content

Commit 30aeb85

Browse files
committed
bug #45351 [WebProfilerBundle] Log section minor fixes (missing "notice" filter, log priority, accessibility) (Amunak)
This PR was squashed before being merged into the 5.4 branch. Discussion ---------- [WebProfilerBundle] Log section minor fixes (missing "notice" filter, log priority, accessibility) | Q | A | ------------- | --- | Branch? | 5.4 <!-- see below --> | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | #42195 (related) | License | MIT | Doc PR | ~ This fixes minor front-end issues with the redesigned Log section in WebProfilerBundle. Marking as bugfix, since technically the redesign removed some features without documenting it - the log level is now visible even for low level logs (debug, notice, info). I have also added the missing "notice" filter and made sure that when a filter is missing the message is shown (fail-safe). I have also implemented accessibility fixes mentioned in the original PR (#42195) by @stof. I did not add tests because I have no idea where or how - currently the profiler front-end is not tested (or at least the log section). These changes do not affect the logic behind the panel in a way that could be easily tested. Screenshot of the changes: notice the visible log levels and added "notice" filter: ![Screenshot of the changes](https://user-images.githubusercontent.com/781546/152992378-89452512-7b94-40b7-9d8e-8f94acc4d058.png) Commits ------- 1c3b266 [WebProfilerBundle] Log section minor fixes (missing "notice" filter, log priority, accessibility)
2 parents 98a7937 + 1c3b266 commit 30aeb85

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig

+11-7
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@
8989

9090
<div class="log-filter-content">
9191
<div class="filter-select-all-or-none">
92-
<a href="#" class="select-all">Select All</a>
93-
<a href="#" class="select-none">Select None</a>
92+
<button type="button" class="btn btn-link select-all">Select All</button>
93+
<button type="button" class="btn btn-link select-none">Select None</button>
9494
</div>
9595

9696
{% for label, value in filters.priority %}
@@ -110,8 +110,8 @@
110110

111111
<div class="log-filter-content">
112112
<div class="filter-select-all-or-none">
113-
<a href="#" class="select-all">Select All</a>
114-
<a href="#" class="select-none">Select None</a>
113+
<button type="button" class="btn btn-link select-all">Select All</button>
114+
<button type="button" class="btn btn-link select-none">Select None</button>
115115
</div>
116116

117117
{% for value in filters.channel %}
@@ -155,6 +155,10 @@
155155
{{ log.type|lower }}
156156
{% endif %}
157157
</span>
158+
{% else %}
159+
<span class="log-type-badge badge badge-{{ css_class }}">
160+
{{ log.priorityName|lower }}
161+
</span>
158162
{% endif %}
159163
</td>
160164

@@ -204,7 +208,7 @@
204208
<td class="font-normal">
205209
{% set context_id = 'context-compiler-' ~ loop.index %}
206210

207-
<a class="btn btn-link sf-toggle" data-toggle-selector="#{{ context_id }}" data-toggle-alt-content="{{ class }}">{{ class }}</a>
211+
<button type="button" class="btn btn-link sf-toggle" data-toggle-selector="#{{ context_id }}" data-toggle-alt-content="{{ class }}">{{ class }}</button>
208212

209213
<div id="{{ context_id }}" class="context sf-toggle-content sf-toggle-hidden">
210214
<ul class="break-long-words">
@@ -243,12 +247,12 @@
243247

244248
{% if has_context %}
245249
{% set context_id = 'context-' ~ category ~ '-' ~ log_index %}
246-
<span><a class="btn btn-link text-small sf-toggle" data-toggle-selector="#{{ context_id }}" data-toggle-alt-content="Hide context">Show context</a></span>
250+
<span><button type="button" class="btn btn-link text-small sf-toggle" data-toggle-selector="#{{ context_id }}" data-toggle-alt-content="Hide context">Show context</button></span>
247251
{% endif %}
248252

249253
{% if has_trace %}
250254
{% set trace_id = 'trace-' ~ category ~ '-' ~ log_index %}
251-
<span><a class="btn btn-link text-small sf-toggle" data-toggle-selector="#{{ trace_id }}" data-toggle-alt-content="Hide trace">Show trace</a></span>
255+
<span><button type="button" class="btn btn-link text-small sf-toggle" data-toggle-selector="#{{ trace_id }}" data-toggle-alt-content="Hide trace">Show trace</button></span>
252256

253257
<div id="{{ trace_id }}" class="context sf-toggle-content sf-toggle-hidden">
254258
{{ profiler_dump(log.context.exception.trace, maxDepth=1) }}

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig

+4-2
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ if (typeof Sfjs === 'undefined' || typeof Sfjs.loadToolbar === 'undefined') {
796796
input.addEventListener('change', () => { Sfjs.updateLogsTable(); });
797797
});
798798
799-
document.querySelectorAll('.filter-select-all-or-none a').forEach((link) => {
799+
document.querySelectorAll('.filter-select-all-or-none button').forEach((link) => {
800800
link.addEventListener('click', () => {
801801
const selectAll = link.classList.contains('select-all');
802802
link.closest('.log-filter-content').querySelectorAll('input').forEach((input) => {
@@ -819,6 +819,7 @@ if (typeof Sfjs === 'undefined' || typeof Sfjs.loadToolbar === 'undefined') {
819819
updateLogsTable: function() {
820820
const selectedType = document.querySelector('#log-filter-type input:checked').value;
821821
const priorities = document.querySelectorAll('#log-filter-priority input');
822+
const allPriorities = Array.from(priorities).map((input) => input.value);
822823
const selectedPriorities = Array.from(priorities).filter((input) => input.checked).map((input) => input.value);
823824
const channels = document.querySelectorAll('#log-filter-channel input');
824825
const selectedChannels = Array.from(channels).filter((input) => input.checked).map((input) => input.value);
@@ -836,7 +837,8 @@ if (typeof Sfjs === 'undefined' || typeof Sfjs.loadToolbar === 'undefined') {
836837
return;
837838
}
838839
839-
if (false === selectedPriorities.includes(row.getAttribute('data-priority'))) {
840+
const priority = row.getAttribute('data-priority');
841+
if (false === selectedPriorities.includes(priority) && true === allPriorities.includes(priority)) {
840842
row.style.display = 'none';
841843
return;
842844
}

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig

+1-1
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,7 @@ tr.status-warning td {
11351135
.log-filter .filter-select-all-or-none {
11361136
margin-bottom: 10px;
11371137
}
1138-
.log-filter .filter-select-all-or-none a + a {
1138+
.log-filter .filter-select-all-or-none button + button {
11391139
margin-left: 15px;
11401140
}
11411141
.log-filters .log-filter .log-filter-content .log-filter-option + .log-filter-option {

src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php

+1
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ public function getFilters()
133133
'priority' => [
134134
'Debug' => 100,
135135
'Info' => 200,
136+
'Notice' => 250,
136137
'Warning' => 300,
137138
'Error' => 400,
138139
'Critical' => 500,

0 commit comments

Comments
 (0)