From 8cafed838dd648c4fbb4489dda2dc40064a9547e Mon Sep 17 00:00:00 2001 From: Simon L Date: Wed, 5 Feb 2025 14:37:08 +0100 Subject: [PATCH] feat(theming): allow to disable standalone windows Co-authored-by: Ferdinand Thiessen Signed-off-by: Simon L. Signed-off-by: Hamza Mahjoubi --- .../lib/Controller/ThemingController.php | 2 +- .../tests/Controller/ThemingControllerTest.php | 17 +++++++++++++++-- config/config.sample.php | 8 ++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/apps/theming/lib/Controller/ThemingController.php b/apps/theming/lib/Controller/ThemingController.php index 5b83d3bdb8b59..f26d2188c5e5d 100644 --- a/apps/theming/lib/Controller/ThemingController.php +++ b/apps/theming/lib/Controller/ThemingController.php @@ -474,7 +474,7 @@ public function getManifest(string $app): JSONResponse { 'sizes' => '16x16' ] ], - 'display' => 'standalone' + 'display' => $this->config->getSystemValueBool('theming.standalone_window.enabled', true) ? 'standalone' : 'browser' ]; $response = new JSONResponse($responseJS); $response->cacheFor(3600); diff --git a/apps/theming/tests/Controller/ThemingControllerTest.php b/apps/theming/tests/Controller/ThemingControllerTest.php index 629bc570032a7..f0c5ed744ea1f 100644 --- a/apps/theming/tests/Controller/ThemingControllerTest.php +++ b/apps/theming/tests/Controller/ThemingControllerTest.php @@ -705,7 +705,15 @@ public function testGetLoginBackground() { @$this->assertEquals($expected, $this->themingController->getImage('background')); } - public function testGetManifest() { + public static function dataGetManifest(): array { + return [ + [true], + [false], + ]; + } + + /** @dataProvider dataGetManifest */ + public function testGetManifest(bool $standalone) { $this->config ->expects($this->once()) ->method('getAppValue') @@ -729,6 +737,11 @@ public function testGetManifest() { 'touchicon', 'favicon', ); + $this->config + ->expects($this->once()) + ->method('getSystemValueBool') + ->with('theming.standalone_window.enabled', true) + ->willReturn($standalone); $response = new Http\JSONResponse([ 'name' => 'Nextcloud', 'start_url' => 'localhost', @@ -745,7 +758,7 @@ public function testGetManifest() { 'sizes' => '16x16' ] ], - 'display' => 'standalone', + 'display' => $standalone ? 'standalone' : 'browser', 'short_name' => 'Nextcloud', 'theme_color' => null, 'background_color' => null, diff --git a/config/config.sample.php b/config/config.sample.php index ac03cec50aacf..aaf3dba280917 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -2079,6 +2079,14 @@ */ 'enforce_theme' => '', + +/** + * This setting allows to disable the PWA functionality that allows browsers to open web applications in dedicated windows. + * + * Defaults to ``true`` + */ +'theming.standalone_window.enabled' => true, + /** * The default cipher for encrypting files. Currently supported are: * - AES-256-CTR