Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2022-08-16 11:12:53 +0300
committerGitHub <noreply@github.com>2022-08-16 11:12:53 +0300
commit3e2ab35af5aa14ed77fba66b63b9d858a5607394 (patch)
tree97f5d619cb57261ad623bf7f60a71eb287fc8f0a
parente6feca6d1559efaaf5ba31d5c24c4a436c0ccf5f (diff)
parent5f3229ed6746825cd50710644ee40e984ca4f049 (diff)
Merge pull request #33556 from nextcloud/fix/theming
-rw-r--r--apps/theming/css/default.css6
-rw-r--r--apps/theming/lib/Themes/DefaultTheme.php25
-rw-r--r--apps/theming/tests/ImageManagerTest.php2
-rw-r--r--apps/theming/tests/Themes/DefaultThemeTest.php19
4 files changed, 19 insertions, 33 deletions
diff --git a/apps/theming/css/default.css b/apps/theming/css/default.css
index bf7ad0f89cc..fb541b7aca9 100644
--- a/apps/theming/css/default.css
+++ b/apps/theming/css/default.css
@@ -59,10 +59,4 @@
--primary-invert-if-bright: no;
--background-invert-if-dark: no;
--background-invert-if-bright: invert(100%);
- --image-logo: url('/core/img/logo/logo.png?v=0');
- --image-logoheader: url('/core/img/logo/logo.png?v=0');
- --image-favicon: url('/core/img/logo/logo.png?v=0');
- --image-background-size: cover;
- --image-background: url('/core/img/background.png?v=0');
- --image-login-background: url('/core/img/background.png?v=0');
}
diff --git a/apps/theming/lib/Themes/DefaultTheme.php b/apps/theming/lib/Themes/DefaultTheme.php
index d327b7db6d4..d141a5d3241 100644
--- a/apps/theming/lib/Themes/DefaultTheme.php
+++ b/apps/theming/lib/Themes/DefaultTheme.php
@@ -91,6 +91,7 @@ class DefaultTheme implements ITheme {
$colorPrimaryLight = $this->util->mix($this->primaryColor, $colorMainBackground, -80);
$hasCustomLogoHeader = $this->imageManager->hasImage('logo') || $this->imageManager->hasImage('logoheader');
+ $hasCustomPrimaryColour = !empty($this->config->getAppValue('theming', 'color'));
$variables = [
'--color-main-background' => $colorMainBackground,
@@ -192,17 +193,25 @@ class DefaultTheme implements ITheme {
];
$backgroundDeleted = $this->config->getAppValue('theming', 'backgroundMime', '') === 'backgroundColor';
+ // If primary as background has been request or if we have a custom primary colour
+ // let's not define the background image
+ if ($backgroundDeleted || $hasCustomPrimaryColour) {
+ $variables["--image-background-plain"] = 'true';
+ }
+
+ // Register image variables only if custom-defined
foreach(['logo', 'logoheader', 'favicon', 'background'] as $image) {
- // If primary as background has been request, let's not define the background image
- if ($image === 'background' && $backgroundDeleted) {
- $variables["--image-background-plain"] = 'true';
- continue;
- } else if ($image === 'background') {
- $variables['--image-background-size'] = 'cover';
+ if ($this->imageManager->hasImage($image)) {
+ if ($image === 'background') {
+ // If background deleted is set, ignoring variable
+ if ($backgroundDeleted) {
+ continue;
+ }
+ $variables['--image-background-size'] = 'cover';
+ }
+ $variables["--image-$image"] = "url('".$this->imageManager->getImageUrl($image)."')";
}
- $variables["--image-$image"] = "url('".$this->imageManager->getImageUrl($image)."')";
}
- $variables["--image-login-background"] = $variables["--image-background"];
if ($hasCustomLogoHeader) {
$variables["--image-logoheader-custom"] = 'true';
diff --git a/apps/theming/tests/ImageManagerTest.php b/apps/theming/tests/ImageManagerTest.php
index 0f22a774a39..ead9ca113e6 100644
--- a/apps/theming/tests/ImageManagerTest.php
+++ b/apps/theming/tests/ImageManagerTest.php
@@ -307,7 +307,7 @@ class ImageManagerTest extends TestCase {
foreach ($folders as $index => $folder) {
$folder->expects($this->any())
->method('getName')
- ->willReturn((string)$index);
+ ->willReturn("$index");
}
$folders[0]->expects($this->once())->method('delete');
$folders[1]->expects($this->once())->method('delete');
diff --git a/apps/theming/tests/Themes/DefaultThemeTest.php b/apps/theming/tests/Themes/DefaultThemeTest.php
index 5086c5da8ee..160efdba142 100644
--- a/apps/theming/tests/Themes/DefaultThemeTest.php
+++ b/apps/theming/tests/Themes/DefaultThemeTest.php
@@ -20,7 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-namespace OCA\Theming\Tests;
+namespace OCA\Theming\Tests\Service;
use OC\App\AppManager;
use OCA\Theming\ImageManager;
@@ -68,23 +68,6 @@ class DefaultThemeTest extends TestCase {
->method('getColorPrimary')
->willReturn('#0082c9');
- $this->imageManager->expects($this->any())
- ->method('getImageUrl')
- ->willReturnCallback(function (string $name): string {
- switch ($name) {
- case 'logo':
- case 'logoheader':
- case 'favicon':
- return '/core/img/logo/logo.png?v=0';
- case 'background':
- case 'login-background':
- return '/core/img/background.png?v=0';
- default:
- return '';
- }
- });
-
-
$this->l10n
->expects($this->any())
->method('t')