diff options
author | provokateurin <kate@provokateurin.de> | 2024-08-27 13:11:30 +0200 |
---|---|---|
committer | provokateurin <kate@provokateurin.de> | 2024-09-09 11:04:36 +0200 |
commit | 0a3093d05da92036684afb5814a4925b443468f7 (patch) | |
tree | 89f89e40346d98efc37ecededc55c571e4ec35db | |
parent | 669641142b35407ae8b6cce1cda95fdb77747ac9 (diff) | |
download | nextcloud-server-0a3093d05da92036684afb5814a4925b443468f7.tar.gz nextcloud-server-0a3093d05da92036684afb5814a4925b443468f7.zip |
fix(theming): Use NavigationManager to handle default entries
Signed-off-by: provokateurin <kate@provokateurin.de>
-rw-r--r-- | apps/theming/lib/Controller/ThemingController.php | 10 | ||||
-rw-r--r-- | apps/theming/lib/Settings/Personal.php | 10 | ||||
-rw-r--r-- | apps/theming/src/components/UserAppMenuSection.vue | 2 | ||||
-rw-r--r-- | apps/theming/tests/Controller/ThemingControllerTest.php | 5 | ||||
-rw-r--r-- | apps/theming/tests/Settings/PersonalTest.php | 15 |
5 files changed, 26 insertions, 16 deletions
diff --git a/apps/theming/lib/Controller/ThemingController.php b/apps/theming/lib/Controller/ThemingController.php index 73ef78c7a8e..ce7a4eca8f3 100644 --- a/apps/theming/lib/Controller/ThemingController.php +++ b/apps/theming/lib/Controller/ThemingController.php @@ -26,6 +26,7 @@ use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; use OCP\IConfig; use OCP\IL10N; +use OCP\INavigationManager; use OCP\IRequest; use OCP\IURLGenerator; use ScssPhp\ScssPhp\Compiler; @@ -47,6 +48,7 @@ class ThemingController extends Controller { private IAppManager $appManager; private ImageManager $imageManager; private ThemesService $themesService; + private INavigationManager $navigationManager; public function __construct( $appName, @@ -57,7 +59,8 @@ class ThemingController extends Controller { IURLGenerator $urlGenerator, IAppManager $appManager, ImageManager $imageManager, - ThemesService $themesService + ThemesService $themesService, + INavigationManager $navigationManager, ) { parent::__construct($appName, $request); @@ -68,6 +71,7 @@ class ThemingController extends Controller { $this->appManager = $appManager; $this->imageManager = $imageManager; $this->themesService = $themesService; + $this->navigationManager = $navigationManager; } /** @@ -163,7 +167,7 @@ class ThemingController extends Controller { case 'defaultApps': if (is_array($value)) { try { - $this->appManager->setDefaultApps($value); + $this->navigationManager->setDefaultEntryIds($value); } catch (InvalidArgumentException $e) { $error = $this->l10n->t('Invalid app given'); } @@ -310,7 +314,7 @@ class ThemingController extends Controller { #[AuthorizedAdminSetting(settings: Admin::class)] public function undoAll(): DataResponse { $this->themingDefaults->undoAll(); - $this->appManager->setDefaultApps([]); + $this->navigationManager->setDefaultEntryIds([]); return new DataResponse( [ diff --git a/apps/theming/lib/Settings/Personal.php b/apps/theming/lib/Settings/Personal.php index 3dc64141dc3..9f78f2cbc35 100644 --- a/apps/theming/lib/Settings/Personal.php +++ b/apps/theming/lib/Settings/Personal.php @@ -9,10 +9,10 @@ use OCA\Theming\ITheme; use OCA\Theming\Service\BackgroundService; use OCA\Theming\Service\ThemesService; use OCA\Theming\ThemingDefaults; -use OCP\App\IAppManager; use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Services\IInitialState; use OCP\IConfig; +use OCP\INavigationManager; use OCP\Settings\ISettings; use OCP\Util; @@ -25,7 +25,7 @@ class Personal implements ISettings { private ThemesService $themesService, private IInitialState $initialStateService, private ThemingDefaults $themingDefaults, - private IAppManager $appManager, + private INavigationManager $navigationManager, ) { } @@ -49,8 +49,8 @@ class Personal implements ISettings { }); } - // Get the default app enforced by admin - $forcedDefaultApp = $this->appManager->getDefaultAppForUser(null, false); + // Get the default entry enforced by admin + $forcedDefaultEntry = $this->navigationManager->getDefaultEntryIdForUser(null, false); /** List of all shipped backgrounds */ $this->initialStateService->provideInitialState('shippedBackgrounds', BackgroundService::SHIPPED_BACKGROUNDS); @@ -78,7 +78,7 @@ class Personal implements ISettings { $this->initialStateService->provideInitialState('enableBlurFilter', $this->config->getUserValue($this->userId, 'theming', 'force_enable_blur_filter', '')); $this->initialStateService->provideInitialState('navigationBar', [ 'userAppOrder' => json_decode($this->config->getUserValue($this->userId, 'core', 'apporder', '[]'), true, flags:JSON_THROW_ON_ERROR), - 'enforcedDefaultApp' => $forcedDefaultApp + 'enforcedDefaultApp' => $forcedDefaultEntry ]); Util::addScript($this->appName, 'personal-theming'); diff --git a/apps/theming/src/components/UserAppMenuSection.vue b/apps/theming/src/components/UserAppMenuSection.vue index 56abd357274..6459c245824 100644 --- a/apps/theming/src/components/UserAppMenuSection.vue +++ b/apps/theming/src/components/UserAppMenuSection.vue @@ -81,7 +81,7 @@ export default defineComponent({ */ const initialAppOrder = loadState<INavigationEntry[]>('core', 'apps') .filter(({ type }) => type === 'link') - .map((app) => ({ ...app, label: app.name, default: app.default && app.app === enforcedDefaultApp })) + .map((app) => ({ ...app, label: app.name, default: app.default && app.id === enforcedDefaultApp })) /** * Check if a custom app order is used or the default is shown diff --git a/apps/theming/tests/Controller/ThemingControllerTest.php b/apps/theming/tests/Controller/ThemingControllerTest.php index 86231e7daf7..fd520231e63 100644 --- a/apps/theming/tests/Controller/ThemingControllerTest.php +++ b/apps/theming/tests/Controller/ThemingControllerTest.php @@ -18,6 +18,7 @@ use OCP\Files\NotFoundException; use OCP\Files\SimpleFS\ISimpleFile; use OCP\IConfig; use OCP\IL10N; +use OCP\INavigationManager; use OCP\IRequest; use OCP\IURLGenerator; use PHPUnit\Framework\MockObject\MockObject; @@ -42,6 +43,8 @@ class ThemingControllerTest extends TestCase { private $urlGenerator; /** @var ThemesService|MockObject */ private $themesService; + /** @var INavigationManager|MockObject */ + private $navigationManager; protected function setUp(): void { $this->request = $this->createMock(IRequest::class); @@ -52,6 +55,7 @@ class ThemingControllerTest extends TestCase { $this->urlGenerator = $this->createMock(IURLGenerator::class); $this->imageManager = $this->createMock(ImageManager::class); $this->themesService = $this->createMock(ThemesService::class); + $this->navigationManager = $this->createMock(INavigationManager::class); $timeFactory = $this->createMock(ITimeFactory::class); $timeFactory->expects($this->any()) @@ -70,6 +74,7 @@ class ThemingControllerTest extends TestCase { $this->appManager, $this->imageManager, $this->themesService, + $this->navigationManager, ); parent::setUp(); diff --git a/apps/theming/tests/Settings/PersonalTest.php b/apps/theming/tests/Settings/PersonalTest.php index 2313b3062a0..88c5e93d1c7 100644 --- a/apps/theming/tests/Settings/PersonalTest.php +++ b/apps/theming/tests/Settings/PersonalTest.php @@ -24,6 +24,7 @@ use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Services\IInitialState; use OCP\IConfig; use OCP\IL10N; +use OCP\INavigationManager; use OCP\IURLGenerator; use OCP\IUserSession; use PHPUnit\Framework\MockObject\MockObject; @@ -34,7 +35,7 @@ class PersonalTest extends TestCase { private ThemesService&MockObject $themesService; private IInitialState&MockObject $initialStateService; private ThemingDefaults&MockObject $themingDefaults; - private IAppManager&MockObject $appManager; + private INavigationManager&MockObject $navigationManager; private Personal $admin; /** @var ITheme[] */ @@ -46,7 +47,7 @@ class PersonalTest extends TestCase { $this->themesService = $this->createMock(ThemesService::class); $this->initialStateService = $this->createMock(IInitialState::class); $this->themingDefaults = $this->createMock(ThemingDefaults::class); - $this->appManager = $this->createMock(IAppManager::class); + $this->navigationManager = $this->createMock(INavigationManager::class); $this->initThemes(); @@ -62,7 +63,7 @@ class PersonalTest extends TestCase { $this->themesService, $this->initialStateService, $this->themingDefaults, - $this->appManager, + $this->navigationManager, ); } @@ -103,9 +104,9 @@ class PersonalTest extends TestCase { ['admin', 'theming', 'background_image', BackgroundService::BACKGROUND_DEFAULT], ]); - $this->appManager->expects($this->once()) - ->method('getDefaultAppForUser') - ->willReturn('forcedapp'); + $this->navigationManager->expects($this->once()) + ->method('getDefaultEntryIdForUser') + ->willReturn('forced_id'); $this->initialStateService->expects($this->exactly(8)) ->method('provideInitialState') @@ -117,7 +118,7 @@ class PersonalTest extends TestCase { ['themes', $themesState], ['enforceTheme', $enforcedTheme], ['isUserThemingDisabled', false], - ['navigationBar', ['userAppOrder' => [], 'enforcedDefaultApp' => 'forcedapp']], + ['navigationBar', ['userAppOrder' => [], 'enforcedDefaultApp' => 'forced_id']], ]); $expected = new TemplateResponse('theming', 'settings-personal'); |