summaryrefslogtreecommitdiffstats
path: root/apps/theming/lib
diff options
context:
space:
mode:
authorChristopher Ng <chrng8@gmail.com>2022-10-01 03:04:39 +0000
committerChristopher Ng <chrng8@gmail.com>2022-10-28 00:18:47 +0000
commit4a2bbc7af9249364ba2455f627522450262cad75 (patch)
treeb0fd373e0aad0f18c35d2272c565b20bdab630a9 /apps/theming/lib
parentd007088cf5d89e29065991e0cbe2c890dfa13d96 (diff)
downloadnextcloud-server-4a2bbc7af9249364ba2455f627522450262cad75.tar.gz
nextcloud-server-4a2bbc7af9249364ba2455f627522450262cad75.zip
Rewrite admin theming in Vue
Signed-off-by: Christopher Ng <chrng8@gmail.com>
Diffstat (limited to 'apps/theming/lib')
-rw-r--r--apps/theming/lib/ImageManager.php15
-rw-r--r--apps/theming/lib/Settings/Admin.php31
-rw-r--r--apps/theming/lib/Settings/Personal.php3
-rw-r--r--apps/theming/lib/Themes/CommonThemeTrait.php11
-rw-r--r--apps/theming/lib/Themes/DefaultTheme.php1
-rw-r--r--apps/theming/lib/ThemingDefaults.php2
6 files changed, 34 insertions, 29 deletions
diff --git a/apps/theming/lib/ImageManager.php b/apps/theming/lib/ImageManager.php
index 560a4c981fe..88a733580fc 100644
--- a/apps/theming/lib/ImageManager.php
+++ b/apps/theming/lib/ImageManager.php
@@ -53,7 +53,6 @@ class ImageManager {
private $appData;
/** @var IURLGenerator */
private $urlGenerator;
- /** @var array */
/** @var ICacheFactory */
private $cacheFactory;
/** @var ILogger */
@@ -138,20 +137,6 @@ class ImageManager {
}
/**
- * @return array<string, array{mime: string, url: string}>
- */
- public function getCustomImages(): array {
- $images = [];
- foreach ($this::SupportedImageKeys as $key) {
- $images[$key] = [
- 'mime' => $this->config->getAppValue('theming', $key . 'Mime', ''),
- 'url' => $this->getImageUrl($key),
- ];
- }
- return $images;
- }
-
- /**
* Get folder for current theming files
*
* @return ISimpleFolder
diff --git a/apps/theming/lib/Settings/Admin.php b/apps/theming/lib/Settings/Admin.php
index 4576bea1df4..0f0d85c147d 100644
--- a/apps/theming/lib/Settings/Admin.php
+++ b/apps/theming/lib/Settings/Admin.php
@@ -27,19 +27,23 @@
*/
namespace OCA\Theming\Settings;
+use OCA\Theming\AppInfo\Application;
use OCA\Theming\ImageManager;
use OCA\Theming\ThemingDefaults;
use OCP\AppFramework\Http\TemplateResponse;
+use OCP\AppFramework\Services\IInitialState;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\Settings\IDelegatedSettings;
+use OCP\Util;
class Admin implements IDelegatedSettings {
private string $appName;
private IConfig $config;
private IL10N $l;
private ThemingDefaults $themingDefaults;
+ private IInitialState $initialState;
private IURLGenerator $urlGenerator;
private ImageManager $imageManager;
@@ -47,12 +51,14 @@ class Admin implements IDelegatedSettings {
IConfig $config,
IL10N $l,
ThemingDefaults $themingDefaults,
+ IInitialState $initialState,
IURLGenerator $urlGenerator,
ImageManager $imageManager) {
$this->appName = $appName;
$this->config = $config;
$this->l = $l;
$this->themingDefaults = $themingDefaults;
+ $this->initialState = $initialState;
$this->urlGenerator = $urlGenerator;
$this->imageManager = $imageManager;
}
@@ -69,23 +75,28 @@ class Admin implements IDelegatedSettings {
$errorMessage = $this->l->t('You are already using a custom theme. Theming app settings might be overwritten by that.');
}
- $parameters = [
- 'themable' => $themable,
- 'errorMessage' => $errorMessage,
+ $this->initialState->provideInitialState('adminThemingParameters', [
+ 'isThemable' => $themable,
+ 'notThemableErrorMessage' => $errorMessage,
'name' => $this->themingDefaults->getEntity(),
'url' => $this->themingDefaults->getBaseUrl(),
'slogan' => $this->themingDefaults->getSlogan(),
'color' => $this->themingDefaults->getDefaultColorPrimary(),
- 'uploadLogoRoute' => $this->urlGenerator->linkToRoute('theming.Theming.uploadImage'),
+ 'logoMime' => $this->config->getAppValue(Application::APP_ID, 'logoMime', ''),
+ 'backgroundMime' => $this->config->getAppValue(Application::APP_ID, 'backgroundMime', ''),
+ 'logoheaderMime' => $this->config->getAppValue(Application::APP_ID, 'logoheaderMime', ''),
+ 'faviconMime' => $this->config->getAppValue(Application::APP_ID, 'faviconMime', ''),
+ 'legalNoticeUrl' => $this->themingDefaults->getImprintUrl(),
+ 'privacyPolicyUrl' => $this->themingDefaults->getPrivacyUrl(),
+ 'docUrl' => $this->urlGenerator->linkToDocs('admin-theming'),
+ 'docUrlIcons' => $this->urlGenerator->linkToDocs('admin-theming-icons'),
'canThemeIcons' => $this->imageManager->shouldReplaceIcons(),
- 'iconDocs' => $this->urlGenerator->linkToDocs('admin-theming-icons'),
- 'images' => $this->imageManager->getCustomImages(),
- 'imprintUrl' => $this->themingDefaults->getImprintUrl(),
- 'privacyUrl' => $this->themingDefaults->getPrivacyUrl(),
'userThemingDisabled' => $this->themingDefaults->isUserThemingDisabled(),
- ];
+ ]);
+
+ Util::addScript($this->appName, 'admin-theming');
- return new TemplateResponse($this->appName, 'settings-admin', $parameters, '');
+ return new TemplateResponse($this->appName, 'settings-admin');
}
/**
diff --git a/apps/theming/lib/Settings/Personal.php b/apps/theming/lib/Settings/Personal.php
index 7ba4da15191..5b0dc742574 100644
--- a/apps/theming/lib/Settings/Personal.php
+++ b/apps/theming/lib/Settings/Personal.php
@@ -77,7 +77,8 @@ class Personal implements ISettings {
$this->initialStateService->provideInitialState('themes', array_values($themes));
$this->initialStateService->provideInitialState('enforceTheme', $enforcedTheme);
$this->initialStateService->provideInitialState('isUserThemingDisabled', $this->themingDefaults->isUserThemingDisabled());
- Util::addScript($this->appName, 'theming-settings');
+
+ Util::addScript($this->appName, 'personal-theming');
return new TemplateResponse($this->appName, 'settings-personal');
}
diff --git a/apps/theming/lib/Themes/CommonThemeTrait.php b/apps/theming/lib/Themes/CommonThemeTrait.php
index c203b35ed44..620c40199db 100644
--- a/apps/theming/lib/Themes/CommonThemeTrait.php
+++ b/apps/theming/lib/Themes/CommonThemeTrait.php
@@ -40,6 +40,7 @@ trait CommonThemeTrait {
protected function generatePrimaryVariables(string $colorMainBackground, string $colorMainText): array {
$colorPrimaryLight = $this->util->mix($this->primaryColor, $colorMainBackground, -80);
$colorPrimaryElement = $this->util->elementColor($this->primaryColor);
+ $colorPrimaryElementDefault = $this->util->elementColor($this->defaultPrimaryColor);
$colorPrimaryElementLight = $this->util->mix($colorPrimaryElement, $colorMainBackground, -80);
// primary related colours
@@ -64,6 +65,7 @@ trait CommonThemeTrait {
// used for buttons, inputs...
'--color-primary-element' => $colorPrimaryElement,
+ '--color-primary-element-default-hover' => $this->util->mix($colorPrimaryElementDefault, $colorMainBackground, 60),
'--color-primary-element-text' => $this->util->invertTextColor($colorPrimaryElement) ? '#000000' : '#ffffff',
'--color-primary-element-hover' => $this->util->mix($colorPrimaryElement, $colorMainBackground, 60),
'--color-primary-element-light' => $colorPrimaryElementLight,
@@ -80,6 +82,7 @@ trait CommonThemeTrait {
* Generate admin theming background-related variables
*/
protected function generateGlobalBackgroundVariables(): array {
+ $user = $this->userSession->getUser();
$backgroundDeleted = $this->config->getAppValue(Application::APP_ID, 'backgroundMime', '') === 'backgroundColor';
$hasCustomLogoHeader = $this->imageManager->hasImage('logo') || $this->imageManager->hasImage('logoheader');
@@ -87,9 +90,11 @@ trait CommonThemeTrait {
// If primary as background has been request or if we have a custom primary colour
// let's not define the background image
- if ($backgroundDeleted && $this->themingDefaults->isUserThemingDisabled()) {
- $variables['--image-background-plain'] = 'true';
+ if ($backgroundDeleted) {
$variables['--color-background-plain'] = $this->themingDefaults->getColorPrimary();
+ if ($this->themingDefaults->isUserThemingDisabled() || $user === null) {
+ $variables['--image-background-plain'] = 'true';
+ }
}
// Register image variables only if custom-defined
@@ -99,9 +104,11 @@ trait CommonThemeTrait {
if ($image === 'background') {
// If background deleted is set, ignoring variable
if ($backgroundDeleted) {
+ $variables['--image-background-default'] = 'no';
continue;
}
$variables['--image-background-size'] = 'cover';
+ $variables['--image-background-default'] = "url('" . $imageUrl . "')";
}
$variables["--image-$image"] = "url('" . $imageUrl . "')";
}
diff --git a/apps/theming/lib/Themes/DefaultTheme.php b/apps/theming/lib/Themes/DefaultTheme.php
index bb24bb4566b..94b71eb9d12 100644
--- a/apps/theming/lib/Themes/DefaultTheme.php
+++ b/apps/theming/lib/Themes/DefaultTheme.php
@@ -193,6 +193,7 @@ class DefaultTheme implements ITheme {
// Default last fallback values
'--image-background' => "url('" . $this->urlGenerator->imagePath('core', 'app-background.jpg') . "')",
+ '--image-background-default' => "url('" . $this->urlGenerator->imagePath('core', 'app-background.jpg') . "')",
'--color-background-plain' => $this->defaultPrimaryColor,
];
diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php
index eee44e81fda..f32faa5a8ef 100644
--- a/apps/theming/lib/ThemingDefaults.php
+++ b/apps/theming/lib/ThemingDefaults.php
@@ -224,7 +224,7 @@ class ThemingDefaults extends \OC_Defaults {
if ($this->isUserThemingDisabled()) {
return $defaultColor;
}
-
+
// user-defined primary color
$themingBackground = '';
if (!empty($user)) {