Skip to content

Commit 2a58e76

Browse files
Merge pull request #1109 from nextcloud/backport/1081/stable26
[stable26] Create headings for sidebar pages
2 parents 9c15b6f + 7cd86ef commit 2a58e76

3 files changed

Lines changed: 17 additions & 3 deletions

File tree

js/script.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ $(function(){
5959
var navigationLink = this.$navigation.find('a[data-navigation=' + filter + ']');
6060
navigationLink.parent().addClass('active').attr('aria-current', 'page');
6161
window.document.title = navigationLink.text().trim() + ' - ' + this.defaultPageTitle;
62-
62+
OCP.Accessibility.setPageHeading(navigationLink.text().trim());
6363
OCA.Activity.InfinitScrolling.prefill();
6464
}
6565
};

lib/Controller/ActivitiesController.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use OCP\AppFramework\Controller;
2828
use OCP\AppFramework\Http\TemplateResponse;
2929
use OCP\IConfig;
30+
use OCP\IL10N;
3031
use OCP\IRequest;
3132
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
3233
use Symfony\Component\EventDispatcher\GenericEvent;
@@ -38,6 +39,9 @@ class ActivitiesController extends Controller {
3839
/** @var Data */
3940
protected $data;
4041

42+
/** @var IL10N */
43+
private $l10n;
44+
4145
/** @var Navigation */
4246
protected $navigation;
4347

@@ -51,18 +55,21 @@ class ActivitiesController extends Controller {
5155
* @param Data $data
5256
* @param Navigation $navigation
5357
* @param EventDispatcherInterface $eventDispatcher
58+
* @param IL10N $l10n
5459
*/
5560
public function __construct($appName,
5661
IRequest $request,
5762
IConfig $config,
5863
Data $data,
5964
Navigation $navigation,
60-
EventDispatcherInterface $eventDispatcher) {
65+
EventDispatcherInterface $eventDispatcher,
66+
IL10N $l10n) {
6167
parent::__construct($appName, $request);
6268
$this->data = $data;
6369
$this->config = $config;
6470
$this->navigation = $navigation;
6571
$this->eventDispatcher = $eventDispatcher;
72+
$this->l10n = $l10n;
6673
}
6774

6875
/**
@@ -82,6 +89,7 @@ public function showList($filter = 'all') {
8289
'appNavigation' => $this->navigation->getTemplate($filter),
8390
'avatars' => $this->config->getSystemValue('enable_avatars', true) ? 'yes' : 'no',
8491
'filter' => $filter,
92+
'pageTitle' => $this->l10n->t('Activity')
8593
]);
8694
}
8795
}

tests/Controller/ActivitiesControllerTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
use OCA\Activity\Controller\ActivitiesController;
2626
use OCA\Activity\Tests\TestCase;
27+
use OCP\IL10N;
2728
use OCP\ILogger;
2829
use OCP\Template;
2930
use PHPUnit\Framework\MockObject\MockObject;
@@ -51,6 +52,8 @@ class ActivitiesControllerTest extends TestCase {
5152
protected $eventDispatcher;
5253
/** @var Navigation|MockObject */
5354
protected $navigation;
55+
/** @var IL10N */
56+
protected $l10n;
5457

5558
/** @var ActivitiesController */
5659
protected $controller;
@@ -63,6 +66,7 @@ protected function setUp(): void {
6366
$this->navigation = $this->createMock(Navigation::class);
6467
$this->eventDispatcher = $this->createMock(EventDispatcherInterface::class);
6568
$this->request = $this->createMock(IRequest::class);
69+
$this->l10n = $this->createMock(IL10N::class);
6670

6771
$this->controller = $this->getController();
6872
}
@@ -75,7 +79,8 @@ protected function getController(array $methods = []): ActivitiesController {
7579
$this->config,
7680
$this->data,
7781
$this->navigation,
78-
$this->eventDispatcher
82+
$this->eventDispatcher,
83+
$this->l10n,
7984
);
8085
}
8186

@@ -87,6 +92,7 @@ protected function getController(array $methods = []): ActivitiesController {
8792
$this->data,
8893
$this->navigation,
8994
$this->eventDispatcher,
95+
$this->l10n,
9096
])
9197
->onlyMethods($methods)
9298
->getMock();

0 commit comments

Comments
 (0)