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:07:48 +0200 |
commit | 5c3bb1d91d4a95482a0ec6a73fd1eed242b6da96 (patch) | |
tree | a16297ec3ae822e07152e34df3b87345d05dfc73 | |
parent | 1526a64cce1f8ff8ead73ee27d4c9ea25fd84d81 (diff) | |
download | nextcloud-server-fix/29-template-layout.tar.gz nextcloud-server-fix/29-template-layout.zip |
fix: ensure enabled themes are set on the templatefix/29-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 | 28 |
3 files changed, 28 insertions, 22 deletions
diff --git a/apps/theming/lib/Service/ThemesService.php b/apps/theming/lib/Service/ThemesService.php index d7127173848..fba63923a20 100644 --- a/apps/theming/lib/Service/ThemesService.php +++ b/apps/theming/lib/Service/ThemesService.php @@ -164,8 +164,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 5d29b06a73b..7d7002c71db 100644 --- a/lib/private/TemplateLayout.php +++ b/lib/private/TemplateLayout.php @@ -112,13 +112,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', ''); @@ -183,8 +176,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) { @@ -192,14 +183,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); @@ -227,9 +210,14 @@ class TemplateLayout extends \OC_Template { } else { parent::__construct('core', 'layout.base'); } - // Send the language and the locale to our layouts - $lang = \OC::$server->getL10NFactory()->findLanguage(); - $locale = \OC::$server->getL10NFactory()->findLocale($lang); + + // 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); $lang = str_replace('_', '-', $lang); $this->assign('language', $lang); |