Skip to content

Commit

Permalink
fix(settings): Show feedback 4 server-sde encryption toggle
Browse files Browse the repository at this point in the history
Show visual feedback if user clicks on encryption toggle when it cannot be activated.

Signed-off-by: nfebe <fenn25.fn@gmail.com>
  • Loading branch information
nfebe committed Nov 11, 2024
1 parent 038deb4 commit 016738f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions apps/settings/src/components/Encryption.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
:description="t('settings', 'Server-side encryption makes it possible to encrypt files which are uploaded to this server. This comes with limitations like a performance penalty, so enable this only if needed.')"
:doc-url="encryptionAdminDoc">
<NcCheckboxRadioSwitch :checked="encryptionEnabled || shouldDisplayWarning"
:disabled="encryptionEnabled"
type="switch"
@update:checked="displayWarning">
{{ t('settings', 'Enable server-side encryption') }}
Expand All @@ -34,7 +33,7 @@

<div v-if="encryptionEnabled">
<div v-if="encryptionReady">
<p v-if="encryptionModules.length === 0">
<p v-if="!hasEncryptionModules">
{{ t('settings', 'No encryption module loaded, please enable an encryption module in the app menu.') }}
</p>
<template v-else>
Expand Down Expand Up @@ -89,8 +88,9 @@ export default {
},
data() {
const encryptionModules = loadState('settings', 'encryption-modules')
const hasEncryptionModules = encryptionModules instanceof Array && encryptionModules.length > 0
let defaultCheckedModule = ''
if (encryptionModules instanceof Array && encryptionModules.length > 0) {
if (hasEncryptionModules) {
const defaultModule = Object.entries(encryptionModules).find((module) => module[1].default)
if (defaultModule) {
defaultCheckedModule = foundModule[0]
Expand All @@ -107,10 +107,19 @@ export default {
shouldDisplayWarning: false,
migrating: false,
defaultCheckedModule,
hasEncryptionModules,
}
},
methods: {
displayWarning() {
if (!this.hasEncryptionModules || !this.encryptionReady) {
this.encryptionEnabled = true
showError(t('settings', 'Encryption is not ready, please enable an encryption module/app.'))
setTimeout(() => {
this.encryptionEnabled = false
}, 1000)
return
}
if (!this.encryptionEnabled) {
this.shouldDisplayWarning = !this.shouldDisplayWarning
} else {
Expand Down

0 comments on commit 016738f

Please sign in to comment.