From e75b9ea168c7ac18ec541c1d1362ab5474314a45 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 17 Sep 2018 18:09:26 +0200 Subject: [PATCH] Prevent shared folders from being dropped to the trash --- www/drive/inner.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/www/drive/inner.js b/www/drive/inner.js index e9271f7c3..2acae0f3e 100644 --- a/www/drive/inner.js +++ b/www/drive/inner.js @@ -1298,6 +1298,7 @@ define([ if (!oldPaths) { return; } // A moved element should be removed from its previous location var movedPaths = []; + var sharedF = false; oldPaths.forEach(function (p) { movedPaths.push(p.path); @@ -1309,9 +1310,25 @@ define([ var newPath = findDropPath(ev.target); if (!newPath) { return; } if (sharedF && manager.isPathIn(newPath, [TRASH])) { - deletePaths(null, movedPaths); - return; + return void deletePaths(null, movedPaths); } + + if (manager.isPathIn(newPath, [TRASH])) { + // Filter the selection to remove shared folders. + // Shared folders can't be moved to the trash! + var filteredPaths = movedPaths.filter(function (p) { + var el = manager.find(p); + return !manager.isSharedFolder(el); + }); + + if (!filteredPaths.length) { + // We only have shared folder, delete them + return void deletePaths(null, movedPaths); + } + + movedPaths = filteredPaths; + } + if (movedPaths && movedPaths.length) { moveElements(movedPaths, newPath, null, refresh); }