Folder move added
This commit is contained in:
+42
-4
@@ -259,6 +259,30 @@ function baseName(path) {
|
||||
return index >= 0 ? path.slice(index + 1) : path;
|
||||
}
|
||||
|
||||
function rootKeyFromPath(path) {
|
||||
const normalized = (path || "").trim();
|
||||
if (!normalized) {
|
||||
return null;
|
||||
}
|
||||
if (normalized.startsWith("/")) {
|
||||
const segments = normalized.split("/").filter(Boolean);
|
||||
if (segments.length < 2) {
|
||||
return normalized;
|
||||
}
|
||||
return `/${segments[0]}/${segments[1]}`;
|
||||
}
|
||||
return normalized.split("/")[0];
|
||||
}
|
||||
|
||||
function isNestedPath(sourcePath, destinationPath) {
|
||||
const source = (sourcePath || "").replace(/\/+$/, "");
|
||||
const destination = (destinationPath || "").replace(/\/+$/, "");
|
||||
if (!source || !destination) {
|
||||
return false;
|
||||
}
|
||||
return destination.startsWith(`${source}/`);
|
||||
}
|
||||
|
||||
function renderBreadcrumbs(pane, path) {
|
||||
const nav = document.getElementById(`${pane}-breadcrumbs`);
|
||||
nav.innerHTML = "";
|
||||
@@ -892,6 +916,12 @@ function showDirectoryMoveNotSupported() {
|
||||
setStatus(message);
|
||||
}
|
||||
|
||||
function showBatchDirectoryMoveNotSupported() {
|
||||
const message = "Batch directory move is not supported in v1";
|
||||
setError("actions-error", message);
|
||||
setStatus(message);
|
||||
}
|
||||
|
||||
function resetRenameMoveState() {
|
||||
renameMoveState = {
|
||||
source: null,
|
||||
@@ -965,7 +995,7 @@ function openF6Flow() {
|
||||
return openRenameMovePopup();
|
||||
}
|
||||
if (selectedItems.some((item) => item.kind !== "file")) {
|
||||
showDirectoryMoveNotSupported();
|
||||
showBatchDirectoryMoveNotSupported();
|
||||
return true;
|
||||
}
|
||||
return openBatchMovePopup(selectedItems);
|
||||
@@ -991,9 +1021,17 @@ async function submitRenameMovePopup() {
|
||||
elements.error.textContent = "Destination must differ from source";
|
||||
return;
|
||||
}
|
||||
if (source.kind === "directory" && destinationParent !== sourceParent) {
|
||||
elements.error.textContent = "Directory move is not supported in v1";
|
||||
return;
|
||||
if (source.kind === "directory") {
|
||||
if (isNestedPath(source.path, destination)) {
|
||||
elements.error.textContent = "Destination cannot be inside source";
|
||||
return;
|
||||
}
|
||||
if (destinationParent !== sourceParent) {
|
||||
if (rootKeyFromPath(destination) !== rootKeyFromPath(source.path)) {
|
||||
elements.error.textContent = "Cross-root directory move is not supported in v1";
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user