drag DirectoryEntry onto directory to move

This commit is contained in:
2025-07-29 22:14:45 +02:00
parent b1409b44d1
commit 2c834eb42b
3 changed files with 87 additions and 2 deletions

View File

@@ -300,3 +300,49 @@ export async function fetchFile(
data: data.value,
};
}
export async function moveFile(
warrenId: string,
path: string,
fileName: string,
targetPath: string
): Promise<{ success: boolean }> {
if (!path.endsWith('/')) {
path += '/';
}
path += fileName;
if (!targetPath.endsWith('/')) {
targetPath += '/';
}
targetPath += fileName;
const { status } = await useFetch(getApiUrl(`warrens/files/mv`), {
method: 'POST',
headers: getApiHeaders(),
body: JSON.stringify({
warrenId,
path,
targetPath,
}),
});
if (status.value !== 'success') {
toast.error('Move', {
id: 'MOVE_FILE_TOAST',
description: `Failed to move ${fileName}`,
});
return { success: false };
}
await refreshNuxtData('current-directory');
toast.success('Rename', {
id: 'RENAME_FILE_TOAST',
description: `Successfully moved ${fileName} to ${targetPath}`,
});
return {
success: true,
};
}