diff options
author | John Molakvoæ <skjnldsv@protonmail.com> | 2022-11-30 17:45:58 +0100 |
---|---|---|
committer | John Molakvoæ <skjnldsv@protonmail.com> | 2022-11-30 18:39:57 +0100 |
commit | f26ee9c69d98b9208f709e0c7aa284755708adbd (patch) | |
tree | 1edfb8f4d680e6e4ff3940e3f1ac3f068326fd8e /apps/theming/lib | |
parent | 8434259b1bfef22adbf30b166043e29763bf9507 (diff) | |
download | nextcloud-server-f26ee9c69d98b9208f709e0c7aa284755708adbd.tar.gz nextcloud-server-f26ee9c69d98b9208f709e0c7aa284755708adbd.zip |
Faster theming tests, better colours comparison and properly follow admin theming changes
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/theming/lib')
-rw-r--r-- | apps/theming/lib/Controller/ThemingController.php | 21 | ||||
-rw-r--r-- | apps/theming/lib/Controller/UserThemeController.php | 1 | ||||
-rw-r--r-- | apps/theming/lib/Service/BackgroundService.php | 2 | ||||
-rw-r--r-- | apps/theming/lib/ThemingDefaults.php | 12 |
4 files changed, 33 insertions, 3 deletions
diff --git a/apps/theming/lib/Controller/ThemingController.php b/apps/theming/lib/Controller/ThemingController.php index 2cac9a345a4..8868208197d 100644 --- a/apps/theming/lib/Controller/ThemingController.php +++ b/apps/theming/lib/Controller/ThemingController.php @@ -276,6 +276,27 @@ class ThemingController extends Controller { } /** + * Revert all theming settings to their default values + * @AuthorizedAdminSetting(settings=OCA\Theming\Settings\Admin) + * + * @return DataResponse + * @throws NotPermittedException + */ + public function undoAll(): DataResponse { + $this->themingDefaults->undoAll(); + + return new DataResponse( + [ + 'data' => + [ + 'message' => $this->l10n->t('Saved'), + ], + 'status' => 'success' + ] + ); + } + + /** * @PublicPage * @NoCSRFRequired * @NoSameSiteCookieRequired diff --git a/apps/theming/lib/Controller/UserThemeController.php b/apps/theming/lib/Controller/UserThemeController.php index 112a8a23638..a227e72d998 100644 --- a/apps/theming/lib/Controller/UserThemeController.php +++ b/apps/theming/lib/Controller/UserThemeController.php @@ -186,6 +186,7 @@ class UserThemeController extends OCSController { $this->backgroundService->setFileBackground($value); break; case BackgroundService::BACKGROUND_DEFAULT: + // Delete both background and color keys $this->backgroundService->setDefaultBackground(); break; default: diff --git a/apps/theming/lib/Service/BackgroundService.php b/apps/theming/lib/Service/BackgroundService.php index a3af56b08f8..4879ad1cbad 100644 --- a/apps/theming/lib/Service/BackgroundService.php +++ b/apps/theming/lib/Service/BackgroundService.php @@ -160,7 +160,7 @@ class BackgroundService { public function setDefaultBackground(): void { $this->config->deleteUserValue($this->userId, Application::APP_ID, 'background_image'); - $this->config->setUserValue($this->userId, Application::APP_ID, 'background_color', $this->themingDefaults->getDefaultColorPrimary()); + $this->config->deleteUserValue($this->userId, Application::APP_ID, 'background_color'); } /** diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php index 881a27f9936..afec58dc3a3 100644 --- a/apps/theming/lib/ThemingDefaults.php +++ b/apps/theming/lib/ThemingDefaults.php @@ -439,18 +439,26 @@ class ThemingDefaults extends \OC_Defaults { * @param string $setting * @param string $value */ - public function set($setting, $value) { + public function set($setting, $value): void { $this->config->setAppValue('theming', $setting, $value); $this->increaseCacheBuster(); } /** + * Revert all settings to the default value + */ + public function undoAll(): void { + $this->config->deleteAppValues('theming'); + $this->increaseCacheBuster(); + } + + /** * Revert settings to the default value * * @param string $setting setting which should be reverted * @return string default value */ - public function undo($setting) { + public function undo($setting): string { $this->config->deleteAppValue('theming', $setting); $this->increaseCacheBuster(); |