Skip to content

Commit

Permalink
Merge pull request #34069 from nextcloud/enh/33736/add-accessibility-…
Browse files Browse the repository at this point in the history
…in-user-menu

Add accessibility entry in user menu
  • Loading branch information
szaimen authored Sep 14, 2022
2 parents 7ea015f + da01494 commit 0550e5e
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 13 deletions.
6 changes: 5 additions & 1 deletion apps/settings/lib/Controller/CommonSettingsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,11 @@ private function formatSettings(array $settings): array {

private function getIndexResponse(string $type, string $section): TemplateResponse {
if ($type === 'personal') {
$this->navigationManager->setActiveEntry('settings');
if ($section === 'theming') {
$this->navigationManager->setActiveEntry('accessibility_settings');
} else {
$this->navigationManager->setActiveEntry('settings');
}
} elseif ($type === 'admin') {
$this->navigationManager->setActiveEntry('admin_settings');
}
Expand Down
43 changes: 43 additions & 0 deletions apps/theming/img/accessibility-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 16 additions & 5 deletions lib/private/NavigationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,23 @@ private function init() {
}

if ($this->userSession->isLoggedIn()) {
// Accessibility settings
if ($this->appManager->isEnabledForUser('theming', $this->userSession->getUser())) {
$this->add([
'type' => 'settings',
'id' => 'accessibility_settings',
'order' => 2,
'href' => $this->urlGenerator->linkToRoute('settings.PersonalSettings.index', ['section' => 'theming']),
'name' => $l->t('Appearance and accessibility'),
'icon' => $this->urlGenerator->imagePath('theming', 'accessibility-dark.svg'),
]);
}
if ($this->isAdmin()) {
// App management
$this->add([
'type' => 'settings',
'id' => 'core_apps',
'order' => 4,
'order' => 5,
'href' => $this->urlGenerator->linkToRoute('settings.AppSettings.viewApps'),
'icon' => $this->urlGenerator->imagePath('settings', 'apps.svg'),
'name' => $l->t('Apps'),
Expand All @@ -216,7 +227,7 @@ private function init() {
$this->add([
'type' => 'settings',
'id' => 'settings',
'order' => 2,
'order' => 3,
'href' => $this->urlGenerator->linkToRoute('settings.PersonalSettings.index'),
'name' => $l->t('Personal settings'),
'icon' => $this->urlGenerator->imagePath('settings', 'personal.svg'),
Expand All @@ -226,7 +237,7 @@ private function init() {
$this->add([
'type' => 'settings',
'id' => 'admin_settings',
'order' => 3,
'order' => 4,
'href' => $this->urlGenerator->linkToRoute('settings.AdminSettings.index', ['section' => 'overview']),
'name' => $l->t('Administration settings'),
'icon' => $this->urlGenerator->imagePath('settings', 'admin.svg'),
Expand All @@ -236,7 +247,7 @@ private function init() {
$this->add([
'type' => 'settings',
'id' => 'settings',
'order' => 2,
'order' => 3,
'href' => $this->urlGenerator->linkToRoute('settings.PersonalSettings.index'),
'name' => $l->t('Settings'),
'icon' => $this->urlGenerator->imagePath('settings', 'admin.svg'),
Expand All @@ -261,7 +272,7 @@ private function init() {
$this->add([
'type' => 'settings',
'id' => 'core_users',
'order' => 5,
'order' => 6,
'href' => $this->urlGenerator->linkToRoute('settings.Users.usersList'),
'name' => $l->t('Users'),
'icon' => $this->urlGenerator->imagePath('settings', 'users.svg'),
Expand Down
6 changes: 4 additions & 2 deletions tests/acceptance/features/header.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ Feature: header
Given I am logged in as the admin
When I open the Settings menu
Then I see that the Settings menu is shown
And I see that the Settings menu has only 8 items
And I see that the Settings menu has only 9 items
And I see that the "Set status" item in the Settings menu is shown
And I see that the "Appearance and accessibility" item in the Settings menu is shown
And I see that the "Personal settings" item in the Settings menu is shown
And I see that the "Administration settings" item in the Settings menu is shown
And I see that the "Apps" item in the Settings menu is shown
Expand All @@ -18,8 +19,9 @@ Feature: header
Given I am logged in
When I open the Settings menu
Then I see that the Settings menu is shown
And I see that the Settings menu has only 5 items
And I see that the Settings menu has only 6 items
And I see that the "Set status" item in the Settings menu is shown
And I see that the "Appearance and accessibility" item in the Settings menu is shown
And I see that the "Settings" item in the Settings menu is shown
And I see that the "Help" item in the Settings menu is shown
And I see that the "Log out" item in the Settings menu is shown
Expand Down
36 changes: 31 additions & 5 deletions tests/lib/NavigationManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,19 @@ public function testWithAppManager($expected, $navigation, $isAdmin = false) {
return vsprintf($text, $parameters);
});

$this->appManager->expects($this->any())
->method('isEnabledForUser')
->with('theming')
->willReturn(true);
$this->appManager->expects($this->once())->method('getAppInfo')->with('test')->willReturn($navigation);
/*
$this->appManager->expects($this->any())
->method('getAppInfo')
->will($this->returnValueMap([
['test', null, null, $navigation],
['theming', null, null, null],
]));
*/
$this->l10nFac->expects($this->any())->method('get')->willReturn($l);
$this->urlGenerator->expects($this->any())->method('imagePath')->willReturnCallback(function ($appName, $file) {
return "/apps/$appName/img/$file";
Expand All @@ -230,7 +242,7 @@ public function testWithAppManager($expected, $navigation, $isAdmin = false) {
$user->expects($this->any())->method('getUID')->willReturn('user001');
$this->userSession->expects($this->any())->method('getUser')->willReturn($user);
$this->userSession->expects($this->any())->method('isLoggedIn')->willReturn(true);
$this->appManager->expects($this->once())
$this->appManager->expects($this->any())
->method('getEnabledAppsForUser')
->with($user)
->willReturn(['test']);
Expand All @@ -248,7 +260,7 @@ public function providesNavigationConfig() {
$apps = [
'core_apps' => [
'id' => 'core_apps',
'order' => 4,
'order' => 5,
'href' => '/apps/test/',
'icon' => '/apps/settings/img/apps.svg',
'name' => 'Apps',
Expand All @@ -259,9 +271,20 @@ public function providesNavigationConfig() {
]
];
$defaults = [
'accessibility_settings' => [
'type' => 'settings',
'id' => 'accessibility_settings',
'order' => 2,
'href' => '/apps/test/',
'name' => 'Appearance and accessibility',
'icon' => '/apps/theming/img/accessibility-dark.svg',
'active' => false,
'classes' => '',
'unread' => 0,
],
'settings' => [
'id' => 'settings',
'order' => 2,
'order' => 3,
'href' => '/apps/test/',
'icon' => '/apps/settings/img/admin.svg',
'name' => 'Settings',
Expand All @@ -283,9 +306,10 @@ public function providesNavigationConfig() {
]
];
$adminSettings = [
'accessibility_settings' => $defaults['accessibility_settings'],
'settings' => [
'id' => 'settings',
'order' => 2,
'order' => 3,
'href' => '/apps/test/',
'icon' => '/apps/settings/img/personal.svg',
'name' => 'Personal settings',
Expand All @@ -296,7 +320,7 @@ public function providesNavigationConfig() {
],
'admin_settings' => [
'id' => 'admin_settings',
'order' => 3,
'order' => 4,
'href' => '/apps/test/',
'icon' => '/apps/settings/img/admin.svg',
'name' => 'Administration settings',
Expand All @@ -310,6 +334,7 @@ public function providesNavigationConfig() {
return [
'minimalistic' => [
array_merge(
['accessibility_settings' => $defaults['accessibility_settings']],
['settings' => $defaults['settings']],
['test' => [
'id' => 'test',
Expand All @@ -332,6 +357,7 @@ public function providesNavigationConfig() {
],
'minimalistic-settings' => [
array_merge(
['accessibility_settings' => $defaults['accessibility_settings']],
['settings' => $defaults['settings']],
['test' => [
'id' => 'test',
Expand Down

0 comments on commit 0550e5e

Please sign in to comment.