From 08845f73c9105896172d72a6a95017dc8883da9b Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Thu, 9 Feb 2023 11:01:54 -0800 Subject: [PATCH 1/4] Allow settings navigation items with no route entry Signed-off-by: Christopher Ng (cherry picked from commit 62b7bb73955a6f782ddaf6e3d248f29b93165099) --- lib/private/App/InfoParser.php | 4 ++++ lib/private/NavigationManager.php | 10 +++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/private/App/InfoParser.php b/lib/private/App/InfoParser.php index 9d57ef95688d3..c7aa8a9cc056b 100644 --- a/lib/private/App/InfoParser.php +++ b/lib/private/App/InfoParser.php @@ -225,6 +225,10 @@ public function parse($file) { * @return bool */ private function isNavigationItem($data): bool { + // Allow settings navigation items with no route entry + if ($data['type'] === 'settings') { + return isset($data['name']); + } return isset($data['name'], $data['route']); } diff --git a/lib/private/NavigationManager.php b/lib/private/NavigationManager.php index b78d9fa1ed81e..2d1400714fea1 100644 --- a/lib/private/NavigationManager.php +++ b/lib/private/NavigationManager.php @@ -301,11 +301,15 @@ private function init() { continue; } foreach ($info['navigations']['navigation'] as $key => $nav) { + $nav['type'] = $nav['type'] ?? 'link'; if (!isset($nav['name'])) { continue; } if (!isset($nav['route'])) { - continue; + // Allow settings navigation items with no route entry, all other types require one + if ($nav['type'] !== 'settings') { + continue; + } } $role = isset($nav['@attributes']['role']) ? $nav['@attributes']['role'] : 'all'; if ($role === 'admin' && !$this->isAdmin()) { @@ -314,8 +318,8 @@ private function init() { $l = $this->l10nFac->get($app); $id = $nav['id'] ?? $app . ($key === 0 ? '' : $key); $order = isset($nav['order']) ? $nav['order'] : 100; - $type = isset($nav['type']) ? $nav['type'] : 'link'; - $route = $nav['route'] !== '' ? $this->urlGenerator->linkToRoute($nav['route']) : ''; + $type = $nav['type']; + $route = !empty($nav['route']) ? $this->urlGenerator->linkToRoute($nav['route']) : ''; $icon = isset($nav['icon']) ? $nav['icon'] : 'app.svg'; foreach ([$icon, "$app.svg"] as $i) { try { From f725eeddfdb386a601a51b5181e7bf300679804d Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Thu, 9 Feb 2023 11:01:54 -0800 Subject: [PATCH 2/4] Allow zero occurences of route in XML schemas - For xmllint Signed-off-by: Christopher Ng (cherry picked from commit 70651c3ab176d8a5491e15dbb22b1cd6561c6274) --- resources/app-info-shipped.xsd | 2 +- resources/app-info.xsd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/app-info-shipped.xsd b/resources/app-info-shipped.xsd index 031579ad5a374..c11264142ebfb 100644 --- a/resources/app-info-shipped.xsd +++ b/resources/app-info-shipped.xsd @@ -446,7 +446,7 @@ - + diff --git a/resources/app-info.xsd b/resources/app-info.xsd index 1c7cc5c47e432..191c8ed7c5b0b 100644 --- a/resources/app-info.xsd +++ b/resources/app-info.xsd @@ -442,7 +442,7 @@ - + From 23ab3a3c9284b2adb55f2e3e98df1433477ac530 Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Thu, 9 Feb 2023 11:01:54 -0800 Subject: [PATCH 3/4] Remove extraneous user status route entry Signed-off-by: Christopher Ng (cherry picked from commit c610d0d99b7ed6999dea78d532a9c6c8552cafff) --- apps/user_status/appinfo/info.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/user_status/appinfo/info.xml b/apps/user_status/appinfo/info.xml index 23f07eb325ae2..b99639c5fb0f1 100644 --- a/apps/user_status/appinfo/info.xml +++ b/apps/user_status/appinfo/info.xml @@ -15,7 +15,6 @@ user_status-menuitem User status - 1 settings From 5e82a118618b963f3dcf425a823a3e6f43975fdb Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 9 Feb 2023 11:01:54 -0800 Subject: [PATCH 4/4] fix(appinfo): navigation type is optional Signed-off-by: Joas Schilling (cherry picked from commit bf7fe04c4b238f7c20dd3bb54c2f8df13cc0f6b8) --- lib/private/App/InfoParser.php | 3 ++- lib/private/NavigationManager.php | 8 +++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/private/App/InfoParser.php b/lib/private/App/InfoParser.php index c7aa8a9cc056b..7267b58cfbc23 100644 --- a/lib/private/App/InfoParser.php +++ b/lib/private/App/InfoParser.php @@ -226,7 +226,8 @@ public function parse($file) { */ private function isNavigationItem($data): bool { // Allow settings navigation items with no route entry - if ($data['type'] === 'settings') { + $type = $data['type'] ?? 'link'; + if ($type === 'settings') { return isset($data['name']); } return isset($data['name'], $data['route']); diff --git a/lib/private/NavigationManager.php b/lib/private/NavigationManager.php index 2d1400714fea1..e3d5ac752d804 100644 --- a/lib/private/NavigationManager.php +++ b/lib/private/NavigationManager.php @@ -305,11 +305,9 @@ private function init() { if (!isset($nav['name'])) { continue; } - if (!isset($nav['route'])) { - // Allow settings navigation items with no route entry, all other types require one - if ($nav['type'] !== 'settings') { - continue; - } + // Allow settings navigation items with no route entry, all other types require one + if (!isset($nav['route']) && $nav['type'] !== 'settings') { + continue; } $role = isset($nav['@attributes']['role']) ? $nav['@attributes']['role'] : 'all'; if ($role === 'admin' && !$this->isAdmin()) {