Skip to content

Commit da01494

Browse files
committed
Add accessibility entry in user menu
Signed-off-by: Vincent Petry <vincent@nextcloud.com>
1 parent 7ea015f commit da01494

5 files changed

Lines changed: 99 additions & 13 deletions

File tree

apps/settings/lib/Controller/CommonSettingsTrait.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,11 @@ private function formatSettings(array $settings): array {
135135

136136
private function getIndexResponse(string $type, string $section): TemplateResponse {
137137
if ($type === 'personal') {
138-
$this->navigationManager->setActiveEntry('settings');
138+
if ($section === 'theming') {
139+
$this->navigationManager->setActiveEntry('accessibility_settings');
140+
} else {
141+
$this->navigationManager->setActiveEntry('settings');
142+
}
139143
} elseif ($type === 'admin') {
140144
$this->navigationManager->setActiveEntry('admin_settings');
141145
}
Lines changed: 43 additions & 0 deletions
Loading

lib/private/NavigationManager.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,23 @@ private function init() {
201201
}
202202

203203
if ($this->userSession->isLoggedIn()) {
204+
// Accessibility settings
205+
if ($this->appManager->isEnabledForUser('theming', $this->userSession->getUser())) {
206+
$this->add([
207+
'type' => 'settings',
208+
'id' => 'accessibility_settings',
209+
'order' => 2,
210+
'href' => $this->urlGenerator->linkToRoute('settings.PersonalSettings.index', ['section' => 'theming']),
211+
'name' => $l->t('Appearance and accessibility'),
212+
'icon' => $this->urlGenerator->imagePath('theming', 'accessibility-dark.svg'),
213+
]);
214+
}
204215
if ($this->isAdmin()) {
205216
// App management
206217
$this->add([
207218
'type' => 'settings',
208219
'id' => 'core_apps',
209-
'order' => 4,
220+
'order' => 5,
210221
'href' => $this->urlGenerator->linkToRoute('settings.AppSettings.viewApps'),
211222
'icon' => $this->urlGenerator->imagePath('settings', 'apps.svg'),
212223
'name' => $l->t('Apps'),
@@ -216,7 +227,7 @@ private function init() {
216227
$this->add([
217228
'type' => 'settings',
218229
'id' => 'settings',
219-
'order' => 2,
230+
'order' => 3,
220231
'href' => $this->urlGenerator->linkToRoute('settings.PersonalSettings.index'),
221232
'name' => $l->t('Personal settings'),
222233
'icon' => $this->urlGenerator->imagePath('settings', 'personal.svg'),
@@ -226,7 +237,7 @@ private function init() {
226237
$this->add([
227238
'type' => 'settings',
228239
'id' => 'admin_settings',
229-
'order' => 3,
240+
'order' => 4,
230241
'href' => $this->urlGenerator->linkToRoute('settings.AdminSettings.index', ['section' => 'overview']),
231242
'name' => $l->t('Administration settings'),
232243
'icon' => $this->urlGenerator->imagePath('settings', 'admin.svg'),
@@ -236,7 +247,7 @@ private function init() {
236247
$this->add([
237248
'type' => 'settings',
238249
'id' => 'settings',
239-
'order' => 2,
250+
'order' => 3,
240251
'href' => $this->urlGenerator->linkToRoute('settings.PersonalSettings.index'),
241252
'name' => $l->t('Settings'),
242253
'icon' => $this->urlGenerator->imagePath('settings', 'admin.svg'),
@@ -261,7 +272,7 @@ private function init() {
261272
$this->add([
262273
'type' => 'settings',
263274
'id' => 'core_users',
264-
'order' => 5,
275+
'order' => 6,
265276
'href' => $this->urlGenerator->linkToRoute('settings.Users.usersList'),
266277
'name' => $l->t('Users'),
267278
'icon' => $this->urlGenerator->imagePath('settings', 'users.svg'),

tests/acceptance/features/header.feature

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ Feature: header
55
Given I am logged in as the admin
66
When I open the Settings menu
77
Then I see that the Settings menu is shown
8-
And I see that the Settings menu has only 8 items
8+
And I see that the Settings menu has only 9 items
99
And I see that the "Set status" item in the Settings menu is shown
10+
And I see that the "Appearance and accessibility" item in the Settings menu is shown
1011
And I see that the "Personal settings" item in the Settings menu is shown
1112
And I see that the "Administration settings" item in the Settings menu is shown
1213
And I see that the "Apps" item in the Settings menu is shown
@@ -18,8 +19,9 @@ Feature: header
1819
Given I am logged in
1920
When I open the Settings menu
2021
Then I see that the Settings menu is shown
21-
And I see that the Settings menu has only 5 items
22+
And I see that the Settings menu has only 6 items
2223
And I see that the "Set status" item in the Settings menu is shown
24+
And I see that the "Appearance and accessibility" item in the Settings menu is shown
2325
And I see that the "Settings" item in the Settings menu is shown
2426
And I see that the "Help" item in the Settings menu is shown
2527
And I see that the "Log out" item in the Settings menu is shown

tests/lib/NavigationManagerTest.php

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,19 @@ public function testWithAppManager($expected, $navigation, $isAdmin = false) {
215215
return vsprintf($text, $parameters);
216216
});
217217

218+
$this->appManager->expects($this->any())
219+
->method('isEnabledForUser')
220+
->with('theming')
221+
->willReturn(true);
218222
$this->appManager->expects($this->once())->method('getAppInfo')->with('test')->willReturn($navigation);
223+
/*
224+
$this->appManager->expects($this->any())
225+
->method('getAppInfo')
226+
->will($this->returnValueMap([
227+
['test', null, null, $navigation],
228+
['theming', null, null, null],
229+
]));
230+
*/
219231
$this->l10nFac->expects($this->any())->method('get')->willReturn($l);
220232
$this->urlGenerator->expects($this->any())->method('imagePath')->willReturnCallback(function ($appName, $file) {
221233
return "/apps/$appName/img/$file";
@@ -230,7 +242,7 @@ public function testWithAppManager($expected, $navigation, $isAdmin = false) {
230242
$user->expects($this->any())->method('getUID')->willReturn('user001');
231243
$this->userSession->expects($this->any())->method('getUser')->willReturn($user);
232244
$this->userSession->expects($this->any())->method('isLoggedIn')->willReturn(true);
233-
$this->appManager->expects($this->once())
245+
$this->appManager->expects($this->any())
234246
->method('getEnabledAppsForUser')
235247
->with($user)
236248
->willReturn(['test']);
@@ -248,7 +260,7 @@ public function providesNavigationConfig() {
248260
$apps = [
249261
'core_apps' => [
250262
'id' => 'core_apps',
251-
'order' => 4,
263+
'order' => 5,
252264
'href' => '/apps/test/',
253265
'icon' => '/apps/settings/img/apps.svg',
254266
'name' => 'Apps',
@@ -259,9 +271,20 @@ public function providesNavigationConfig() {
259271
]
260272
];
261273
$defaults = [
274+
'accessibility_settings' => [
275+
'type' => 'settings',
276+
'id' => 'accessibility_settings',
277+
'order' => 2,
278+
'href' => '/apps/test/',
279+
'name' => 'Appearance and accessibility',
280+
'icon' => '/apps/theming/img/accessibility-dark.svg',
281+
'active' => false,
282+
'classes' => '',
283+
'unread' => 0,
284+
],
262285
'settings' => [
263286
'id' => 'settings',
264-
'order' => 2,
287+
'order' => 3,
265288
'href' => '/apps/test/',
266289
'icon' => '/apps/settings/img/admin.svg',
267290
'name' => 'Settings',
@@ -283,9 +306,10 @@ public function providesNavigationConfig() {
283306
]
284307
];
285308
$adminSettings = [
309+
'accessibility_settings' => $defaults['accessibility_settings'],
286310
'settings' => [
287311
'id' => 'settings',
288-
'order' => 2,
312+
'order' => 3,
289313
'href' => '/apps/test/',
290314
'icon' => '/apps/settings/img/personal.svg',
291315
'name' => 'Personal settings',
@@ -296,7 +320,7 @@ public function providesNavigationConfig() {
296320
],
297321
'admin_settings' => [
298322
'id' => 'admin_settings',
299-
'order' => 3,
323+
'order' => 4,
300324
'href' => '/apps/test/',
301325
'icon' => '/apps/settings/img/admin.svg',
302326
'name' => 'Administration settings',
@@ -310,6 +334,7 @@ public function providesNavigationConfig() {
310334
return [
311335
'minimalistic' => [
312336
array_merge(
337+
['accessibility_settings' => $defaults['accessibility_settings']],
313338
['settings' => $defaults['settings']],
314339
['test' => [
315340
'id' => 'test',
@@ -332,6 +357,7 @@ public function providesNavigationConfig() {
332357
],
333358
'minimalistic-settings' => [
334359
array_merge(
360+
['accessibility_settings' => $defaults['accessibility_settings']],
335361
['settings' => $defaults['settings']],
336362
['test' => [
337363
'id' => 'test',

0 commit comments

Comments
 (0)