Skip to content

Commit d31fe12

Browse files
committed
twig fix
1 parent 5680a88 commit d31fe12

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

src/Dashboards/Redis/RedisTrait.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,9 +464,10 @@ public function keysTableView(array $keys_array): array {
464464
foreach ($keys_array as $key) {
465465
$formatted_keys[] = [
466466
'key' => $key,
467+
'items' => $pipeline[$key]['count'] ?? null,
467468
'base64' => true,
468469
'info' => [
469-
'link_title' => ($pipeline[$key]['count'] !== null ? '('.$pipeline[$key]['count'].' items) ' : '').$key,
470+
'link_title' => $key,
470471
'bytes_size' => $pipeline[$key]['size'],
471472
'type' => $pipeline[$key]['type'],
472473
'ttl' => $pipeline[$key]['ttl'] === -1 ? 'Doesn\'t expire' : $pipeline[$key]['ttl'],
@@ -503,8 +504,9 @@ public function keysTreeView(array $keys_array): array {
503504
if ($i === count($parts) - 1) { // check last part
504505
$current[] = [
505506
'type' => 'key',
506-
'name' => ($pipeline[$key]['count'] !== null ? '('.$pipeline[$key]['count'].' items) ' : '').$part,
507+
'name' => $part,
507508
'key' => $key,
509+
'items' => $pipeline[$key]['count'] ?? null,
508510
'base64' => true,
509511
'info' => [
510512
'bytes_size' => $pipeline[$key]['size'],

templates/partials/table_view.twig

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@
3939
<td class="px-3 py-2 border-b border-gray-200 text-sm{{ td_class }}{{ classes[loop.index]|space }} dark:border-gray-700 dark:text-gray-300">
4040
{% if item_key == 'link_title' and view_key %}
4141
{% set link = view_key|replace({'__key__': key.key}) %}
42-
<a class="text-primary-500 hover:text-primary-700 font-semibold dark:text-primary-400 dark:hover:text-primary-300" href="{{ link }}">{{ item }}</a>
42+
<a class="text-primary-500 hover:text-primary-700 font-semibold dark:text-primary-400 dark:hover:text-primary-300" href="{{ link }}">
43+
{{ item }}
44+
{% if key.items %}
45+
<span class="text-gray-500 dark:text-gray-400 text-xs">({{ key.items }} items)</span>
46+
{% endif %}
47+
</a>
4348
{% elseif item_key == 'type' %}
4449
{{- components.key_type(item) -}}
4550
{% elseif item_key starts with 'number_' %}

templates/partials/tree_view.twig

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</div>
1919
{% else %}
2020
<div class="keywrapper border-t border-gray-200 dark:border-gray-700" style="--level: {{ level }}">
21-
<div data-key="{{ item.base64 ? item.key|base64 : item.key }}" class="flex justify-between px-6 py-1 hover:bg-gray-50 dark:hover:bg-white/5" style="padding-left: calc({{ level }} * 20px + 32px)">
21+
<div data-key="{{ item.base64 ? item.key|base64 : item.key }}" class="flex justify-between px-6 py-1 text-sm hover:bg-gray-50 dark:hover:bg-white/5" style="padding-left: calc({{ level }} * 20px + 32px)">
2222
<div class="flex items-center gap-2">
2323
{% if show_actions %}
2424
{{ components.checkbox('check-key mt-0') }}
@@ -28,14 +28,17 @@
2828
{% set link = view_key|replace({'__key__': item.key}) %}
2929
<a class="text-primary-500 hover:text-primary-700 font-semibold dark:text-primary-400 dark:hover:text-primary-300" href="{{ link }}">
3030
{{ item.name }}
31+
{% if item.items %}
32+
<span class="text-gray-500 dark:text-gray-400 text-xs">({{ item.items }} items)</span>
33+
{% endif %}
3134
</a>
3235
</span>
3336
</div>
3437

3538
<div class="flex gap-4">
3639
{% for item_key, kitem in item.info %}
3740
{% if item_key == 'type' %}
38-
{{- components.key_type(kitem) -}}
41+
<span class="w-24">{{ components.key_type(kitem) }}</span>
3942
{% elseif item_key starts with 'number_' %}
4043
{{- kitem|number -}}
4144
{% elseif item_key starts with 'time_' %}

tests/Dashboards/Redis/RedisTestCase.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,13 @@ public function testGetAllKeysTableView(): void {
262262
$expected = [
263263
[
264264
'key' => 'pu-test-table1',
265+
'items' => null,
265266
'base64' => true,
266267
'info' => array_merge(['link_title' => 'pu-test-table1'], $info),
267268
],
268269
[
269270
'key' => 'pu-test-table2',
271+
'items' => null,
270272
'base64' => true,
271273
'info' => array_merge(['link_title' => 'pu-test-table2'], $info),
272274
],
@@ -305,13 +307,15 @@ public function testGetAllKeysTreeView(): void {
305307
'type' => 'key',
306308
'name' => 'sub1',
307309
'key' => 'pu-test-tree1:sub1',
310+
'items' => null,
308311
'base64' => true,
309312
'info' => $info,
310313
],
311314
[
312315
'type' => 'key',
313316
'name' => 'sub2',
314317
'key' => 'pu-test-tree1:sub2',
318+
'items' => null,
315319
'base64' => true,
316320
'info' => $info,
317321
],
@@ -323,6 +327,7 @@ public function testGetAllKeysTreeView(): void {
323327
'type' => 'key',
324328
'name' => 'pu-test-tree2',
325329
'key' => 'pu-test-tree2',
330+
'items' => null,
326331
'base64' => true,
327332
'info' => $info,
328333
],

0 commit comments

Comments
 (0)