diff --git a/apps/theming/appinfo/routes.php b/apps/theming/appinfo/routes.php index eceb447620d..8647ae135a8 100644 --- a/apps/theming/appinfo/routes.php +++ b/apps/theming/appinfo/routes.php @@ -39,6 +39,11 @@ return [ 'url' => '/ajax/undoChanges', 'verb' => 'POST' ], + [ + 'name' => 'Theming#undoAll', + 'url' => '/ajax/undoAllChanges', + 'verb' => 'POST' + ], [ 'name' => 'Theming#uploadImage', 'url' => '/ajax/uploadImage', 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 @@ -275,6 +275,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 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(); diff --git a/apps/theming/src/AdminTheming.vue b/apps/theming/src/AdminTheming.vue index bb26dcc0f30..f922143e04d 100644 --- a/apps/theming/src/AdminTheming.vue +++ b/apps/theming/src/AdminTheming.vue @@ -58,15 +58,15 @@ -
-