diff --git a/docs/app_settings.md b/docs/app_settings.md index 699effde41..9d9cc3e523 100644 --- a/docs/app_settings.md +++ b/docs/app_settings.md @@ -25,8 +25,26 @@ token. These credentials then can be used by the 3rd party application to make c ### Canonical webroot Canonical webroot, in case there are multiple, for Collabora Online to use. Provide the one with least restrictions. E.g.: Use non-shibbolized webroot if this instance is accessed by both shibbolized and non-shibbolized webroots. You can ignore this setting if only one webroot is used to access this instance. +### Previews + +By default Nextcloud will generate previews of Office files using the Collabora file conversion endpoint. This can be turned off through + + occ config:app:set richdocuments preview_generation --type boolean --lazy --value true + ### Electronic signature From a shell running in the Nextcloud root directory, run the following `occ` command to configure a non-default base URL for eID Easy. For example: - ./occ config:app:set --value https://test.eideasy.com richdocuments esignature_base_url + occ config:app:set richdocuments esignature_base_url --type string --value https://test.eideasy.com + +### UI mode + +Switching between classic and tabbed view is possible as a default, however users can still change this while using Office: + + occ config:app:set richdocuments uiDefaults-UIMode --type string --value classic + +### Disable local editing + +In case no desktop client is used on an instance you may disable the local editing button within office with: + + occ config:app:set richdocuments open_local_editor --type string --value no diff --git a/lib/AppConfig.php b/lib/AppConfig.php index ce05280730..69dbd864ed 100644 --- a/lib/AppConfig.php +++ b/lib/AppConfig.php @@ -8,6 +8,7 @@ use OCA\Richdocuments\AppInfo\Application; use OCA\Richdocuments\Service\FederationService; use OCP\App\IAppManager; +use OCP\AppFramework\Services\IAppConfig; use OCP\GlobalScale\IConfig as GlobalScaleConfig; use OCP\IConfig; @@ -55,6 +56,7 @@ class AppConfig { public function __construct( private IConfig $config, + private IAppConfig $appConfig, private IAppManager $appManager, private GlobalScaleConfig $globalScaleConfig, ) { @@ -232,6 +234,10 @@ private function getFederationDomains(): array { return array_map(fn ($url) => $this->domainOnly($url), array_merge($trustedNextcloudDomains, $trustedCollaboraDomains)); } + public function isPreviewGenerationEnabled(): bool { + return $this->appConfig->getAppValueBool('preview_generation', true); + } + private function getGSDomains(): array { if (!$this->globalScaleConfig->isGlobalScaleEnabled()) { return []; diff --git a/lib/Preview/Office.php b/lib/Preview/Office.php index 8b8caa8390..b93536836b 100644 --- a/lib/Preview/Office.php +++ b/lib/Preview/Office.php @@ -5,6 +5,7 @@ */ namespace OCA\Richdocuments\Preview; +use OCA\Richdocuments\AppConfig; use OCA\Richdocuments\Capabilities; use OCA\Richdocuments\Service\RemoteService; use OCP\Files\File; @@ -20,6 +21,7 @@ abstract class Office implements IProviderV2 { public function __construct( private RemoteService $remoteService, private LoggerInterface $logger, + private AppConfig $appConfig, Capabilities $capabilities, ) { $this->capabilities = $capabilities->getCapabilities()['richdocuments'] ?? []; @@ -27,7 +29,7 @@ public function __construct( public function isAvailable(FileInfo $file): bool { if (isset($this->capabilities['collabora']['convert-to']['available'])) { - return (bool)$this->capabilities['collabora']['convert-to']['available']; + return (bool)$this->capabilities['collabora']['convert-to']['available'] && $this->appConfig->isPreviewGenerationEnabled(); } return false; } diff --git a/tests/lib/AppConfigTest.php b/tests/lib/AppConfigTest.php index 1f9296427f..d9bea5d9b5 100644 --- a/tests/lib/AppConfigTest.php +++ b/tests/lib/AppConfigTest.php @@ -8,6 +8,8 @@ use OCA\Richdocuments\AppConfig; use OCP\App\IAppManager; +use OCP\AppFramework\Services\IAppConfig; +use OCP\GlobalScale\IConfig as IGlobalScaleConfig; use OCP\IConfig; use PHPUnit\Framework\MockObject\MockObject; use Test\TestCase; @@ -15,15 +17,17 @@ class AppConfigTest extends TestCase { /** @var IConfig|MockObject */ private $config; - /** @var AppConfig */ + /** @var IAppConfig */ private $appConfig; public function setUp(): void { parent::setUp(); $this->config = $this->createMock(IConfig::class); $this->appManager = $this->createMock(IAppManager::class); + $this->appConfig = $this->createMock(IAppConfig::class); + $this->gsConfig = $this->createMock(IGlobalScaleConfig::class); - $this->appConfig = new AppConfig($this->config, $this->appManager, $this->createMock(\OCP\GlobalScale\IConfig::class)); + $this->appConfig = new AppConfig($this->config, $this->appConfig, $this->appManager, $this->gsConfig); } public function testGetAppValueArrayWithValues() { diff --git a/tests/lib/Listener/AddContentSecurityPolicyListenerTest.php b/tests/lib/Listener/AddContentSecurityPolicyListenerTest.php index 67577ef83f..0de81b8a54 100644 --- a/tests/lib/Listener/AddContentSecurityPolicyListenerTest.php +++ b/tests/lib/Listener/AddContentSecurityPolicyListenerTest.php @@ -13,6 +13,7 @@ use OCP\App\IAppManager; use OCP\AppFramework\Http\ContentSecurityPolicy; use OCP\AppFramework\Http\EmptyContentSecurityPolicy; +use OCP\AppFramework\Services\IAppConfig; use OCP\EventDispatcher\IEventDispatcher; use OCP\GlobalScale\IConfig as GlobalScaleConfig; use OCP\IConfig; @@ -54,6 +55,7 @@ public function setUp(): void { $this->config = $this->getMockBuilder(AppConfig::class) ->setConstructorArgs([ $this->createMock(IConfig::class), + $this->createMock(IAppConfig::class), $this->appManager, $this->gsConfig, ])