From d5f8664d6090b0ee42dd94274342cb1ce2ef8db3 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Thu, 12 Mar 2020 03:54:26 +0000 Subject: [PATCH] get selected file/folder name --- src/app/files/file-explorer.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/app/files/file-explorer.js b/src/app/files/file-explorer.js index c552136969..2589ac8d90 100644 --- a/src/app/files/file-explorer.js +++ b/src/app/files/file-explorer.js @@ -126,6 +126,12 @@ function fileExplorer (localRegistry, files, menuItems) { }) } + function extractNameFromKey (key){ + const keyPath = key.split('/') + + return keyPath[keyPath.length - 1] + } + function folderAdded (folderpath) { self.ensureRoot(() => { folderpath = folderpath.split('/').slice(0, -1).join('/') @@ -228,7 +234,9 @@ function fileExplorer (localRegistry, files, menuItems) { } actions['Delete'] = () => { if (self.files.isReadOnly(key)) { return tooltip('cannot delete folder. ' + self.files.type + ' is a read only explorer') } - modalDialogCustom.confirm('Confirm to delete a folder', 'Are you sure you want to delete this folder?', + const currentFilename = extractNameFromKey(key) + + modalDialogCustom.confirm(`Confirm to delete a folder', 'Are you sure you want to delete ${currentFilename} folder?`, () => { if (!files.remove(key)) { tooltip(`failed to remove ${key}. Make sure the directory is empty before removing it.`) @@ -266,8 +274,7 @@ function fileExplorer (localRegistry, files, menuItems) { } actions['Delete'] = () => { if (self.files.isReadOnly(key)) { return tooltip('cannot delete file. ' + self.files.type + ' is a read only explorer') } - const currentPath = self._deps.config.get('currentFile').split('/') - const currentFilename = currentPath[currentPath.length - 1] + const currentFilename = extractNameFromKey(key) modalDialogCustom.confirm( 'Delete a file', `Are you sure you want to delete ${currentFilename} file?`,