Skip to content

Commit

Permalink
Merge pull request #4107 from nextcloud/backport/4104/stable29
Browse files Browse the repository at this point in the history
[stable29] fix: display proper custom logo in collabora
  • Loading branch information
elzody authored Oct 11, 2024
2 parents be2dc70 + 31ddfd7 commit 4d49c14
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
13 changes: 8 additions & 5 deletions lib/Service/InitialStateService.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use OCA\Richdocuments\AppConfig;
use OCA\Richdocuments\AppInfo\Application;
use OCA\Richdocuments\Db\Wopi;
use OCA\Theming\ImageManager;
use OCP\AppFramework\Services\IInitialState;
use OCP\Defaults;
use OCP\IConfig;
Expand All @@ -39,6 +40,7 @@ class InitialStateService {
public function __construct(
private IInitialState $initialState,
private AppConfig $appConfig,
private ImageManager $imageManager,
private CapabilitiesService $capabilitiesService,
private IURLGenerator $urlGenerator,
private Defaults $themingDefaults,
Expand Down Expand Up @@ -101,15 +103,16 @@ private function provideOptions(): void {
'UIMode' => $this->config->getAppValue(Application::APPNAME, 'uiDefaults-UIMode', 'notebookbar')
]);

$logoSet = $this->config->getAppValue('theming', 'logoheaderMime', '') !== '';
$logoType = 'logoheader';
$logoSet = $this->imageManager->hasImage($logoType);
if (!$logoSet) {
$logoSet = $this->config->getAppValue('theming', 'logoMime', '') !== '';
$logoType = 'logo';
$logoSet = $this->imageManager->hasImage($logoType);
}

$this->initialState->provideInitialState('theming-customLogo', ($logoSet ?
$this->urlGenerator->getAbsoluteURL($this->themingDefaults->getLogo())
: false));
$logo = $logoSet ? $this->imageManager->getImageUrlAbsolute($logoType) : false;

$this->initialState->provideInitialState('theming-customLogo', $logo);
$this->initialState->provideInitialState('open_local_editor', $this->config->getAppValue(Application::APPNAME, 'open_local_editor', 'yes') === 'yes');
}
}
3 changes: 2 additions & 1 deletion src/helpers/coolParameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,10 @@ const generateCSSVarTokens = () => {
// cleanup theme elements after extracting property values
lightElement.remove()
darkElement.remove()

const customLogo = loadState('richdocuments', 'theming-customLogo', false)
if (customLogo) {
str += `--nc-custom-logo=${window.OCA?.Theming?.cacheBuster ?? 0};`
str += `--nc-custom-logo=${encodeURIComponent(customLogo)};`
}

const rootEl = document.querySelector(':root')
Expand Down
29 changes: 29 additions & 0 deletions tests/stub.phpstub
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,35 @@ namespace OCA\Files_Sharing\Event {
}
}

namespace OCA\Theming {
use OCA\Theming\Service\BackgroundService;
use OCA\Files\IAppData;
use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\ITempManager;
use OCP\IURLGenerator;
use PSR\Log\LoggerInterface;

class ImageManager {
public function __construct(
IConfig $config,
IAppData $appData,
IURLGenerator $urlGenerator,
ICacheFactory $cacheFactory,
LoggerInterface $logger,
ITempManager $tempManager,
BackgroundService $backgroundService
) {
}

public function hasImage(string $key): bool {
}

public function getImageUrlAbsolute(string $key): string {
}
}
}

class OC_Helper {
public static function getFileTemplateManager() {
}
Expand Down

0 comments on commit 4d49c14

Please sign in to comment.