瀏覽代碼

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 年之前
父節點
當前提交
7cff390b56
No account linked to committer's email address

+ 0
- 1
apps/user_status/appinfo/info.xml 查看文件

<navigation> <navigation>
<id>user_status-menuitem</id> <id>user_status-menuitem</id>
<name>User status</name> <name>User status</name>
<route />
<order>1</order> <order>1</order>
<type>settings</type> <type>settings</type>
</navigation> </navigation>

+ 5
- 0
lib/private/App/InfoParser.php 查看文件

* @return bool * @return bool
*/ */
private function isNavigationItem($data): 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']); return isset($data['name'], $data['route']);
} }



+ 5
- 3
lib/private/NavigationManager.php 查看文件

continue; continue;
} }
foreach ($info['navigations']['navigation'] as $key => $nav) { foreach ($info['navigations']['navigation'] as $key => $nav) {
$nav['type'] = $nav['type'] ?? 'link';
if (!isset($nav['name'])) { if (!isset($nav['name'])) {
continue; 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; continue;
} }
$role = isset($nav['@attributes']['role']) ? $nav['@attributes']['role'] : 'all'; $role = isset($nav['@attributes']['role']) ? $nav['@attributes']['role'] : 'all';
$l = $this->l10nFac->get($app); $l = $this->l10nFac->get($app);
$id = $nav['id'] ?? $app . ($key === 0 ? '' : $key); $id = $nav['id'] ?? $app . ($key === 0 ? '' : $key);
$order = isset($nav['order']) ? $nav['order'] : 100; $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'; $icon = isset($nav['icon']) ? $nav['icon'] : 'app.svg';
foreach ([$icon, "$app.svg"] as $i) { foreach ([$icon, "$app.svg"] as $i) {
try { try {

+ 1
- 1
resources/app-info-shipped.xsd 查看文件

<xs:sequence> <xs:sequence>
<xs:element name="id" type="id" minOccurs="0" maxOccurs="1"/> <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="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="icon" type="xs:anyURI" minOccurs="0" maxOccurs="1"/>
<xs:element name="order" type="xs:int" 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"/> <xs:element name="type" type="navigation-type" minOccurs="0" maxOccurs="1"/>

+ 1
- 1
resources/app-info.xsd 查看文件

<xs:sequence> <xs:sequence>
<xs:element name="id" type="id" minOccurs="0" maxOccurs="1"/> <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="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="icon" type="xs:anyURI" minOccurs="0" maxOccurs="1"/>
<xs:element name="order" type="xs:int" 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"/> <xs:element name="type" type="navigation-type" minOccurs="0" maxOccurs="1"/>

Loading…
取消
儲存