diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2025-04-04 09:00:43 +0200 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2025-04-04 10:10:25 +0200 |
commit | 8a0bc2422def824cb404cabcc9b6c5a11974b0dd (patch) | |
tree | 09a99be9d424ac4754b05c06d5405720d17d38f4 | |
parent | dc2a087e3052b441a196145d160d438a11e0b028 (diff) | |
download | nextcloud-server-fix/30-template-layout.tar.gz nextcloud-server-fix/30-template-layout.zip |
fix: ensure enabled themes are set on the templatefix/30-template-layout
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
-rw-r--r-- | apps/theming/lib/Service/ThemesService.php | 3 | ||||
-rw-r--r-- | cypress/e2e/core/404-error.cy.ts | 19 | ||||
-rw-r--r-- | lib/private/TemplateLayout.php | 24 |
3 files changed, 26 insertions, 20 deletions
diff --git a/apps/theming/lib/Service/ThemesService.php b/apps/theming/lib/Service/ThemesService.php index 3b40e72bb5b..a269f86ecba 100644 --- a/apps/theming/lib/Service/ThemesService.php +++ b/apps/theming/lib/Service/ThemesService.php @@ -147,8 +147,7 @@ class ThemesService { } /** - * Get the list of all enabled themes IDs - * for the logged-in user + * Get the list of all enabled themes IDs for the current user. * * @return string[] */ diff --git a/cypress/e2e/core/404-error.cy.ts b/cypress/e2e/core/404-error.cy.ts new file mode 100644 index 00000000000..b24562933e8 --- /dev/null +++ b/cypress/e2e/core/404-error.cy.ts @@ -0,0 +1,19 @@ +/** + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +describe('404 error page', { testIsolation: true }, () => { + it('renders 404 page', () => { + cy.visit('/doesnotexist', { failOnStatusCode: false }) + + cy.findByRole('heading', { name: /Page not found/ }) + .should('be.visible') + cy.findByRole('link', { name: /Back to Nextcloud/ }) + .should('be.visible') + .click() + + cy.url() + .should('match', /(\/index.php)\/login$/) + }) +}) diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php index 86198a4d2c5..420fc414279 100644 --- a/lib/private/TemplateLayout.php +++ b/lib/private/TemplateLayout.php @@ -80,13 +80,6 @@ class TemplateLayout extends \OC_Template { } else { Util::addScript('core', 'unified-search', 'core'); } - // Set body data-theme - $this->assign('enabledThemes', []); - if ($this->appManager->isEnabledForUser('theming') && class_exists('\OCA\Theming\Service\ThemesService')) { - /** @var \OCA\Theming\Service\ThemesService */ - $themesService = \OC::$server->get(\OCA\Theming\Service\ThemesService::class); - $this->assign('enabledThemes', $themesService->getEnabledThemes()); - } // Set logo link target $logoUrl = $this->config->getSystemValueString('logo_url', ''); @@ -151,8 +144,6 @@ class TemplateLayout extends \OC_Template { if ($user) { $userDisplayName = $user->getDisplayName(); } - $theme = $this->config->getSystemValueString('enforce_theme', ''); - $this->assign('enabledThemes', $theme === '' ? [] : [$theme]); $this->assign('user_displayname', $userDisplayName); $this->assign('user_uid', \OC_User::getUser()); } elseif ($renderAs === TemplateResponse::RENDER_AS_PUBLIC) { @@ -160,14 +151,6 @@ class TemplateLayout extends \OC_Template { $this->assign('appid', $appId); $this->assign('bodyid', 'body-public'); - // Set body data-theme - $this->assign('enabledThemes', []); - if ($this->appManager->isEnabledForUser('theming') && class_exists('\OCA\Theming\Service\ThemesService')) { - /** @var \OCA\Theming\Service\ThemesService $themesService */ - $themesService = \OC::$server->get(\OCA\Theming\Service\ThemesService::class); - $this->assign('enabledThemes', $themesService->getEnabledThemes()); - } - // Set logo link target $logoUrl = $this->config->getSystemValueString('logo_url', ''); $this->assign('logoUrl', $logoUrl); @@ -195,7 +178,12 @@ class TemplateLayout extends \OC_Template { } else { parent::__construct('core', 'layout.base'); } - // Send the language and the locale to our layouts + + // Set body data-theme + $themesService = \OCP\Server::get(\OCA\Theming\Service\ThemesService::class); + $this->assign('enabledThemes', $themesService->getEnabledThemes()); + + // Send the language, locale, and direction to our layouts $lang = \OC::$server->get(IFactory::class)->findLanguage(); $locale = \OC::$server->get(IFactory::class)->findLocale($lang); |