From 35e534123a9722b479baab136b5c68e3354727f3 Mon Sep 17 00:00:00 2001 From: Andrii Rublov Date: Mon, 5 Feb 2024 19:47:01 +0000 Subject: [PATCH] feature(files) : When creating a new folder give a hint that folder names starting with dots might be hidden #21609 Signed-off-by: Andrii Rublov --- .../components/FileEntry/FileEntryName.vue | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/apps/files/src/components/FileEntry/FileEntryName.vue b/apps/files/src/components/FileEntry/FileEntryName.vue index 87859de353a5a..139061071b1c4 100644 --- a/apps/files/src/components/FileEntry/FileEntryName.vue +++ b/apps/files/src/components/FileEntry/FileEntryName.vue @@ -113,6 +113,12 @@ export default Vue.extend({ } }, + data() { + return { + isConfirmationFileCanHidden: false, + } + }, + computed: { isRenaming() { return this.renamingStore.renamingNode === this.source @@ -261,7 +267,7 @@ export default Vue.extend({ }) }, stopRenaming() { - if (!this.isRenaming) { + if (!this.isRenaming || this.isConfirmationFileCanHidden) { return } @@ -290,6 +296,35 @@ export default Vue.extend({ return } + // Checking and displaying confirmation that a file can be hidden + if(/^\.{1,}.+$/.test(newName)){ + const confirm = await new Promise(resolve => { + this.isConfirmationFileCanHidden = true + + OC.dialogs.confirmDestructive( + t('files', 'Are you sure you want to rename the file from {oldName} to {newName}? The file can be hidden.', { oldName, newName }), + t('files', 'Confirm renaming'), + { + type: OC.dialogs.YES_NO_BUTTONS, + confirm: 'Yes', + confirmClasses: 'error', + cancel: t('files', 'Cancel'), + }, + (decision: boolean) => { + resolve(decision) + }, + ) + return + }) + + // If the user cancels, we don't continue and return focus to the file + if (confirm === false) { + return + } + + this.isConfirmationFileCanHidden = false + } + // Set loading state this.loading = 'renaming' Vue.set(this.source, 'status', NodeStatus.LOADING)