Merge branch 'sfTrash' into staging

pull/1/head
ansuz 4 years ago
commit 2302d6ef7e

@ -1202,7 +1202,7 @@ define([
hide.push('collapseall'); hide.push('collapseall');
} }
if (path.length === 1) { if (path.length === 1) {
// Can't rename, share, delete, or change the color of root elements // Can't rename, share, delete, or change the color of categories
hide.push('delete'); hide.push('delete');
hide.push('rename'); hide.push('rename');
hide.push('share'); hide.push('share');
@ -1257,7 +1257,7 @@ define([
hide.push('openro'); hide.push('openro');
hide.push('openincode'); hide.push('openincode');
hide.push('hashtag'); hide.push('hashtag');
hide.push('delete'); //hide.push('delete');
hide.push('makeacopy'); hide.push('makeacopy');
//hide.push('deleteowned'); //hide.push('deleteowned');
} else { // it's a folder } else { // it's a folder
@ -1768,25 +1768,15 @@ define([
}); });
if (sharedF && manager.isPathIn(newPath, [TRASH])) { if (sharedF && manager.isPathIn(newPath, [TRASH])) {
return void deletePaths(null, movedPaths); // XXX create a key here?
// You can't move to YOUR trash documents stored in a shared folder
// XXX or keep deletePaths: trigger the "Remove from cryptdrive" modal
return void UI.warn(Messages.error);
//return void deletePaths(null, movedPaths);
} }
var copy = false; var copy = false;
if (manager.isPathIn(newPath, [TRASH])) { if (ev.ctrlKey || (ev.metaKey && APP.isMac)) {
// 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;
} else if (ev.ctrlKey || (ev.metaKey && APP.isMac)) {
copy = true; copy = true;
} }
@ -2254,15 +2244,25 @@ define([
var skipNext = false; // When encountering a shared folder, skip a key in the path var skipNext = false; // When encountering a shared folder, skip a key in the path
path.forEach(function (p, idx) { path.forEach(function (p, idx) {
if (skipNext) { skipNext = false; return; }
if (isTrash && [2,3].indexOf(idx) !== -1) { return; } if (isTrash && [2,3].indexOf(idx) !== -1) { return; }
if (skipNext) { skipNext = false; return; }
var name = p; var name = p;
if (manager.isFile(el) && isInTrashRoot && idx === 1) { if (manager.isFile(el) && isInTrashRoot && idx === 1) {
idx = 3; idx = 3;
} }
// Check if the current element is a shared folder. If it is, get its
// name and skip the next itme in the path (it will be "root")
var currentEl = isVirtual ? undefined : manager.find(path.slice(0, idx+1)); var currentEl = isVirtual ? undefined : manager.find(path.slice(0, idx+1));
// If we're in trash root, check if the "element" is a shared folder
if (isTrash && idx === 1) {
currentEl = manager.find(path.slice(0, idx+3));
}
// Name and skip next...
// "p === SHARED_FOLDER" for anonymous shared folders
if (p === SHARED_FOLDER || (currentEl && manager.isSharedFolder(currentEl))) { if (p === SHARED_FOLDER || (currentEl && manager.isSharedFolder(currentEl))) {
name = manager.getSharedFolderData(currentEl || APP.newSharedFolder).title; name = manager.getSharedFolderData(currentEl || APP.newSharedFolder).title;
skipNext = true; skipNext = true;
@ -4582,23 +4582,18 @@ define([
paths.push($(elmt).data('path')); paths.push($(elmt).data('path'));
}); });
if (!paths.length) { return; } if (!paths.length) { return; }
// Remove shared folders from the selection (they can't be moved to the trash)
// unless the selection is only shared folders // If we are in the trash or anon USER or if we are holding the "shift" key,
var paths2 = paths.filter(function (p) {
var el = manager.find(p);
return !manager.isSharedFolder(el);
});
// If we are in the trash or anon pad or if we are holding the "shift" key,
// delete permanently // delete permanently
// Or if we are in a shared folder // Or if we are in a shared folder
// Or if the selection is only shared folders // Or if the selection is only shared folders
if (!APP.loggedIn || isTrash || manager.isInSharedFolder(currentPath) if (!APP.loggedIn || isTrash || manager.isInSharedFolder(currentPath)
|| e.shiftKey || !paths2.length) { || e.shiftKey) {
deletePaths(null, paths); deletePaths(null, paths);
return; return;
} }
// else move to trash // else move to trash
moveElements(paths2, [TRASH], false, refresh); moveElements(paths, [TRASH], false, refresh);
return; return;
} }
}); });

@ -649,6 +649,10 @@ define([
var toClean; var toClean;
var addToClean = function (obj, idx, el) { var addToClean = function (obj, idx, el) {
if (typeof(obj) !== "object") { toClean.push(idx); return; } if (typeof(obj) !== "object") { toClean.push(idx); return; }
// shared folders have their own userObject
if (exp.isSharedFolder(obj.element)) { return; }
if (!exp.isFile(obj.element, true) && if (!exp.isFile(obj.element, true) &&
!exp.isFolder(obj.element)) { toClean.push(idx); return; } !exp.isFolder(obj.element)) { toClean.push(idx); return; }
if (!Array.isArray(obj.path)) { toClean.push(idx); return; } if (!Array.isArray(obj.path)) { toClean.push(idx); return; }
@ -841,7 +845,7 @@ define([
if (sharedFolder) { return; } if (sharedFolder) { return; }
if (typeof(files[SHARED_FOLDERS]) !== "object") { debug("SHARED_FOLDER was not an object"); files[SHARED_FOLDERS] = {}; } if (typeof(files[SHARED_FOLDERS]) !== "object") { debug("SHARED_FOLDER was not an object"); files[SHARED_FOLDERS] = {}; }
var sf = files[SHARED_FOLDERS]; var sf = files[SHARED_FOLDERS];
var rootFiles = exp.getFiles([ROOT]); var rootFiles = exp.getFiles([ROOT, TRASH]);
var root = exp.find([ROOT]); var root = exp.find([ROOT]);
var parsed /*, secret */, el; var parsed /*, secret */, el;
for (var id in sf) { for (var id in sf) {

Loading…
Cancel
Save