mirror of
https://github.com/nextcloud/server.git
synced 2026-04-21 14:23:17 -04:00
fix: ensure enabled themes are set on the template
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
parent
287b520471
commit
00580b369e
4 changed files with 32 additions and 20 deletions
|
|
@ -148,8 +148,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[]
|
||||
*/
|
||||
|
|
|
|||
19
cypress/e2e/core/404-error.cy.ts
Normal file
19
cypress/e2e/core/404-error.cy.ts
Normal file
|
|
@ -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$/)
|
||||
})
|
||||
})
|
||||
|
|
@ -81,13 +81,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,10 +178,15 @@ class TemplateLayout extends \OC_Template {
|
|||
} else {
|
||||
parent::__construct('core', 'layout.base');
|
||||
}
|
||||
|
||||
// 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);
|
||||
$direction = \OC::$server->getL10NFactory()->getLanguageDirection($lang);
|
||||
$direction = \OC::$server->get(IFactory::class)->getLanguageDirection($lang);
|
||||
|
||||
$lang = str_replace('_', '-', $lang);
|
||||
$this->assign('language', $lang);
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ namespace Test;
|
|||
|
||||
use OC\InitialStateService;
|
||||
use OC\TemplateLayout;
|
||||
use OCA\Theming\Service\ThemesService;
|
||||
use OCP\App\IAppManager;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\IConfig;
|
||||
|
|
@ -45,7 +46,12 @@ class TemplateLayoutTest extends \Test\TestCase {
|
|||
->willReturn('42');
|
||||
|
||||
$initialState = $this->createMock(InitialStateService::class);
|
||||
$themesService = $this->createMock(ThemesService::class);
|
||||
$themesService->expects(self::once())
|
||||
->method('getEnabledThemes')
|
||||
->willReturn([]);
|
||||
|
||||
$this->overwriteService(ThemesService::class, $themesService);
|
||||
$this->overwriteService(IConfig::class, $config);
|
||||
$this->overwriteService(IAppManager::class, $appManager);
|
||||
$this->overwriteService(InitialStateService::class, $initialState);
|
||||
|
|
|
|||
Loading…
Reference in a new issue