From 27f8a832e41590a33a7815d328564a1fd70e7760 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 27 Jan 2017 09:38:10 +0100 Subject: Force to specify the name Signed-off-by: Joas Schilling --- apps/files/appinfo/info.xml | 1 + lib/private/NavigationManager.php | 11 +++++++---- tests/lib/NavigationManagerTest.php | 10 ++++++---- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/apps/files/appinfo/info.xml b/apps/files/appinfo/info.xml index 1171c0ceb6f..2bb4d98c158 100644 --- a/apps/files/appinfo/info.xml +++ b/apps/files/appinfo/info.xml @@ -55,6 +55,7 @@ + Files files.view.index 0 diff --git a/lib/private/NavigationManager.php b/lib/private/NavigationManager.php index 79b01a69c49..f7bc02943a3 100644 --- a/lib/private/NavigationManager.php +++ b/lib/private/NavigationManager.php @@ -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']), ]); } } diff --git a/tests/lib/NavigationManagerTest.php b/tests/lib/NavigationManagerTest.php index 942dcbe1865..64fec802eca 100644 --- a/tests/lib/NavigationManagerTest.php +++ b/tests/lib/NavigationManagerTest.php @@ -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']]] ]; } } -- cgit v1.2.3