Force to specify the name
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
47d7d26bda
commit
27f8a832e4
|
@ -55,6 +55,7 @@
|
|||
</commands>
|
||||
|
||||
<navigation>
|
||||
<name>Files</name>
|
||||
<route>files.view.index</route>
|
||||
<order>0</order>
|
||||
</navigation>
|
||||
|
|
|
@ -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']),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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']]]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue