Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions apps/theming/lib/Service/ThemesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,7 @@ public function isEnabled(ITheme $theme): bool {
}

/**
* 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[]
*/
Expand Down
19 changes: 19 additions & 0 deletions cypress/e2e/core/404-error.cy.ts
Original file line number Diff line number Diff line change
@@ -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$/)
})
})
24 changes: 6 additions & 18 deletions lib/private/TemplateLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,6 @@ public function __construct($renderAs, $appId = '') {
} 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', '');
Expand Down Expand Up @@ -151,23 +144,13 @@ public function __construct($renderAs, $appId = '') {
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) {
parent::__construct('core', 'layout.public');
$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);
Expand Down Expand Up @@ -195,10 +178,15 @@ public function __construct($renderAs, $appId = '') {
} 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);
Expand Down
6 changes: 6 additions & 0 deletions tests/lib/TemplateLayoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use OC\InitialStateService;
use OC\TemplateLayout;
use OCA\Theming\Service\ThemesService;
use OCP\App\IAppManager;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
Expand Down Expand Up @@ -45,7 +46,12 @@ public function testVersionHash($path, $file, $installed, $debug, $expected): vo
->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);
Expand Down
Loading