mirror of
https://github.com/cryptpad/cryptpad.git
synced 2026-09-14 11:05:41 +05:00
Random keys for all folders
This commit is contained in:
parent
9ff8f6d4e3
commit
630d06726e
@ -4698,16 +4698,6 @@ define([
|
||||
// Auto-expand if explicitly marked as opened
|
||||
var shouldExpand = shouldBeOpened(path);
|
||||
|
||||
// Also expand if has opened children, but only when viewing this tree
|
||||
if (!shouldExpand && hasOpenedChild(path)) {
|
||||
// Check if we're currently viewing this tree (same root category)
|
||||
if (config.currentPath && config.rootPath &&
|
||||
config.currentPath.length > 0 && config.rootPath.length > 0 &&
|
||||
config.currentPath[0] === config.rootPath[0]) {
|
||||
shouldExpand = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldExpand) {
|
||||
$element.removeClass('cp-app-drive-element-collapsed');
|
||||
$collapse.empty().append($expandedIcon.clone());
|
||||
@ -4739,16 +4729,13 @@ define([
|
||||
var name = item.name || key;
|
||||
var newPath;
|
||||
if (item.navPath) {
|
||||
// Shared folder: derive path without root
|
||||
newPath = item.navPath.slice(0, -1);
|
||||
newPath = item.navPath;
|
||||
} else {
|
||||
// Regular folder: reconstruct from parent path
|
||||
// Fallback: reconstruct from parent path (for backwards compatibility)
|
||||
var p = path.slice();
|
||||
p.push(key);
|
||||
newPath = p;
|
||||
}
|
||||
|
||||
var pathForCurrentCheck = item.navPath || newPath;
|
||||
var $icon;
|
||||
if (item.icon) {
|
||||
if (typeof item.icon === 'string') {
|
||||
@ -4757,18 +4744,17 @@ define([
|
||||
$icon = $(item.icon);
|
||||
}
|
||||
} else {
|
||||
var shouldShowOpened = shouldBeOpened(pathForCurrentCheck);
|
||||
var shouldShowOpened = shouldBeOpened(newPath);
|
||||
$icon = shouldShowOpened ? $folderOpenedIcon.clone() : $folderIcon.clone();
|
||||
}
|
||||
|
||||
var hasSubfolder = item.content && Object.keys(item.content).length > 0;
|
||||
var isActive = config.currentPath && JSON.stringify(pathForCurrentCheck) === JSON.stringify(config.currentPath);
|
||||
var isActive = config.currentPath && JSON.stringify(newPath) === JSON.stringify(config.currentPath);
|
||||
var $element = createTreeElement(name, $icon.clone(), newPath, hasSubfolder, isActive);
|
||||
$element.appendTo($list);
|
||||
|
||||
if (hasSubfolder) {
|
||||
var pathForRecursion = item.navPath || newPath;
|
||||
createTree($element, item, pathForRecursion);
|
||||
createTree($element, item, newPath);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@ -2085,6 +2085,7 @@ define([
|
||||
if (sfId && folders[sfId] && folders[sfId].readOnly) {
|
||||
return void UI.warn(Messages.fm_forbidden);
|
||||
}
|
||||
|
||||
if (newPath[0] === TEMPLATE) {
|
||||
var oldPaths = data && JSON.parse(data).path;
|
||||
if (oldPaths && oldPaths.length) {
|
||||
@ -4587,25 +4588,28 @@ define([
|
||||
var isSharedFolder = manager.isSharedFolder(root[key]) && root[key];
|
||||
var sfId = manager.isInSharedFolder(newPath) || (isSharedFolder && root[key]);
|
||||
var $icon, isCurrentFolder, subfolder, folderName = key;
|
||||
var randomKey = Util.uid();
|
||||
var pathForRecursion = newPath;
|
||||
if (isSharedFolder) {
|
||||
var navPath = newPath.slice();
|
||||
navPath.push(manager.user.userObject.ROOT);
|
||||
isCurrentFolder = manager.comparePath(navPath, currentPath);
|
||||
// Subfolders?
|
||||
var newRoot = Util.find(manager, ['folders', sfId, 'proxy', manager.user.userObject.ROOT]) || {};
|
||||
subfolder = manager.hasSubfolder(newRoot);
|
||||
// Fix name
|
||||
var sfData = manager.getSharedFolderData(sfId);
|
||||
folderName = sfData.title || sfData.lastTitle || Messages.fm_deletedFolder;
|
||||
isCurrentFolder = manager.comparePath(navPath, currentPath);
|
||||
// Fix icon
|
||||
$icon = isCurrentFolder ? $sharedFolderOpenedIcon : $sharedFolderIcon;
|
||||
data.content[key] = {
|
||||
data.content[randomKey] = {
|
||||
name: folderName,
|
||||
icon: $icon,
|
||||
navPath: navPath,
|
||||
content: {}
|
||||
};
|
||||
isSharedFolder = sfId;
|
||||
pathForRecursion = navPath;
|
||||
} else {
|
||||
var isEmpty = manager.isFolderEmpty(root[key]);
|
||||
subfolder = manager.hasSubfolder(root[key]);
|
||||
@ -4613,10 +4617,10 @@ define([
|
||||
$icon = isEmpty ?
|
||||
(isCurrentFolder ? $folderOpenedEmptyIcon : $folderEmptyIcon) :
|
||||
(isCurrentFolder ? $folderOpenedIcon : $folderIcon);
|
||||
data.content[key] = {
|
||||
data.content[randomKey] = {
|
||||
name: folderName,
|
||||
icon: $icon,
|
||||
// path: NOT stored for regular folders
|
||||
navPath: newPath,
|
||||
content: {}
|
||||
};
|
||||
}
|
||||
@ -4625,9 +4629,7 @@ define([
|
||||
Util.find(manager, ['folders', sfId, 'proxy', manager.user.userObject.ROOT]) :
|
||||
root[key];
|
||||
if (subRoot) {
|
||||
// For shared folders, add ROOT to path for subfolders
|
||||
var pathForSubfolders = isSharedFolder ? navPath : newPath;
|
||||
data.content[key].content = buildTreeData(subRoot, pathForSubfolders, currentPath).content;
|
||||
data.content[randomKey].content = buildTreeData(subRoot, pathForRecursion, currentPath).content;
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -5145,29 +5147,36 @@ define([
|
||||
}
|
||||
var openRecursive = function (path, isSharedFolderRoot) {
|
||||
LS.setFolderOpened(path, opened);
|
||||
// For shared folders, we need to add root
|
||||
var pathForContent = isSharedFolderRoot ?
|
||||
path.concat(manager.user.userObject.ROOT) :
|
||||
path;
|
||||
var folderContent = manager.find(pathForContent);
|
||||
if (!folderContent) {
|
||||
return;
|
||||
}
|
||||
var subfolders = [];
|
||||
for (var k in folderContent) {
|
||||
if (manager.isFolder(folderContent[k])) {
|
||||
// Build the full path for each subfolder
|
||||
var subPath = pathForContent.slice();
|
||||
subPath.push(k);
|
||||
if (manager.isSharedFolder(folderContent[k])) {
|
||||
subfolders.push([k].concat(manager.user.userObject.ROOT));
|
||||
}
|
||||
else {
|
||||
subfolders.push(k);
|
||||
// Shared folders need ROOT appended
|
||||
subPath.push(manager.user.userObject.ROOT);
|
||||
}
|
||||
subfolders.push(subPath);
|
||||
}
|
||||
}
|
||||
subfolders.forEach(function (p) {
|
||||
var subPath = pathForContent.concat(p);
|
||||
subfolders.forEach(function (subPath) {
|
||||
openRecursive(subPath, false);
|
||||
});
|
||||
};
|
||||
openRecursive(initialPath, isInitialSharedFolder);
|
||||
refresh();
|
||||
if (!opened) {
|
||||
APP.displayDirectory(initialPath);
|
||||
} else {
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
else if ($this.hasClass('cp-app-drive-context-download')) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user