diff options
author | John Molakvoæ <skjnldsv@protonmail.com> | 2022-11-29 09:51:34 +0100 |
---|---|---|
committer | John Molakvoæ <skjnldsv@protonmail.com> | 2022-11-29 11:26:27 +0100 |
commit | a869259e411486486fb1206dfa74f5363834d92f (patch) | |
tree | 7ea353549158dc5898d917452f8b9c6970438c87 /apps | |
parent | 064fa10ecfe4725398895a21ab8bafd171e2eadd (diff) | |
download | nextcloud-server-a869259e411486486fb1206dfa74f5363834d92f.tar.gz nextcloud-server-a869259e411486486fb1206dfa74f5363834d92f.zip |
More theming cypress tests and some fixes
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/theming/lib/ImageManager.php | 2 | ||||
-rw-r--r-- | apps/theming/lib/Jobs/MigrateBackgroundImages.php | 1 | ||||
-rw-r--r-- | apps/theming/lib/Listener/BeforeTemplateRenderedListener.php | 4 | ||||
-rw-r--r-- | apps/theming/lib/Service/BackgroundService.php | 2 | ||||
-rw-r--r-- | apps/theming/lib/Themes/CommonThemeTrait.php | 7 | ||||
-rw-r--r-- | apps/theming/lib/ThemingDefaults.php | 6 | ||||
-rw-r--r-- | apps/theming/src/AdminTheming.vue | 31 | ||||
-rw-r--r-- | apps/theming/src/UserThemes.vue | 3 | ||||
-rw-r--r-- | apps/theming/src/components/BackgroundSettings.vue | 3 | ||||
-rw-r--r-- | apps/theming/src/components/admin/ColorPickerField.vue | 4 | ||||
-rw-r--r-- | apps/theming/src/components/admin/FileInputField.vue | 3 | ||||
-rw-r--r-- | apps/theming/tests/Themes/DefaultThemeTest.php | 2 | ||||
-rw-r--r-- | apps/theming/tests/ThemingDefaultsTest.php | 2 |
13 files changed, 40 insertions, 30 deletions
diff --git a/apps/theming/lib/ImageManager.php b/apps/theming/lib/ImageManager.php index d4f4353b8a8..f7b0c12844a 100644 --- a/apps/theming/lib/ImageManager.php +++ b/apps/theming/lib/ImageManager.php @@ -94,7 +94,7 @@ class ImageManager { case 'favicon': return $this->urlGenerator->imagePath('core', 'logo/logo.png') . '?v=' . $cacheBusterCounter; case 'background': - return $this->urlGenerator->linkTo(Application::APP_ID, 'img/background/' . BackgroundService::DEFAULT_BACKGROUND); + return $this->urlGenerator->linkTo(Application::APP_ID, 'img/background/' . BackgroundService::DEFAULT_BACKGROUND_IMAGE); } return ''; } diff --git a/apps/theming/lib/Jobs/MigrateBackgroundImages.php b/apps/theming/lib/Jobs/MigrateBackgroundImages.php index 4b0cf187bae..54c0d591e40 100644 --- a/apps/theming/lib/Jobs/MigrateBackgroundImages.php +++ b/apps/theming/lib/Jobs/MigrateBackgroundImages.php @@ -27,7 +27,6 @@ declare(strict_types=1); namespace OCA\Theming\Jobs; use OCA\Theming\AppInfo\Application; -use OCP\App\IAppManager; use OCP\AppFramework\Utility\ITimeFactory; use OCP\BackgroundJob\IJobList; use OCP\BackgroundJob\QueuedJob; diff --git a/apps/theming/lib/Listener/BeforeTemplateRenderedListener.php b/apps/theming/lib/Listener/BeforeTemplateRenderedListener.php index d0fa9690602..380527ee024 100644 --- a/apps/theming/lib/Listener/BeforeTemplateRenderedListener.php +++ b/apps/theming/lib/Listener/BeforeTemplateRenderedListener.php @@ -93,7 +93,7 @@ class BeforeTemplateRenderedListener implements IEventListener { /** User color */ $this->initialState->provideInitialState( 'backgroundColor', - $this->config->getUserValue($userId, Application::APP_ID, 'background_image', BackgroundService::BACKGROUND_DEFAULT), + $this->config->getUserValue($userId, Application::APP_ID, 'background_color', BackgroundService::DEFAULT_COLOR), ); /** @@ -106,7 +106,7 @@ class BeforeTemplateRenderedListener implements IEventListener { ); $this->initialState->provideInitialState( 'defaultShippedBackground', - BackgroundService::DEFAULT_BACKGROUND, + BackgroundService::DEFAULT_BACKGROUND_IMAGE, ); /** List of all shipped backgrounds */ diff --git a/apps/theming/lib/Service/BackgroundService.php b/apps/theming/lib/Service/BackgroundService.php index 002ca169a83..a3af56b08f8 100644 --- a/apps/theming/lib/Service/BackgroundService.php +++ b/apps/theming/lib/Service/BackgroundService.php @@ -53,7 +53,7 @@ class BackgroundService { public const BACKGROUND_DEFAULT = 'default'; public const BACKGROUND_DISABLED = 'disabled'; - public const DEFAULT_BACKGROUND = 'kamil-porembinski-clouds.jpg'; + public const DEFAULT_BACKGROUND_IMAGE = 'kamil-porembinski-clouds.jpg'; public const SHIPPED_BACKGROUNDS = [ 'anatoly-mikhaltsov-butterfly-wing-scale.jpg' => [ 'attribution' => 'Butterfly wing scale (Anatoly Mikhaltsov, CC BY-SA)', diff --git a/apps/theming/lib/Themes/CommonThemeTrait.php b/apps/theming/lib/Themes/CommonThemeTrait.php index 40feddd2b38..18d3fb2d814 100644 --- a/apps/theming/lib/Themes/CommonThemeTrait.php +++ b/apps/theming/lib/Themes/CommonThemeTrait.php @@ -89,16 +89,14 @@ trait CommonThemeTrait { $variables = []; // Default last fallback values - $variables['--image-background-default'] = $backgroundDeleted ?: "url('" . $this->themingDefaults->getBackground() . "')"; + $variables['--image-background-default'] = "url('" . $this->themingDefaults->getBackground() . "')"; $variables['--color-background-plain'] = $this->defaultPrimaryColor; // If primary as background has been request or if we have a custom primary colour // let's not define the background image if ($backgroundDeleted) { $variables['--color-background-plain'] = $this->themingDefaults->getColorPrimary(); - if ($this->themingDefaults->isUserThemingDisabled() || $user === null) { - $variables['--image-background-plain'] = 'yes'; - } + $variables['--image-background-plain'] = 'yes'; } // Register image variables only if custom-defined @@ -111,7 +109,6 @@ trait CommonThemeTrait { continue; } $variables['--image-background-size'] = 'cover'; - $variables['--image-background-default'] = "url('" . $imageUrl . "')"; } // --image-background is overridden by user theming $variables["--image-$image"] = "url('" . $imageUrl . "')"; diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php index 954b1be651b..881a27f9936 100644 --- a/apps/theming/lib/ThemingDefaults.php +++ b/apps/theming/lib/ThemingDefaults.php @@ -227,10 +227,10 @@ class ThemingDefaults extends \OC_Defaults { // user-defined primary color if (!empty($user)) { - $themingBackground = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'background_color', ''); + $themingBackgroundColor = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'background_color', ''); // If the user selected a specific colour - if (preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $themingBackground)) { - return $themingBackground; + if (preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $themingBackgroundColor)) { + return $themingBackgroundColor; } } diff --git a/apps/theming/src/AdminTheming.vue b/apps/theming/src/AdminTheming.vue index 4b1877ccf7d..bb26dcc0f30 100644 --- a/apps/theming/src/AdminTheming.vue +++ b/apps/theming/src/AdminTheming.vue @@ -24,36 +24,46 @@ <section> <NcSettingsSection :title="t('theming', 'Theming')" :description="t('theming', 'Theming makes it possible to easily customize the look and feel of your instance and supported clients. This will be visible for all users.')" - :doc-url="docUrl"> + :doc-url="docUrl" + data-admin-theming-settings> <div class="admin-theming"> <NcNoteCard v-if="!isThemable" type="error" :show-alert="true"> <p>{{ notThemableErrorMessage }}</p> </NcNoteCard> + + <!-- Name, web link, slogan... fields --> <TextField v-for="field in textFields" :key="field.name" - :name="field.name" - :value.sync="field.value" + :data-admin-theming-setting-field="field.name" :default-value="field.defaultValue" - :type="field.type" :display-name="field.displayName" - :placeholder="field.placeholder" :maxlength="field.maxlength" + :name="field.name" + :placeholder="field.placeholder" + :type="field.type" + :value.sync="field.value" @update:theming="$emit('update:theming')" /> + + <!-- Primary color picker --> <ColorPickerField :name="colorPickerField.name" - :value.sync="colorPickerField.value" :default-value="colorPickerField.defaultValue" :display-name="colorPickerField.displayName" + :value.sync="colorPickerField.value" + data-admin-theming-setting-primary-color @update:theming="$emit('update:theming')" /> + + <!-- Default background picker --> <FileInputField v-for="field in fileInputFields" :key="field.name" - :name="field.name" - :mime-name="field.mimeName" - :mime-value.sync="field.mimeValue" + :aria-label="field.ariaLabel" :default-mime-value="field.defaultMimeValue" :display-name="field.displayName" - :aria-label="field.ariaLabel" + :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" /> @@ -87,6 +97,7 @@ :display-name="userThemingField.displayName" :label="userThemingField.label" :description="userThemingField.description" + data-admin-theming-setting-disable-user-theming @update:theming="$emit('update:theming')" /> <a v-if="!canThemeIcons" :href="docUrlIcons" diff --git a/apps/theming/src/UserThemes.vue b/apps/theming/src/UserThemes.vue index 7220820a3c3..0f72e95d9a8 100644 --- a/apps/theming/src/UserThemes.vue +++ b/apps/theming/src/UserThemes.vue @@ -63,7 +63,8 @@ </NcSettingsSection> <NcSettingsSection :title="t('theming', 'Background')" - class="background"> + class="background" + data-user-theming-background-disabled> <template v-if="isUserThemingDisabled"> <p>{{ t('theming', 'Customization has been disabled by your administrator') }}</p> </template> diff --git a/apps/theming/src/components/BackgroundSettings.vue b/apps/theming/src/components/BackgroundSettings.vue index e1d8b731bc4..97912ae3c9c 100644 --- a/apps/theming/src/components/BackgroundSettings.vue +++ b/apps/theming/src/components/BackgroundSettings.vue @@ -99,7 +99,6 @@ import { Palette } from 'node-vibrant/lib/color' import { getFilePickerBuilder } from '@nextcloud/dialogs' import { getCurrentUser } from '@nextcloud/auth' -const backgroundColor = loadState('theming', 'backgroundColor') const backgroundImage = loadState('theming', 'backgroundImage') const shippedBackgroundList = loadState('theming', 'shippedBackgrounds') const themingDefaultBackground = loadState('theming', 'themingDefaultBackground') @@ -132,7 +131,6 @@ export default { // User background image and color settings backgroundImage, - backgroundColor, } }, @@ -210,7 +208,6 @@ export default { async update(data) { // Update state this.backgroundImage = data.backgroundImage - this.backgroundColor = data.backgroundColor this.Theming.color = data.backgroundColor // Notify parent and reload style diff --git a/apps/theming/src/components/admin/ColorPickerField.vue b/apps/theming/src/components/admin/ColorPickerField.vue index 2e6ee99a75d..c9f1a8e4ef5 100644 --- a/apps/theming/src/components/admin/ColorPickerField.vue +++ b/apps/theming/src/components/admin/ColorPickerField.vue @@ -30,13 +30,15 @@ <NcButton class="field__button" type="primary" :id="id" - :aria-label="t('theming', 'Select a custom color')"> + :aria-label="t('theming', 'Select a custom color')" + data-admin-theming-setting-primary-color-picker> {{ value }} </NcButton> </NcColorPicker> <NcButton v-if="value !== defaultValue" type="tertiary" :aria-label="t('theming', 'Reset to default')" + data-admin-theming-setting-primary-color-reset @click="undo"> <template #icon> <Undo :size="20" /> diff --git a/apps/theming/src/components/admin/FileInputField.vue b/apps/theming/src/components/admin/FileInputField.vue index 537970cc0cc..ba046ec8b31 100644 --- a/apps/theming/src/components/admin/FileInputField.vue +++ b/apps/theming/src/components/admin/FileInputField.vue @@ -27,6 +27,7 @@ <NcButton type="secondary" :id="id" :aria-label="ariaLabel" + data-admin-theming-setting-background-picker @click="activateLocalFilePicker"> <template #icon> <Upload :size="20" /> @@ -36,6 +37,7 @@ <NcButton v-if="showReset" type="tertiary" :aria-label="t('theming', 'Reset to default')" + data-admin-theming-setting-background-reset @click="undo"> <template #icon> <Undo :size="20" /> @@ -44,6 +46,7 @@ <NcButton v-if="showRemove" type="tertiary" :aria-label="t('theming', 'Remove background image')" + data-admin-theming-setting-background-remove @click="removeBackground"> <template #icon> <Delete :size="20" /> diff --git a/apps/theming/tests/Themes/DefaultThemeTest.php b/apps/theming/tests/Themes/DefaultThemeTest.php index 2a62211f268..6044f5c10d3 100644 --- a/apps/theming/tests/Themes/DefaultThemeTest.php +++ b/apps/theming/tests/Themes/DefaultThemeTest.php @@ -85,7 +85,7 @@ class DefaultThemeTest extends TestCase { $this->themingDefaults ->expects($this->any()) ->method('getBackground') - ->willReturn('/apps/' . Application::APP_ID . '/img/background/' . BackgroundService::DEFAULT_BACKGROUND); + ->willReturn('/apps/' . Application::APP_ID . '/img/background/' . BackgroundService::DEFAULT_BACKGROUND_IMAGE); $this->l10n ->expects($this->any()) diff --git a/apps/theming/tests/ThemingDefaultsTest.php b/apps/theming/tests/ThemingDefaultsTest.php index 04fce553c33..cf6b6492c11 100644 --- a/apps/theming/tests/ThemingDefaultsTest.php +++ b/apps/theming/tests/ThemingDefaultsTest.php @@ -464,7 +464,7 @@ class ThemingDefaultsTest extends TestCase { $this->config ->expects($this->once()) ->method('getUserValue') - ->with('user', 'theming', 'background') + ->with('user', 'theming', 'background_color') ->willReturn(''); $this->assertEquals(BackgroundService::DEFAULT_COLOR, $this->template->getColorPrimary()); |