Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: display proper custom logo in collabora #4104

Merged
merged 2 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading