Skip to content

Commit

Permalink
Merge pull request #4108 from nextcloud/backport/4104/stable30
Browse files Browse the repository at this point in the history
[stable30] fix: display proper custom logo in collabora
  • Loading branch information
elzody authored Oct 11, 2024
2 parents 1eb2e56 + 6c6efcc commit 36767b9
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 @@ -11,6 +11,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 @@ -22,6 +23,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 @@ -84,15 +86,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 @@ -145,9 +145,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 @@ -82,6 +82,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 36767b9

Please sign in to comment.