Skip to content
Open
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
35 changes: 4 additions & 31 deletions apps/dav/lib/Settings/ExampleContentSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use OCA\DAV\AppInfo\Application;
use OCA\DAV\Service\ExampleContactService;
use OCA\DAV\Service\ExampleEventService;
use OCP\App\IAppManager;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Services\IAppConfig;
use OCP\AppFramework\Services\IInitialState;
Expand All @@ -23,38 +22,17 @@ class ExampleContentSettings implements ISettings {
public function __construct(
private readonly IAppConfig $appConfig,
private readonly IInitialState $initialState,
private readonly IAppManager $appManager,
private readonly ExampleEventService $exampleEventService,
private readonly ExampleContactService $exampleContactService,
) {
}

#[\Override]
public function getForm(): TemplateResponse {
$calendarEnabled = $this->appManager->isEnabledForUser('calendar');
$contactsEnabled = $this->appManager->isEnabledForUser('contacts');
$this->initialState->provideInitialState('calendarEnabled', $calendarEnabled);
$this->initialState->provideInitialState('contactsEnabled', $contactsEnabled);

if ($calendarEnabled) {
$enableDefaultEvent = $this->exampleEventService->shouldCreateExampleEvent();
$this->initialState->provideInitialState('create_example_event', $enableDefaultEvent);
$this->initialState->provideInitialState(
'has_custom_example_event',
$this->exampleEventService->hasCustomExampleEvent(),
);
}

if ($contactsEnabled) {
$this->initialState->provideInitialState(
'enableDefaultContact',
$this->exampleContactService->isDefaultContactEnabled(),
);
$this->initialState->provideInitialState(
'hasCustomDefaultContact',
$this->appConfig->getAppValueBool('hasCustomDefaultContact'),
);
}
$this->initialState->provideInitialState('create_example_event', $this->exampleEventService->shouldCreateExampleEvent());
$this->initialState->provideInitialState('has_custom_example_event', $this->exampleEventService->hasCustomExampleEvent());
$this->initialState->provideInitialState('enableDefaultContact', $this->exampleContactService->isDefaultContactEnabled());
$this->initialState->provideInitialState('hasCustomDefaultContact', $this->appConfig->getAppValueBool('hasCustomDefaultContact'));
Comment on lines 31 to +35

Util::addStyle(Application::APP_ID, 'settings-admin-example-content');
Util::addScript(Application::APP_ID, 'settings-admin-example-content');
Expand All @@ -63,11 +41,6 @@ public function getForm(): TemplateResponse {

#[\Override]
public function getSection(): ?string {
if (!$this->appManager->isEnabledForUser('contacts')
&& !$this->appManager->isEnabledForUser('calendar')) {
return null;
}

return 'groupware';
}

Expand Down
8 changes: 2 additions & 6 deletions apps/dav/src/views/ExampleContentSettingsSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,18 @@
-->

<script setup lang="ts">
import { loadState } from '@nextcloud/initial-state'
import { t } from '@nextcloud/l10n'
import { NcSettingsSection } from '@nextcloud/vue'
import ExampleContactSettings from '../components/ExampleContactSettings.vue'
import ExampleEventSettings from '../components/ExampleEventSettings.vue'

const hasContactsApp = loadState('dav', 'contactsEnabled')
const hasCalendarApp = loadState('dav', 'calendarEnabled')
</script>

<template>
<NcSettingsSection
id="example-content"
:name="t('dav', 'Example content')"
:description="t('dav', 'Example content serves to showcase the features of Nextcloud. Default content is shipped with Nextcloud, and can be replaced by custom content.')">
<ExampleContactSettings v-if="hasContactsApp" />
<ExampleEventSettings v-if="hasCalendarApp" />
<ExampleContactSettings />
<ExampleEventSettings />
</NcSettingsSection>
Comment on lines 13 to 20
</template>
Loading
Loading