Browse Source

Merge pull request #36508 from nextcloud/enh/allow-no-route

Allow settings navigation items with no route entry
tags/v26.0.0beta3
Joas Schilling 1 year ago
parent
commit
7cff390b56
No account linked to committer's email address

+ 0
- 1
apps/user_status/appinfo/info.xml View File

@@ -15,7 +15,6 @@
<navigation>
<id>user_status-menuitem</id>
<name>User status</name>
<route />
<order>1</order>
<type>settings</type>
</navigation>

+ 5
- 0
lib/private/App/InfoParser.php View File

@@ -225,6 +225,11 @@ class InfoParser {
* @return bool
*/
private function isNavigationItem($data): bool {
// Allow settings navigation items with no route entry
$type = $data['type'] ?? 'link';
if ($type === 'settings') {
return isset($data['name']);
}
return isset($data['name'], $data['route']);
}


+ 5
- 3
lib/private/NavigationManager.php View File

@@ -301,10 +301,12 @@ class NavigationManager implements INavigationManager {
continue;
}
foreach ($info['navigations']['navigation'] as $key => $nav) {
$nav['type'] = $nav['type'] ?? 'link';
if (!isset($nav['name'])) {
continue;
}
if (!isset($nav['route'])) {
// 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';
@@ -314,8 +316,8 @@ class NavigationManager implements INavigationManager {
$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 {

+ 1
- 1
resources/app-info-shipped.xsd View File

@@ -446,7 +446,7 @@
<xs:sequence>
<xs:element name="id" type="id" minOccurs="0" maxOccurs="1"/>
<xs:element name="name" type="non-empty-string" minOccurs="1" maxOccurs="1"/>
<xs:element name="route" type="route" minOccurs="1" maxOccurs="1"/>
<xs:element name="route" type="route" minOccurs="0" maxOccurs="1"/>
<xs:element name="icon" type="xs:anyURI" minOccurs="0" maxOccurs="1"/>
<xs:element name="order" type="xs:int" minOccurs="0" maxOccurs="1"/>
<xs:element name="type" type="navigation-type" minOccurs="0" maxOccurs="1"/>

+ 1
- 1
resources/app-info.xsd View File

@@ -442,7 +442,7 @@
<xs:sequence>
<xs:element name="id" type="id" minOccurs="0" maxOccurs="1"/>
<xs:element name="name" type="non-empty-string" minOccurs="1" maxOccurs="1"/>
<xs:element name="route" type="route" minOccurs="1" maxOccurs="1"/>
<xs:element name="route" type="route" minOccurs="0" maxOccurs="1"/>
<xs:element name="icon" type="xs:anyURI" minOccurs="0" maxOccurs="1"/>
<xs:element name="order" type="xs:int" minOccurs="0" maxOccurs="1"/>
<xs:element name="type" type="navigation-type" minOccurs="0" maxOccurs="1"/>

Loading…
Cancel
Save