1+ <!--
2+ - SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
3+ - SPDX-License-Identifier: AGPL-3.0-or-later
4+ -->
5+
6+ <script setup lang="ts">
7+ import { ref } from ' vue'
8+ import { NcNoteCard , NcCheckboxRadioSwitch , NcSettingsSection } from ' @nextcloud/vue'
9+ import { loadState } from ' @nextcloud/initial-state'
10+ import axios from ' @nextcloud/axios'
11+ import { generateUrl } from ' @nextcloud/router'
12+ import { showError } from ' @nextcloud/dialogs'
13+ import { t } from ' @nextcloud/l10n'
14+
15+ const serverSideEncryptionEnabled = ref <string >(loadState <string >(' groupfolders' , ' server_side_encryption' , ' no' ))
16+ const folderEncryptionEnabled = ref <boolean >(loadState <boolean >(' groupfolders' , ' enable_encryption' , false ))
17+
18+ const loading = ref (false )
19+
20+ async function handleChange(isEnabled : boolean ) {
21+ if (loading .value || serverSideEncryptionEnabled .value === ' no' || (folderEncryptionEnabled .value == true && isEnabled == false )) {
22+ return
23+ }
24+ const previous = folderEncryptionEnabled .value
25+ folderEncryptionEnabled .value = isEnabled
26+ loading .value = true
27+ try {
28+ await axios .post (generateUrl (' apps/groupfolders/settings' ), { enable: isEnabled })
29+ } catch {
30+ folderEncryptionEnabled .value = previous
31+ showError (t (' groupfolders' , ' Failed to update encryption setting' ))
32+ } finally {
33+ loading .value = false
34+ }
35+ }
36+ </script >
37+
38+ <template >
39+ <NcSettingsSection :name =" t (' groupfolders' , ' Team folders encryption' )" >
40+ <NcCheckboxRadioSwitch
41+ :class =" { disabled: folderEncryptionEnabled || serverSideEncryptionEnabled === ' no' } "
42+ type="switch"
43+ :model-value =" folderEncryptionEnabled "
44+ :aria-disabled =" loading || serverSideEncryptionEnabled === ' no' || folderEncryptionEnabled == true "
45+ :loading =" loading "
46+ :description =" ! folderEncryptionEnabled ? t (' groupfolders' , ' Encrypt team folders using server-side encryption. Remember that the data cannot be accessed if the encryption key is lost.' ) : null "
47+ @update :model-value =" handleChange " >
48+ {{ t('groupfolders', 'Enable Team Folders encryption') }}
49+ </NcCheckboxRadioSwitch >
50+
51+ <p v-if =" serverSideEncryptionEnabled === 'yes' && folderEncryptionEnabled == true" id =" team-folders-encryption-disable-hint" class =" disable-hint" >
52+ {{ t('groupfolders', 'Disabling team folders encryption is only possible using OCC, please refer to the documentation.') }}
53+ </p >
54+
55+ <NcNoteCard v-if =" serverSideEncryptionEnabled === ' no' " type="warning"
56+ :text =" t (' settings' , ' Team Folders cannot be encrypted on the server because server-side encryption is disabled.' )" />
57+ </NcSettingsSection >
58+ </template >
59+
60+ <style scoped>
61+
62+ .disabled {
63+ opacity : .75 ;
64+ }
65+
66+ .disabled :deep(* ) {
67+ cursor : not-allowed !important ;
68+ }
69+
70+ .disable-hint {
71+ color : var (--color-text-maxcontrast );
72+ padding-inline-start : 10px ;
73+ }
74+ </style >
0 commit comments