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 | |
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')
-rw-r--r-- | apps/theming/appinfo/routes.php | 5 | ||||
-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 | ||||
-rw-r--r-- | apps/theming/src/AdminTheming.vue | 6 | ||||
-rw-r--r-- | apps/theming/src/components/admin/FileInputField.vue | 6 |
7 files changed, 44 insertions, 9 deletions
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 @@ -40,6 +40,11 @@ return [ 'verb' => 'POST' ], [ + 'name' => 'Theming#undoAll', + 'url' => '/ajax/undoAllChanges', + 'verb' => 'POST' + ], + [ 'name' => 'Theming#uploadImage', 'url' => '/ajax/uploadImage', 'verb' => 'POST' 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(); 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 @@ <FileInputField v-for="field in fileInputFields" :key="field.name" :aria-label="field.ariaLabel" + :data-admin-theming-setting-file="field.name" :default-mime-value="field.defaultMimeValue" :display-name="field.displayName" :mime-name="field.mimeName" :mime-value.sync="field.mimeValue" :name="field.name" - data-admin-theming-setting-background @update:theming="$emit('update:theming')" /> - <div class="admin-theming__preview"> - <div class="admin-theming__preview-logo" /> + <div class="admin-theming__preview" data-admin-theming-preview> + <div class="admin-theming__preview-logo" data-admin-theming-preview-logo /> </div> </div> </NcSettingsSection> diff --git a/apps/theming/src/components/admin/FileInputField.vue b/apps/theming/src/components/admin/FileInputField.vue index ba046ec8b31..c15d1ee2c8e 100644 --- a/apps/theming/src/components/admin/FileInputField.vue +++ b/apps/theming/src/components/admin/FileInputField.vue @@ -27,7 +27,7 @@ <NcButton type="secondary" :id="id" :aria-label="ariaLabel" - data-admin-theming-setting-background-picker + data-admin-theming-setting-file-picker @click="activateLocalFilePicker"> <template #icon> <Upload :size="20" /> @@ -37,7 +37,7 @@ <NcButton v-if="showReset" type="tertiary" :aria-label="t('theming', 'Reset to default')" - data-admin-theming-setting-background-reset + data-admin-theming-setting-file-reset @click="undo"> <template #icon> <Undo :size="20" /> @@ -46,7 +46,7 @@ <NcButton v-if="showRemove" type="tertiary" :aria-label="t('theming', 'Remove background image')" - data-admin-theming-setting-background-remove + data-admin-theming-setting-file-remove @click="removeBackground"> <template #icon> <Delete :size="20" /> |