From 4d9d617c840431568fc17540937b231b1bc2d698 Mon Sep 17 00:00:00 2001 From: skjnldsv Date: Fri, 8 Nov 2024 08:57:22 +0100 Subject: feat(files_sharing): use share node or label as page title Signed-off-by: skjnldsv --- apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php | 4 ++++ apps/files_sharing/tests/Controller/ShareControllerTest.php | 3 +++ 2 files changed, 7 insertions(+) (limited to 'apps') diff --git a/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php b/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php index dad1f332458..0c76f0e1742 100644 --- a/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php +++ b/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php @@ -130,12 +130,16 @@ class DefaultPublicShareTemplateProvider implements IPublicShareTemplateProvider 'index', ); $response->setContentSecurityPolicy($csp); + // If the share has a label, use it as the title if ($share->getLabel() !== '') { $response->setHeaderTitle($share->getLabel()); + $response->setParams(['pageTitle' => $share->getLabel()]); } else { $response->setHeaderTitle($shareNode->getName()); + $response->setParams(['pageTitle' => $shareNode->getName()]); } + if ($ownerName !== '') { $response->setHeaderDetails($this->l10n->t('shared by %s', [$ownerName])); } diff --git a/apps/files_sharing/tests/Controller/ShareControllerTest.php b/apps/files_sharing/tests/Controller/ShareControllerTest.php index 5d962dff4c0..bc8e5dede63 100644 --- a/apps/files_sharing/tests/Controller/ShareControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareControllerTest.php @@ -338,6 +338,7 @@ class ShareControllerTest extends \Test\TestCase { $csp = new ContentSecurityPolicy(); $csp->addAllowedFrameDomain('\'self\''); $expectedResponse = new PublicTemplateResponse('files', 'index'); + $expectedResponse->setParams(['pageTitle' => $filename]); $expectedResponse->setContentSecurityPolicy($csp); $expectedResponse->setHeaderTitle($filename); $expectedResponse->setHeaderDetails('shared by ownerDisplay'); @@ -477,6 +478,7 @@ class ShareControllerTest extends \Test\TestCase { $csp = new ContentSecurityPolicy(); $csp->addAllowedFrameDomain('\'self\''); $expectedResponse = new PublicTemplateResponse('files', 'index'); + $expectedResponse->setParams(['pageTitle' => $filename]); $expectedResponse->setContentSecurityPolicy($csp); $expectedResponse->setHeaderTitle($filename); $expectedResponse->setHeaderDetails('shared by ownerDisplay'); @@ -604,6 +606,7 @@ class ShareControllerTest extends \Test\TestCase { $csp = new ContentSecurityPolicy(); $csp->addAllowedFrameDomain('\'self\''); $expectedResponse = new PublicTemplateResponse('files', 'index'); + $expectedResponse->setParams(['pageTitle' => $filename]); $expectedResponse->setContentSecurityPolicy($csp); $expectedResponse->setHeaderTitle($filename); $expectedResponse->setHeaderDetails(''); -- cgit v1.2.3