]> source.dussan.org Git - nextcloud-server.git/commitdiff
Force to specify the name 2822/head
authorJoas Schilling <coding@schilljs.com>
Fri, 27 Jan 2017 08:38:10 +0000 (09:38 +0100)
committerJoas Schilling <coding@schilljs.com>
Fri, 27 Jan 2017 08:44:11 +0000 (09:44 +0100)
Signed-off-by: Joas Schilling <coding@schilljs.com>
apps/files/appinfo/info.xml
lib/private/NavigationManager.php
tests/lib/NavigationManagerTest.php

index 1171c0ceb6fd16b318a2c8e4f4fdfc9047c906b8..2bb4d98c1582c5d5c86c5c5ecd4af72aa8d7eac0 100644 (file)
@@ -55,6 +55,7 @@
        </commands>
 
        <navigation>
+               <name>Files</name>
                <route>files.view.index</route>
                <order>0</order>
        </navigation>
index 79b01a69c4955e8342787a46c36854a64cf0b9d5..f7bc02943a38558a451b31289c852d006aa2fca6 100644 (file)
@@ -26,6 +26,7 @@
 
 namespace OC;
 
+use OC\App\AppManager;
 use OCP\App\IAppManager;
 use OCP\IGroupManager;
 use OCP\INavigationManager;
@@ -43,7 +44,7 @@ class NavigationManager implements INavigationManager {
        protected $activeEntry;
        /** @var bool */
        protected $init = false;
-       /** @var IAppManager */
+       /** @var IAppManager|AppManager */
        protected $appManager;
        /** @var IURLGenerator */
        private $urlGenerator;
@@ -54,7 +55,7 @@ class NavigationManager implements INavigationManager {
        /** @var IGroupManager */
        private $groupManager;
 
-       function __construct(IAppManager $appManager = null,
+       public function __construct(IAppManager $appManager = null,
                                                 IURLGenerator $urlGenerator = null,
                                                 IFactory $l10nFac = null,
                                                 IUserSession $userSession = null,
@@ -143,6 +144,9 @@ class NavigationManager implements INavigationManager {
                                continue;
                        }
                        $nav = $info['navigation'];
+                       if (!isset($nav['name'])) {
+                               continue;
+                       }
                        if (!isset($nav['route'])) {
                                continue;
                        }
@@ -153,7 +157,6 @@ class NavigationManager implements INavigationManager {
                        $l = $this->l10nFac->get($app);
                        $order = isset($nav['order']) ? $nav['order'] : 100;
                        $route = $this->urlGenerator->linkToRoute($nav['route']);
-                       $name = isset($nav['name']) ? $nav['name'] : ucfirst($app);
                        $icon = isset($nav['icon']) ? $nav['icon'] : 'app.svg';
                        foreach ([$icon, "$app.svg"] as $i) {
                                try {
@@ -172,7 +175,7 @@ class NavigationManager implements INavigationManager {
                                'order' => $order,
                                'href' => $route,
                                'icon' => $icon,
-                               'name' => $l->t($name),
+                               'name' => $l->t($nav['name']),
                        ]);
                }
        }
index 942dcbe18650acba6943ba0f0c29796b64a4519e..64fec802eca7e744b15380c056d5bed55a6a1411 100644 (file)
@@ -12,6 +12,7 @@
 
 namespace Test;
 
+use OC\App\AppManager;
 use OC\NavigationManager;
 use OCP\App\IAppManager;
 use OCP\IGroupManager;
@@ -170,7 +171,7 @@ class NavigationManagerTest extends TestCase {
         */
        public function testWithAppManager($expected, $config, $isAdmin = false) {
 
-               $appManager = $this->createMock(IAppManager::class);
+               $appManager = $this->createMock(AppManager::class);
                $urlGenerator = $this->createMock(IURLGenerator::class);
                $l10nFac = $this->createMock(IFactory::class);
                $userSession = $this->createMock(IUserSession::class);
@@ -209,7 +210,7 @@ class NavigationManagerTest extends TestCase {
                                'icon' => '/apps/test/img/app.svg',
                                'name' => 'Test',
                                'active' => false
-                       ]], ['navigation' => ['route' => 'test.page.index']]],
+                       ]], ['navigation' => ['route' => 'test.page.index', 'name' => 'Test']]],
                        'no admin' => [[[
                                'id' => 'test',
                                'order' => 100,
@@ -217,8 +218,9 @@ class NavigationManagerTest extends TestCase {
                                'icon' => '/apps/test/img/app.svg',
                                'name' => 'Test',
                                'active' => false
-                       ]], ['navigation' => ['@attributes' => ['role' => 'admin'], 'route' => 'test.page.index']], true],
-                       'admin' => [[], ['navigation' => ['@attributes' => ['role' => 'admin'], 'route' => 'test.page.index']]]
+                       ]], ['navigation' => ['@attributes' => ['role' => 'admin'], 'route' => 'test.page.index', 'name' => 'Test']], true],
+                       'no name' => [[], ['navigation' => ['@attributes' => ['role' => 'admin'], 'route' => 'test.page.index']], true],
+                       'admin' => [[], ['navigation' => ['@attributes' => ['role' => 'admin'], 'route' => 'test.page.index', 'name' => 'Test']]]
                ];
        }
 }