diff --git a/src/components/widgets/filesystem/FileSystem.vue b/src/components/widgets/filesystem/FileSystem.vue index 41003df776..98686b1fa1 100644 --- a/src/components/widgets/filesystem/FileSystem.vue +++ b/src/components/widgets/filesystem/FileSystem.vue @@ -67,6 +67,7 @@ @view="handleFileOpenDialog" @edit="handleFileOpenDialog" @rename="handleRenameDialog" + @duplicate="handleDuplicateDialog" @remove="handleRemove" @download="handleDownload" @preheat="handlePreheat" @@ -577,8 +578,8 @@ export default class FileSystem extends Mixins(StateMixin, FilesMixin, ServicesM if (this.disabled) return const [title, label] = item.type === 'file' - ? [this.$t('app.file_system.title.rename_dir'), this.$t('app.file_system.label.dir_name')] - : [this.$t('app.file_system.title.rename_file'), this.$t('app.file_system.label.file_name')] + ? [this.$t('app.file_system.title.rename_file'), this.$t('app.file_system.label.file_name')] + : [this.$t('app.file_system.title.rename_dir'), this.$t('app.file_system.label.dir_name')] this.fileNameDialogState = { open: true, @@ -589,6 +590,22 @@ export default class FileSystem extends Mixins(StateMixin, FilesMixin, ServicesM } } + handleDuplicateDialog (item: FileBrowserEntry) { + if (this.disabled) return + + const [title, label] = item.type === 'file' + ? [this.$t('app.file_system.title.duplicate_file'), this.$t('app.file_system.label.file_name')] + : [this.$t('app.file_system.title.duplicate_dir'), this.$t('app.file_system.label.dir_name')] + + this.fileNameDialogState = { + open: true, + title, + label, + value: item.name, + handler: this.handleDuplicate + } + } + handleAddFileDialog () { if (this.disabled) return this.fileNameDialogState = { @@ -785,6 +802,12 @@ export default class FileSystem extends Mixins(StateMixin, FilesMixin, ServicesM SocketActions.serverFilesMove(src, dest) } + handleDuplicate (name: string) { + const src = `${this.currentPath}/${this.fileNameDialogState.value}` + const dest = `${this.currentPath}/${name}` + SocketActions.serverFilesCopy(src, dest) + } + async handleRemove (file: FileBrowserEntry | FileBrowserEntry[]) { if (this.disabled) return diff --git a/src/components/widgets/filesystem/FileSystemContextMenu.vue b/src/components/widgets/filesystem/FileSystemContextMenu.vue index 5bd935ad5f..1f25adc120 100644 --- a/src/components/widgets/filesystem/FileSystemContextMenu.vue +++ b/src/components/widgets/filesystem/FileSystemContextMenu.vue @@ -130,6 +130,19 @@ + + + $duplicate + + + {{ $t('app.general.btn.duplicate') }} + + +