From 3cf281b24d357519c0e1fa9cdf553e18d9155f0a Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Sun, 12 Mar 2023 01:04:28 +0100 Subject: [PATCH] AdminMenu: add error count to badge iff count > 0 --- models/AdminMenu.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/models/AdminMenu.php b/models/AdminMenu.php index aae9e0d..e0515d0 100644 --- a/models/AdminMenu.php +++ b/models/AdminMenu.php @@ -15,9 +15,10 @@ class AdminMenu extends Menu if (!$user->isAdmin()) return; - $this->items[] = [ + $this->items[0] = [ 'label' => 'Admin', 'icon' => 'gear', + 'badge' => ErrorLog::getCount(), 'subs' => [ [ 'uri' => '/managealbums/', @@ -43,6 +44,9 @@ class AdminMenu extends Menu ], ]; + if ($this->items[0]['badge'] == 0) + unset($this->items[0]['badge']); + foreach ($this->items as $i => $item) { if (isset($item['uri']))