Add dummy convert folder to shared folder

pull/1/head
ClemDee 5 years ago
parent 0636714829
commit e949c2a6f7

@ -1071,6 +1071,13 @@ define([
} }
return Env.user.userObject.hasSubfolder(el, trashRoot); return Env.user.userObject.hasSubfolder(el, trashRoot);
}; };
var hasSubSharedFolder = function (Env, el, trashRoot) {
if (Env.folders[el]) {
var uo = Env.folders[el].userObject;
return uo.hasSubSharedFolder(uo.find[uo.ROOT]);
}
return Env.user.userObject.hasSubSharedFolder(el, trashRoot);
};
var hasFile = function (Env, el, trashRoot) { var hasFile = function (Env, el, trashRoot) {
if (Env.folders[el]) { if (Env.folders[el]) {
var uo = Env.folders[el].userObject; var uo = Env.folders[el].userObject;
@ -1140,6 +1147,7 @@ define([
isInTrashRoot: callWithEnv(isInTrashRoot), isInTrashRoot: callWithEnv(isInTrashRoot),
comparePath: callWithEnv(comparePath), comparePath: callWithEnv(comparePath),
hasSubfolder: callWithEnv(hasSubfolder), hasSubfolder: callWithEnv(hasSubfolder),
hasSubSharedFolder: callWithEnv(hasSubSharedFolder),
hasFile: callWithEnv(hasFile), hasFile: callWithEnv(hasFile),
// Data // Data
user: Env.user, user: Env.user,

@ -156,6 +156,20 @@ define([
} }
}; };
exp.hasSubSharedFolder = function (folder) {
for (var el in folder) {
if (isSharedFolder(folder[el])) {
return true;
}
else if (isFolder(folder[el])) {
if (exp.hasSubSharedFolder(folder[el])) {
return true;
}
}
}
return false;
}
// Get data from AllFiles (Cryptpad_RECENTPADS) // Get data from AllFiles (Cryptpad_RECENTPADS)
var getFileData = exp.getFileData = function (file) { var getFileData = exp.getFileData = function (file) {
if (!file) { return; } if (!file) { return; }

@ -996,6 +996,7 @@ define([
// Can't rename or delete root elements // Can't rename or delete root elements
hide.push('delete'); hide.push('delete');
hide.push('rename'); hide.push('rename');
hide.push('share');
hide.push('color'); hide.push('color');
} }
if (!$element.is('.cp-app-drive-element-owned')) { if (!$element.is('.cp-app-drive-element-owned')) {
@ -1022,8 +1023,9 @@ define([
} }
} else if ($element.is('.cp-app-drive-element-sharedf')) { } else if ($element.is('.cp-app-drive-element-sharedf')) {
if (containsFolder) { if (containsFolder) {
// More than 1 folder selected: cannot create a new subfolder // More than 1 shared folder selected: cannot create a new subfolder
hide.push('newfolder'); hide.push('newfolder');
hide.push('share');
hide.push('expandall'); hide.push('expandall');
hide.push('collapseall'); hide.push('collapseall');
} }
@ -1036,13 +1038,13 @@ define([
if (containsFolder) { if (containsFolder) {
// More than 1 folder selected: cannot create a new subfolder // More than 1 folder selected: cannot create a new subfolder
hide.push('newfolder'); hide.push('newfolder');
hide.push('share');
hide.push('expandall'); hide.push('expandall');
hide.push('collapseall'); hide.push('collapseall');
} }
containsFolder = true; containsFolder = true;
hide.push('openro'); hide.push('openro');
hide.push('properties'); hide.push('properties');
hide.push('share');
hide.push('hashtag'); hide.push('hashtag');
} }
// If we're in the trash, hide restore and properties for non-root elements // If we're in the trash, hide restore and properties for non-root elements
@ -3568,7 +3570,7 @@ define([
var parsed, modal; var parsed, modal;
var friends = common.getFriends(); var friends = common.getFriends();
if (manager.isSharedFolder(el)) { if (manager.isSharedFolder(el)) { // Shared Folder
data = manager.getSharedFolderData(el); data = manager.getSharedFolderData(el);
parsed = Hash.parsePadUrl(data.href); parsed = Hash.parsePadUrl(data.href);
modal = UIElements.createSFShareModal({ modal = UIElements.createSFShareModal({
@ -3582,7 +3584,27 @@ define([
editHash: parsed.hash editHash: parsed.hash
} }
}); });
} else { UI.openCustomModal(modal, {
wide: Object.keys(friends).length !== 0
});
} else if (manager.isFolder(el)) { // Folder
// if folder already contains SF
if (manager.isInSharedFolder(paths[0].path)) {
UI.alert(Messages.convertFolderToSF_SFParent || "Sharing this folder can't be done because it already in a Shared Folder. Please, move this folder elsewhere in order to continue", undefined, true);
}
// if folder is inside SF
else if (manager.hasSubSharedFolder(el)) {
UI.alert(Messages.convertFolderToSF_SFChildren || "Sharing this folder can't be done because it already contains one ore more Shared Folders. Please, remove those from this folder in order to continue.", undefined, true);
}
// if folder does not contains SF
else {
UI.confirm(Messages.convertFolderToSF_confirm || "In order to be shared, this folder must be converted into a shared folder. Proceed ?", function(res) {
if (!res) { return; }
if (paths[0].path.length <= 1) { return; } // if root
// convert folder to Shared Folder
});
}
} else { // File
data = manager.getFileData(el); data = manager.getFileData(el);
parsed = Hash.parsePadUrl(data.href); parsed = Hash.parsePadUrl(data.href);
var roParsed = Hash.parsePadUrl(data.roHref); var roParsed = Hash.parsePadUrl(data.roHref);
@ -3608,10 +3630,10 @@ define([
modal = padType === 'file' ? UIElements.createFileShareModal(padData) modal = padType === 'file' ? UIElements.createFileShareModal(padData)
: UIElements.createShareModal(padData); : UIElements.createShareModal(padData);
modal = UI.dialog.tabs(modal); modal = UI.dialog.tabs(modal);
UI.openCustomModal(modal, {
wide: Object.keys(friends).length !== 0
});
} }
UI.openCustomModal(modal, {
wide: Object.keys(friends).length !== 0
});
} }
else if ($(this).hasClass('cp-app-drive-context-newfolder')) { else if ($(this).hasClass('cp-app-drive-context-newfolder')) {
if (paths.length !== 1) { return; } if (paths.length !== 1) { return; }

Loading…
Cancel
Save