aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRichard Steinmetz <richard@steinmetz.cloud>2024-07-13 16:51:16 +0200
committerRichard Steinmetz <richard@steinmetz.cloud>2024-07-16 09:18:33 +0200
commite42bceac9fc5845ad3614d3254bbb270e0d9d847 (patch)
tree53062f9f3ee11966417266a241c0f2800514c7ad /apps
parent70dd8d513bf73c8d56fea2aae4a02718a328f6e3 (diff)
downloadnextcloud-server-e42bceac9fc5845ad3614d3254bbb270e0d9d847.tar.gz
nextcloud-server-e42bceac9fc5845ad3614d3254bbb270e0d9d847.zip
feat: hide caldav server settings if no app uses the caldav backend
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
Diffstat (limited to 'apps')
-rw-r--r--apps/dav/lib/Settings/CalDAVSettings.php14
-rw-r--r--apps/dav/tests/unit/Settings/CalDAVSettingsTest.php20
2 files changed, 28 insertions, 6 deletions
diff --git a/apps/dav/lib/Settings/CalDAVSettings.php b/apps/dav/lib/Settings/CalDAVSettings.php
index 75bb70c530a..7c738a83148 100644
--- a/apps/dav/lib/Settings/CalDAVSettings.php
+++ b/apps/dav/lib/Settings/CalDAVSettings.php
@@ -6,6 +6,7 @@
namespace OCA\DAV\Settings;
use OCA\DAV\AppInfo\Application;
+use OCP\App\IAppManager;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Services\IInitialState;
use OCP\IConfig;
@@ -21,6 +22,7 @@ class CalDAVSettings implements IDelegatedSettings {
private $initialState;
private IURLGenerator $urlGenerator;
+ private IAppManager $appManager;
private const defaults = [
'sendInvitations' => 'yes',
@@ -36,10 +38,11 @@ class CalDAVSettings implements IDelegatedSettings {
* @param IConfig $config
* @param IInitialState $initialState
*/
- public function __construct(IConfig $config, IInitialState $initialState, IURLGenerator $urlGenerator) {
+ public function __construct(IConfig $config, IInitialState $initialState, IURLGenerator $urlGenerator, IAppManager $appManager) {
$this->config = $config;
$this->initialState = $initialState;
$this->urlGenerator = $urlGenerator;
+ $this->appManager = $appManager;
}
public function getForm(): TemplateResponse {
@@ -51,10 +54,11 @@ class CalDAVSettings implements IDelegatedSettings {
return new TemplateResponse(Application::APP_ID, 'settings-admin-caldav');
}
- /**
- * @return string
- */
- public function getSection() {
+ public function getSection(): ?string {
+ if (!$this->appManager->isBackendRequired(IAppManager::BACKEND_CALDAV)) {
+ return null;
+ }
+
return 'groupware';
}
diff --git a/apps/dav/tests/unit/Settings/CalDAVSettingsTest.php b/apps/dav/tests/unit/Settings/CalDAVSettingsTest.php
index 46a8db6f3eb..ed497d006e1 100644
--- a/apps/dav/tests/unit/Settings/CalDAVSettingsTest.php
+++ b/apps/dav/tests/unit/Settings/CalDAVSettingsTest.php
@@ -6,6 +6,7 @@
namespace OCA\DAV\Tests\Unit\DAV\Settings;
use OCA\DAV\Settings\CalDAVSettings;
+use OCP\App\IAppManager;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Services\IInitialState;
use OCP\IConfig;
@@ -24,6 +25,9 @@ class CalDAVSettingsTest extends TestCase {
/** @var IURLGenerator|MockObject */
private $urlGenerator;
+ /** @var IAppManager|MockObject */
+ private $appManager;
+
private CalDAVSettings $settings;
protected function setUp(): void {
@@ -32,7 +36,8 @@ class CalDAVSettingsTest extends TestCase {
$this->config = $this->createMock(IConfig::class);
$this->initialState = $this->createMock(IInitialState::class);
$this->urlGenerator = $this->createMock(IURLGenerator::class);
- $this->settings = new CalDAVSettings($this->config, $this->initialState, $this->urlGenerator);
+ $this->appManager = $this->createMock(IAppManager::class);
+ $this->settings = new CalDAVSettings($this->config, $this->initialState, $this->urlGenerator, $this->appManager);
}
public function testGetForm(): void {
@@ -65,10 +70,23 @@ class CalDAVSettingsTest extends TestCase {
}
public function testGetSection(): void {
+ $this->appManager->expects(self::once())
+ ->method('isBackendRequired')
+ ->with(IAppManager::BACKEND_CALDAV)
+ ->willReturn(true);
$this->assertEquals('groupware', $this->settings->getSection());
}
+ public function testGetSectionWithoutCaldavBackend(): void {
+ $this->appManager->expects(self::once())
+ ->method('isBackendRequired')
+ ->with(IAppManager::BACKEND_CALDAV)
+ ->willReturn(false);
+ $this->assertEquals(null, $this->settings->getSection());
+ }
+
public function testGetPriority(): void {
$this->assertEquals(10, $this->settings->getPriority());
}
+
}