diff --git a/apps/files/src/store/userconfig.ts b/apps/files/src/store/userconfig.ts index 8e55f0ed113ac..f41054386808d 100644 --- a/apps/files/src/store/userconfig.ts +++ b/apps/files/src/store/userconfig.ts @@ -16,6 +16,7 @@ import { ref, set } from 'vue' const initialUserConfig = loadState('files', 'config', { crop_image_previews: true, default_view: 'files', + folder_tree: false, grid_view: false, show_files_extensions: true, show_hidden: false, @@ -36,7 +37,7 @@ export const useUserConfigStore = defineStore('userconfig', () => { * @param key The config key * @param value The new value */ - function onUpdate(key: string, value: boolean): void { + function onUpdate(key: string, value: boolean | string): void { set(userConfig.value, key, value) } @@ -44,10 +45,11 @@ export const useUserConfigStore = defineStore('userconfig', () => { * Update the user config local store AND on server side * * @param key The config key - * @param value The new value + * @param value The new value (boolean for switches, string for default_view) */ - async function update(key: string, value: boolean): Promise { - // only update if a user is logged in (not the case for public shares) + async function update(key: string, value: boolean | string): Promise { + onUpdate(key, value) + if (getCurrentUser() !== null) { await axios.put(generateUrl('/apps/files/api/v1/config/{key}', { key }), { value, @@ -56,7 +58,6 @@ export const useUserConfigStore = defineStore('userconfig', () => { emit('files:config:updated', { key, value }) } - // Register the event listener subscribe('files:config:updated', ({ key, value }) => onUpdate(key, value)) return { diff --git a/apps/files/src/types.ts b/apps/files/src/types.ts index 5624f0a7756cf..18565548ace2c 100644 --- a/apps/files/src/types.ts +++ b/apps/files/src/types.ts @@ -54,6 +54,7 @@ export interface UserConfig { crop_image_previews: boolean default_view: 'files' | 'personal' + folder_tree: boolean grid_view: boolean show_files_extensions: boolean show_hidden: boolean diff --git a/apps/files/src/views/FilesAppSettings.vue b/apps/files/src/views/FilesAppSettings.vue index be3b964a57338..82803413994c1 100644 --- a/apps/files/src/views/FilesAppSettings.vue +++ b/apps/files/src/views/FilesAppSettings.vue @@ -10,75 +10,63 @@ @update:open="onClose"> -
+ + + + + + - - {{ t('files', 'Default view') }} - - + - {{ t('files', 'All files') }} - - + - {{ t('files', 'Personal files') }} - -
- - {{ t('files', 'Sort favorites first') }} - - - {{ t('files', 'Sort folders before files') }} - - - {{ t('files', 'Folder tree') }} - + :label="t('files', 'Personal files')" /> +
- - {{ t('files', 'Show hidden files') }} - - - {{ t('files', 'Show file type column') }} - - - {{ t('files', 'Show file extensions') }} - - - {{ t('files', 'Crop image previews') }} - + + + + + + @@ -107,36 +95,39 @@ - - - {{ t('files', 'How to access files using WebDAV') }} ↗ - - -
- - - {{ t('files', 'Two-Factor Authentication is enabled for your account, and therefore you need to use an app password to connect an external WebDAV client.') }} ↗ - - + + + + + + + + - - {{ t('files', 'Warn before changing a file extension') }} - - - {{ t('files', 'Warn before deleting files') }} - + + + + @@ -153,9 +144,14 @@ import { generateRemoteUrl, generateUrl } from '@nextcloud/router' import { useHotKey } from '@nextcloud/vue/composables/useHotKey' import NcAppSettingsDialog from '@nextcloud/vue/components/NcAppSettingsDialog' import NcAppSettingsSection from '@nextcloud/vue/components/NcAppSettingsSection' -import NcCheckboxRadioSwitch from '@nextcloud/vue/components/NcCheckboxRadioSwitch' +import NcFormBox from '@nextcloud/vue/components/NcFormBox' +import NcFormBoxButton from '@nextcloud/vue/components/NcFormBoxButton' +import NcFormBoxSwitch from '@nextcloud/vue/components/NcFormBoxSwitch' import NcInputField from '@nextcloud/vue/components/NcInputField' +import NcRadioGroup from '@nextcloud/vue/components/NcRadioGroup' +import NcRadioGroupButton from '@nextcloud/vue/components/NcRadioGroupButton' import Clipboard from 'vue-material-design-icons/ContentCopy.vue' +import OpenInNew from 'vue-material-design-icons/OpenInNew.vue' import FilesAppSettingsEntry from '../components/FilesAppSettings/FilesAppSettingsEntry.vue' import FilesAppSettingsShortcuts from '../components/FilesAppSettings/FilesAppSettingsShortcuts.vue' import { useUserConfigStore } from '../store/userconfig.ts' @@ -168,8 +164,13 @@ export default { FilesAppSettingsShortcuts, NcAppSettingsDialog, NcAppSettingsSection, - NcCheckboxRadioSwitch, + NcFormBox, + NcFormBoxButton, + NcFormBoxSwitch, NcInputField, + NcRadioGroup, + NcRadioGroupButton, + OpenInNew, }, props: { @@ -179,6 +180,8 @@ export default { }, }, + emits: ['close', 'update:open'], + setup() { const userConfigStore = useUserConfigStore() const isSystemtagsEnabled = getCapabilities()?.systemtags?.enabled === true @@ -221,7 +224,6 @@ export default { }, created() { - // ? opens the settings dialog on the keyboard shortcuts section useHotKey('?', this.showKeyboardShortcuts, { stop: true, prevent: true, @@ -243,8 +245,13 @@ export default { this.$emit('close') }, - setConfig(key, value) { - this.userConfigStore.update(key, value) + async setConfig(key, value) { + try { + await this.userConfigStore.update(key, value) + showSuccess(t('files', 'Setting saved')) + } catch { + showError(t('files', 'Failed to save setting')) + } }, async copyCloudId() { @@ -278,23 +285,15 @@ export default {