diff options
Diffstat (limited to 'apps/dav/src/views')
-rw-r--r-- | apps/dav/src/views/ExampleContactSettings.vue | 160 | ||||
-rw-r--r-- | apps/dav/src/views/ExampleContentSettingsSection.vue | 38 | ||||
-rw-r--r-- | apps/dav/src/views/__snapshots__/CalDavSettings.spec.js.snap | 70 |
3 files changed, 73 insertions, 195 deletions
diff --git a/apps/dav/src/views/ExampleContactSettings.vue b/apps/dav/src/views/ExampleContactSettings.vue deleted file mode 100644 index d4d1c7d31d0..00000000000 --- a/apps/dav/src/views/ExampleContactSettings.vue +++ /dev/null @@ -1,160 +0,0 @@ -<!-- - - SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors - - SPDX-License-Identifier: AGPL-3.0-or-later ---> - -<template> - <NcSettingsSection id="exmaple-content" - :name="$t('dav', 'Example Content')" - class="example-content-setting" - :description="$t('dav', 'Set example content to be created on new user first login.')"> - <div class="example-content-setting__contacts"> - <input id="enable-default-contact" - v-model="enableDefaultContact" - type="checkbox" - class="checkbox" - @change="updateEnableDefaultContact"> - <label for="enable-default-contact"> {{ $t('dav',"Default contact is added to the user's own address book on user's first login.") }} </label> - <div v-if="enableDefaultContact" class="example-content-setting__contacts__buttons"> - <NcButton type="primary" - class="example-content-setting__contacts__buttons__button" - @click="toggleModal"> - <template #icon> - <IconUpload :size="20" /> - </template> - {{ $t('dav', 'Import contact') }} - </NcButton> - <NcButton type="secondary" - class="example-content-setting__contacts__buttons__button" - @click="resetContact"> - <template #icon> - <IconRestore :size="20" /> - </template> - {{ $t('dav', 'Reset to default contact') }} - </NcButton> - </div> - </div> - <NcDialog :open.sync="isModalOpen" - :name="$t('dav', 'Import contacts')" - :buttons="buttons"> - <div> - <p>{{ $t('dav', 'Importing a new .vcf file will delete the existing default contact and replace it with the new one. Do you want to continue?') }}</p> - </div> - </NcDialog> - <input id="example-contact-import" - ref="exampleContactImportInput" - :disabled="loading" - type="file" - accept=".vcf" - class="hidden-visually" - @change="processFile"> - </NcSettingsSection> -</template> -<script> -import axios from '@nextcloud/axios' -import { generateUrl } from '@nextcloud/router' -import { loadState } from '@nextcloud/initial-state' -import { NcDialog, NcButton, NcSettingsSection } from '@nextcloud/vue' -import { showError, showSuccess } from '@nextcloud/dialogs' -import IconUpload from 'vue-material-design-icons/Upload.vue' -import IconRestore from 'vue-material-design-icons/Restore.vue' -import IconCancel from '@mdi/svg/svg/cancel.svg?raw' -import IconCheck from '@mdi/svg/svg/check.svg?raw' - -const enableDefaultContact = loadState('dav', 'enableDefaultContact') === 'yes' - -export default { - name: 'ExampleContactSettings', - components: { - NcDialog, - NcButton, - NcSettingsSection, - IconUpload, - IconRestore, - }, - data() { - return { - enableDefaultContact, - isModalOpen: false, - loading: false, - buttons: [ - { - label: this.$t('dav', 'Cancel'), - icon: IconCancel, - callback: () => { this.isModalOpen = false }, - }, - { - label: this.$t('dav', 'Import'), - type: 'primary', - icon: IconCheck, - callback: () => { this.clickImportInput() }, - }, - ], - } - }, - methods: { - updateEnableDefaultContact() { - axios.put(generateUrl('apps/dav/api/defaultcontact/config'), { - allow: this.enableDefaultContact ? 'yes' : 'no', - }).catch(() => { - this.enableDefaultContact = !this.enableDefaultContact - showError(this.$t('dav', 'Error while saving settings')) - }) - }, - toggleModal() { - this.isModalOpen = !this.isModalOpen - }, - clickImportInput() { - this.$refs.exampleContactImportInput.click() - }, - resetContact() { - this.loading = true - axios.put(generateUrl('/apps/dav/api/defaultcontact/contact')) - .then(() => { - showSuccess(this.$t('dav', 'Contact reset successfully')) - }) - .catch((error) => { - console.error('Error importing contact:', error) - showError(this.$t('dav', 'Error while resetting contact')) - }) - .finally(() => { - this.loading = false - }) - }, - processFile(event) { - this.loading = true - - const file = event.target.files[0] - const reader = new FileReader() - - reader.onload = async () => { - this.isModalOpen = false - try { - await axios.put(generateUrl('/apps/dav/api/defaultcontact/contact'), { contactData: reader.result }) - showSuccess(this.$t('dav', 'Contact imported successfully')) - } catch (error) { - console.error('Error importing contact:', error) - showError(this.$t('dav', 'Error while importing contact')) - } finally { - this.loading = false - event.target.value = '' - } - } - reader.readAsText(file) - }, - }, -} -</script> -<style lang="scss" scoped> -.example-content-setting{ - &__contacts{ - &__buttons{ - margin-top: 1rem; - display: flex; - &__button{ - margin-inline-end: 5px; - } - } - } -} -</style> diff --git a/apps/dav/src/views/ExampleContentSettingsSection.vue b/apps/dav/src/views/ExampleContentSettingsSection.vue new file mode 100644 index 00000000000..3ee2d9e8648 --- /dev/null +++ b/apps/dav/src/views/ExampleContentSettingsSection.vue @@ -0,0 +1,38 @@ +<!-- + - SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + - SPDX-License-Identifier: AGPL-3.0-or-later +--> + +<template> + <NcSettingsSection id="example-content" + :name="$t('dav', 'Example content')" + class="example-content-setting" + :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" /> + </NcSettingsSection> +</template> + +<script> +import { loadState } from '@nextcloud/initial-state' +import { NcSettingsSection } from '@nextcloud/vue' +import ExampleEventSettings from '../components/ExampleEventSettings.vue' +import ExampleContactSettings from '../components/ExampleContactSettings.vue' + +export default { + name: 'ExampleContentSettingsSection', + components: { + NcSettingsSection, + ExampleContactSettings, + ExampleEventSettings, + }, + computed: { + hasContactsApp() { + return loadState('dav', 'contactsEnabled') + }, + hasCalendarApp() { + return loadState('dav', 'calendarEnabled') + }, + }, +} +</script> diff --git a/apps/dav/src/views/__snapshots__/CalDavSettings.spec.js.snap b/apps/dav/src/views/__snapshots__/CalDavSettings.spec.js.snap index 1d2dc512561..fdbe09f5b5e 100644 --- a/apps/dav/src/views/__snapshots__/CalDavSettings.spec.js.snap +++ b/apps/dav/src/views/__snapshots__/CalDavSettings.spec.js.snap @@ -72,35 +72,35 @@ exports[`CalDavSettings > interactions 1`] = ` > <span class="checkbox-radio-switch checkbox-radio-switch-switch checkbox-radio-switch--checked" - data-v-22cdd229="" data-v-6b8d4c30="" data-v-6f6953b5="" + data-v-f275cf53="" style="--icon-size: 36px; --icon-height: 16px;" > <input aria-labelledby="caldavSendInvitations-label" class="checkbox-radio-switch__input" - data-v-22cdd229="" + data-v-f275cf53="" id="caldavSendInvitations" type="checkbox" value="" /> <span class="checkbox-content checkbox-radio-switch__content checkbox-content-switch checkbox-content--has-text" - data-v-18de8bed="" - data-v-22cdd229="" + data-v-3714b019="" + data-v-f275cf53="" id="caldavSendInvitations-label" > <span aria-hidden="true" class="checkbox-content__icon checkbox-content__icon--checked checkbox-radio-switch__icon" - data-v-18de8bed="" + data-v-3714b019="" inert="inert" > <span aria-hidden="true" class="material-design-icon toggle-switch-icon" - data-v-18de8bed="" + data-v-3714b019="" role="img" > <svg @@ -120,7 +120,7 @@ exports[`CalDavSettings > interactions 1`] = ` </span> <span class="checkbox-content__text checkbox-radio-switch__text" - data-v-18de8bed="" + data-v-3714b019="" > Send invitations to attendees </span> @@ -145,35 +145,35 @@ exports[`CalDavSettings > interactions 1`] = ` > <span class="checkbox-radio-switch checkbox checkbox-radio-switch-switch checkbox-radio-switch--checked" - data-v-22cdd229="" data-v-6b8d4c30="" data-v-6f6953b5="" + data-v-f275cf53="" style="--icon-size: 36px; --icon-height: 16px;" > <input aria-labelledby="caldavGenerateBirthdayCalendar-label" class="checkbox-radio-switch__input" - data-v-22cdd229="" + data-v-f275cf53="" id="caldavGenerateBirthdayCalendar" type="checkbox" value="" /> <span class="checkbox-content checkbox-radio-switch__content checkbox-content-switch checkbox-content--has-text" - data-v-18de8bed="" - data-v-22cdd229="" + data-v-3714b019="" + data-v-f275cf53="" id="caldavGenerateBirthdayCalendar-label" > <span aria-hidden="true" class="checkbox-content__icon checkbox-content__icon--checked checkbox-radio-switch__icon" - data-v-18de8bed="" + data-v-3714b019="" inert="inert" > <span aria-hidden="true" class="material-design-icon toggle-switch-icon" - data-v-18de8bed="" + data-v-3714b019="" role="img" > <svg @@ -193,7 +193,7 @@ exports[`CalDavSettings > interactions 1`] = ` </span> <span class="checkbox-content__text checkbox-radio-switch__text" - data-v-18de8bed="" + data-v-3714b019="" > Automatically generate a birthday calendar </span> @@ -222,35 +222,35 @@ exports[`CalDavSettings > interactions 1`] = ` > <span class="checkbox-radio-switch checkbox-radio-switch-switch checkbox-radio-switch--checked" - data-v-22cdd229="" data-v-6b8d4c30="" data-v-6f6953b5="" + data-v-f275cf53="" style="--icon-size: 36px; --icon-height: 16px;" > <input aria-labelledby="caldavSendEventReminders-label" class="checkbox-radio-switch__input" - data-v-22cdd229="" + data-v-f275cf53="" id="caldavSendEventReminders" type="checkbox" value="" /> <span class="checkbox-content checkbox-radio-switch__content checkbox-content-switch checkbox-content--has-text" - data-v-18de8bed="" - data-v-22cdd229="" + data-v-3714b019="" + data-v-f275cf53="" id="caldavSendEventReminders-label" > <span aria-hidden="true" class="checkbox-content__icon checkbox-content__icon--checked checkbox-radio-switch__icon" - data-v-18de8bed="" + data-v-3714b019="" inert="inert" > <span aria-hidden="true" class="material-design-icon toggle-switch-icon" - data-v-18de8bed="" + data-v-3714b019="" role="img" > <svg @@ -270,7 +270,7 @@ exports[`CalDavSettings > interactions 1`] = ` </span> <span class="checkbox-content__text checkbox-radio-switch__text" - data-v-18de8bed="" + data-v-3714b019="" > Send notifications for events </span> @@ -306,35 +306,35 @@ exports[`CalDavSettings > interactions 1`] = ` > <span class="checkbox-radio-switch checkbox-radio-switch-switch checkbox-radio-switch--checked" - data-v-22cdd229="" data-v-6b8d4c30="" data-v-6f6953b5="" + data-v-f275cf53="" style="--icon-size: 36px; --icon-height: 16px;" > <input aria-labelledby="caldavSendEventRemindersToSharedGroupMembers-label" class="checkbox-radio-switch__input" - data-v-22cdd229="" + data-v-f275cf53="" id="caldavSendEventRemindersToSharedGroupMembers" type="checkbox" value="" /> <span class="checkbox-content checkbox-radio-switch__content checkbox-content-switch checkbox-content--has-text" - data-v-18de8bed="" - data-v-22cdd229="" + data-v-3714b019="" + data-v-f275cf53="" id="caldavSendEventRemindersToSharedGroupMembers-label" > <span aria-hidden="true" class="checkbox-content__icon checkbox-content__icon--checked checkbox-radio-switch__icon" - data-v-18de8bed="" + data-v-3714b019="" inert="inert" > <span aria-hidden="true" class="material-design-icon toggle-switch-icon" - data-v-18de8bed="" + data-v-3714b019="" role="img" > <svg @@ -354,7 +354,7 @@ exports[`CalDavSettings > interactions 1`] = ` </span> <span class="checkbox-content__text checkbox-radio-switch__text" - data-v-18de8bed="" + data-v-3714b019="" > Send reminder notifications to calendar sharees as well </span> @@ -374,35 +374,35 @@ exports[`CalDavSettings > interactions 1`] = ` > <span class="checkbox-radio-switch checkbox-radio-switch-switch checkbox-radio-switch--checked" - data-v-22cdd229="" data-v-6b8d4c30="" data-v-6f6953b5="" + data-v-f275cf53="" style="--icon-size: 36px; --icon-height: 16px;" > <input aria-labelledby="caldavSendEventRemindersPush-label" class="checkbox-radio-switch__input" - data-v-22cdd229="" + data-v-f275cf53="" id="caldavSendEventRemindersPush" type="checkbox" value="" /> <span class="checkbox-content checkbox-radio-switch__content checkbox-content-switch checkbox-content--has-text" - data-v-18de8bed="" - data-v-22cdd229="" + data-v-3714b019="" + data-v-f275cf53="" id="caldavSendEventRemindersPush-label" > <span aria-hidden="true" class="checkbox-content__icon checkbox-content__icon--checked checkbox-radio-switch__icon" - data-v-18de8bed="" + data-v-3714b019="" inert="inert" > <span aria-hidden="true" class="material-design-icon toggle-switch-icon" - data-v-18de8bed="" + data-v-3714b019="" role="img" > <svg @@ -422,7 +422,7 @@ exports[`CalDavSettings > interactions 1`] = ` </span> <span class="checkbox-content__text checkbox-radio-switch__text" - data-v-18de8bed="" + data-v-3714b019="" > Enable notifications for events via push </span> |