Skip to content

Commit f5ab312

Browse files
Create headings for settings pages
Signed-off-by: julia.kirschenheuter <[email protected]>
1 parent d29551a commit f5ab312

11 files changed

+51
-13
lines changed

apps/settings/lib/Controller/AppSettingsController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public function viewApps(): TemplateResponse {
136136
$params['bundles'] = $this->getBundles();
137137
$this->navigationManager->setActiveEntry('core_apps');
138138

139-
$templateResponse = new TemplateResponse('settings', 'settings-vue', ['serverData' => $params]);
139+
$templateResponse = new TemplateResponse('settings', 'settings-vue', ['serverData' => $params, 'pageTitle' => $this->l10n->t('Apps')]);
140140
$policy = new ContentSecurityPolicy();
141141
$policy->addAllowedImageDomain('https://usercontent.apps.nextcloud.com');
142142
$templateResponse->setContentSecurityPolicy($policy);

apps/settings/lib/Controller/UsersController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ public function usersList(): TemplateResponse {
277277
$serverData['newUserRequireEmail'] = $this->config->getAppValue('core', 'newUser.requireEmail', 'no') === 'yes';
278278
$serverData['newUserSendEmail'] = $this->config->getAppValue('core', 'newUser.sendEmail', 'yes') === 'yes';
279279

280-
return new TemplateResponse('settings', 'settings-vue', ['serverData' => $serverData]);
280+
return new TemplateResponse('settings', 'settings-vue', ['serverData' => $serverData, 'pageTitle' => $this->l10n->t('Users')]);
281281
}
282282

283283
/**

apps/settings/src/router.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import Router from 'vue-router'
2727
import { generateUrl } from '@nextcloud/router'
2828
import { APPS_SECTION_ENUM } from './constants/AppsConstants.js'
2929
import store from './store/index.js'
30+
import { setPageHeading } from '../../../core/src/OCP/accessibility.js'
3031

3132
// Dynamic loading
3233
const Users = () => import(/* webpackChunkName: 'settings-users' */'./views/Users')
@@ -126,6 +127,7 @@ router.afterEach(async (to) => {
126127
const metaTitle = await to.meta.title?.(to)
127128
if (metaTitle) {
128129
document.title = `${metaTitle} - ${baseTitle}`
130+
setPageHeading(metaTitle)
129131
} else {
130132
document.title = baseTitle
131133
}

apps/settings/tests/Controller/AppSettingsControllerTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ public function testViewApps() {
209209
'appstoreEnabled' => true,
210210
'bundles' => [],
211211
'developerDocumentation' => ''
212-
]
212+
],
213+
'pageTitle' => 'Apps'
213214
],
214215
'user');
215216
$expected->setContentSecurityPolicy($policy);
@@ -243,7 +244,8 @@ public function testViewAppsAppstoreNotEnabled() {
243244
'appstoreEnabled' => false,
244245
'bundles' => [],
245246
'developerDocumentation' => ''
246-
]
247+
],
248+
'pageTitle' => 'Apps'
247249
],
248250
'user');
249251
$expected->setContentSecurityPolicy($policy);

core/src/OCP/accessibility.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,23 @@
2222

2323
import { loadState } from '@nextcloud/initial-state'
2424

25+
/**
26+
* Set the page heading
27+
*
28+
* @param {string} heading page title from the history api
29+
*/
30+
export function setPageHeading(heading) {
31+
const headingEl = document.getElementById('page-heading-level-1')
32+
if (headingEl) {
33+
headingEl.textContent = heading
34+
}
35+
}
2536
export default {
2637
/**
2738
* @return {boolean} Whether the user opted-out of shortcuts so that they should not be registered
2839
*/
2940
disableKeyboardShortcuts() {
3041
return loadState('theming', 'shortcutsDisabled', false)
3142
},
43+
setPageHeading,
3244
}

core/templates/layout.user.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@
5757
</div>
5858

5959
<header role="banner" id="header">
60+
<h1 class="hidden-visually" id="page-heading-level-1">
61+
<?php p(!empty($_['pageTitle'])?$_['pageTitle']:$theme->getName()); ?>
62+
</h1>
6063
<div class="header-left">
6164
<a href="<?php print_unescaped($_['logoUrl'] ?: link_to('', 'index.php')); ?>"
6265
id="nextcloud">
@@ -89,9 +92,6 @@
8992
</form>
9093

9194
<main id="content" class="app-<?php p($_['appid']) ?>">
92-
<h1 class="hidden-visually">
93-
<?php p($l->t('%s\'s homepage', [$theme->getName()])); ?>
94-
</h1>
9595
<?php print_unescaped($_['content']); ?>
9696
</main>
9797
<div id="profiler-toolbar"></div>

dist/core-main.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/core-main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/settings-vue-settings-apps-users-management.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/settings-vue-settings-apps-users-management.js.LICENSE.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,25 @@
114114
* along with this program. If not, see <http://www.gnu.org/licenses/>.
115115
*
116116
*/
117+
118+
/**
119+
* @copyright Copyright (c) 2022 Joas Schilling <[email protected]>
120+
*
121+
* @author Joas Schilling <[email protected]>
122+
*
123+
* @license AGPL-3.0-or-later
124+
*
125+
* This program is free software: you can redistribute it and/or modify
126+
* it under the terms of the GNU Affero General Public License as
127+
* published by the Free Software Foundation, either version 3 of the
128+
* License, or (at your option) any later version.
129+
*
130+
* This program is distributed in the hope that it will be useful,
131+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
132+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
133+
* GNU Affero General Public License for more details.
134+
*
135+
* You should have received a copy of the GNU Affero General Public License
136+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
137+
*
138+
*/

0 commit comments

Comments
 (0)