aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2022-03-18 17:40:36 +0100
committernextcloud-command <nextcloud-command@users.noreply.github.com>2022-03-18 16:52:30 +0000
commit9c07e47c78781a66587313e0c70d5c37cfe81703 (patch)
treed60ee14bb8aa80284bf45d3b42a69d92f5ad8c0d /apps
parentb0fbcccfe66474d79586001ce9509d346919ae74 (diff)
downloadnextcloud-server-9c07e47c78781a66587313e0c70d5c37cfe81703.tar.gz
nextcloud-server-9c07e47c78781a66587313e0c70d5c37cfe81703.zip
Fix link to calendar user docs in groupware settings
Closes #31617 Signed-off-by: Thomas Citharel <tcit@tcit.fr> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/dav/lib/Settings/CalDAVSettings.php7
-rw-r--r--apps/dav/src/views/CalDavSettings.spec.js5
-rw-r--r--apps/dav/src/views/CalDavSettings.vue5
-rw-r--r--apps/dav/src/views/__snapshots__/CalDavSettings.spec.js.snap2
-rw-r--r--apps/dav/tests/unit/Settings/CalDAVSettingsTest.php23
5 files changed, 34 insertions, 8 deletions
diff --git a/apps/dav/lib/Settings/CalDAVSettings.php b/apps/dav/lib/Settings/CalDAVSettings.php
index fb541e1574f..6e8ab6758e8 100644
--- a/apps/dav/lib/Settings/CalDAVSettings.php
+++ b/apps/dav/lib/Settings/CalDAVSettings.php
@@ -29,6 +29,7 @@ use OCA\DAV\AppInfo\Application;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\AppFramework\Services\IInitialState;
+use OCP\IURLGenerator;
use OCP\Settings\IDelegatedSettings;
class CalDAVSettings implements IDelegatedSettings {
@@ -39,6 +40,8 @@ class CalDAVSettings implements IDelegatedSettings {
/** @var IInitialState */
private $initialState;
+ private IURLGenerator $urlGenerator;
+
private const defaults = [
'sendInvitations' => 'yes',
'generateBirthdayCalendar' => 'yes',
@@ -52,12 +55,14 @@ class CalDAVSettings implements IDelegatedSettings {
* @param IConfig $config
* @param IInitialState $initialState
*/
- public function __construct(IConfig $config, IInitialState $initialState) {
+ public function __construct(IConfig $config, IInitialState $initialState, IURLGenerator $urlGenerator) {
$this->config = $config;
$this->initialState = $initialState;
+ $this->urlGenerator = $urlGenerator;
}
public function getForm(): TemplateResponse {
+ $this->initialState->provideInitialState('userSyncCalendarsDocUrl', $this->urlGenerator->linkToDocs('user-sync-calendars'));
foreach (self::defaults as $key => $default) {
$value = $this->config->getAppValue(Application::APP_ID, $key, $default);
$this->initialState->provideInitialState($key, $value === 'yes');
diff --git a/apps/dav/src/views/CalDavSettings.spec.js b/apps/dav/src/views/CalDavSettings.spec.js
index 0dc4c44537a..951a2802182 100644
--- a/apps/dav/src/views/CalDavSettings.spec.js
+++ b/apps/dav/src/views/CalDavSettings.spec.js
@@ -13,6 +13,11 @@ jest.mock('@nextcloud/router', () => {
},
}
})
+jest.mock('@nextcloud/initial-state', () => {
+ return {
+ loadState: jest.fn(() => 'https://docs.nextcloud.com/server/23/go.php?to=user-sync-calendars'),
+ }
+})
describe('CalDavSettings', () => {
const originalOC = global.OC
diff --git a/apps/dav/src/views/CalDavSettings.vue b/apps/dav/src/views/CalDavSettings.vue
index 06c5e9cf8fc..10af947bd3d 100644
--- a/apps/dav/src/views/CalDavSettings.vue
+++ b/apps/dav/src/views/CalDavSettings.vue
@@ -73,6 +73,9 @@
<script>
import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router'
+import { loadState } from '@nextcloud/initial-state'
+
+const userSyncCalendarsDocUrl = loadState('dav', 'userSyncCalendarsDocUrl', '#')
export default {
name: 'CalDavSettings',
@@ -84,7 +87,7 @@ export default {
)
return translated
.replace('{calendarappstoreopen}', '<a target="_blank" href="../apps/office/calendar">')
- .replace('{calendardocopen}', '<a target="_blank" :href="userSyncCalendarsUrl" rel="noreferrer noopener">')
+ .replace('{calendardocopen}', `<a target="_blank" href="${userSyncCalendarsDocUrl}" rel="noreferrer noopener">`)
.replace(/\{linkclose\}/g, '</a>')
},
sendInvitationsHelpText() {
diff --git a/apps/dav/src/views/__snapshots__/CalDavSettings.spec.js.snap b/apps/dav/src/views/__snapshots__/CalDavSettings.spec.js.snap
index fca9ceae155..469cd2f07eb 100644
--- a/apps/dav/src/views/__snapshots__/CalDavSettings.spec.js.snap
+++ b/apps/dav/src/views/__snapshots__/CalDavSettings.spec.js.snap
@@ -21,7 +21,7 @@ exports[`CalDavSettings interactions 1`] = `
</a>
, or
<a
- :href="userSyncCalendarsUrl"
+ href="https://docs.nextcloud.com/server/23/go.php?to=user-sync-calendars"
rel="noreferrer noopener"
target="_blank"
>
diff --git a/apps/dav/tests/unit/Settings/CalDAVSettingsTest.php b/apps/dav/tests/unit/Settings/CalDAVSettingsTest.php
index aa2216c480d..3384ead652f 100644
--- a/apps/dav/tests/unit/Settings/CalDAVSettingsTest.php
+++ b/apps/dav/tests/unit/Settings/CalDAVSettingsTest.php
@@ -26,27 +26,34 @@
namespace OCA\DAV\Tests\Unit\DAV\Settings;
use OCA\DAV\Settings\CalDAVSettings;
+use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\AppFramework\Services\IInitialState;
+use OCP\IURLGenerator;
+use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class CalDAVSettingsTest extends TestCase {
- /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IConfig|MockObject */
private $config;
- /** @var OCP\AppFramework\Services\IInitialState|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IInitialState|MockObject */
private $initialState;
+ /** @var IURLGenerator|MockObject */
+ private $urlGenerator;
+
/** @var CalDAVSettings */
- private $settings;
+ private CalDAVSettings $settings;
protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
$this->initialState = $this->createMock(IInitialState::class);
- $this->settings = new CalDAVSettings($this->config, $this->initialState);
+ $this->urlGenerator = $this->createMock(IURLGenerator::class);
+ $this->settings = new CalDAVSettings($this->config, $this->initialState, $this->urlGenerator);
}
public function testGetForm() {
@@ -58,8 +65,14 @@ class CalDAVSettingsTest extends TestCase {
['dav', 'sendEventRemindersPush', 'no'],
)
->will($this->onConsecutiveCalls('yes', 'no', 'yes', 'yes'));
+ $this->urlGenerator
+ ->expects($this->once())
+ ->method('linkToDocs')
+ ->with('user-sync-calendars')
+ ->willReturn('Some docs URL');
$this->initialState->method('provideInitialState')
->withConsecutive(
+ ['userSyncCalendarsDocUrl', 'Some docs URL'],
['sendInvitations', true],
['generateBirthdayCalendar', false],
['sendEventReminders', true],
@@ -67,7 +80,7 @@ class CalDAVSettingsTest extends TestCase {
);
$result = $this->settings->getForm();
- $this->assertInstanceOf('OCP\AppFramework\Http\TemplateResponse', $result);
+ $this->assertInstanceOf(TemplateResponse::class, $result);
}
public function testGetSection() {