summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2017-01-27 09:38:10 +0100
committerJoas Schilling <coding@schilljs.com>2017-01-27 09:44:11 +0100
commit27f8a832e41590a33a7815d328564a1fd70e7760 (patch)
tree5c05746c23cc788a23d0dc8e646807ce210d9054
parent47d7d26bdafe1d898af69aa35ab049a85e8d2b98 (diff)
downloadnextcloud-server-27f8a832e41590a33a7815d328564a1fd70e7760.tar.gz
nextcloud-server-27f8a832e41590a33a7815d328564a1fd70e7760.zip
Force to specify the name
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--apps/files/appinfo/info.xml1
-rw-r--r--lib/private/NavigationManager.php11
-rw-r--r--tests/lib/NavigationManagerTest.php10
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 @@
</commands>
<navigation>
+ <name>Files</name>
<route>files.view.index</route>
<order>0</order>
</navigation>
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']]]
];
}
}