delete multiple files with selection

This commit is contained in:
2025-09-04 16:26:23 +02:00
parent 49b4162448
commit 8b2ed0e700
17 changed files with 250 additions and 137 deletions

View File

@@ -87,6 +87,40 @@ export async function createDirectory(
return { success: true };
}
export async function warrenRm(
warrenId: string,
paths: string[],
force: boolean
): Promise<{ success: boolean }> {
const { status } = await useFetch(getApiUrl(`warrens/files/rm`), {
method: 'POST',
headers: getApiHeaders(),
body: JSON.stringify({
warrenId,
paths,
force,
}),
});
const TOAST_TITLE = 'Delete';
if (status.value !== 'success') {
toast.error(TOAST_TITLE, {
id: 'WARREN_RM_TOAST',
description: `Failed to delete directory`,
});
return { success: false };
}
await refreshNuxtData('current-directory');
toast.success(TOAST_TITLE, {
id: 'WARREN_RM_TOAST',
description: `Successfully deleted files`,
});
return { success: true };
}
export async function deleteWarrenDirectory(
warrenId: string,
path: string,
@@ -104,7 +138,7 @@ export async function deleteWarrenDirectory(
headers: getApiHeaders(),
body: JSON.stringify({
warrenId,
path,
paths: [path],
force,
}),
});
@@ -113,7 +147,7 @@ export async function deleteWarrenDirectory(
if (status.value !== 'success') {
toast.error(TOAST_TITLE, {
id: 'DELETE_DIRECTORY_TOAST',
id: 'WARREN_RM_TOAST',
description: `Failed to delete directory`,
});
return { success: false };
@@ -122,7 +156,7 @@ export async function deleteWarrenDirectory(
await refreshNuxtData('current-directory');
toast.success(TOAST_TITLE, {
id: 'DELETE_DIRECTORY_TOAST',
id: 'WARREN_RM_TOAST',
description: `Successfully deleted ${directoryName}`,
});
return { success: true };
@@ -144,7 +178,7 @@ export async function deleteWarrenFile(
headers: getApiHeaders(),
body: JSON.stringify({
warrenId,
path,
paths: [path],
force: false,
}),
});
@@ -153,7 +187,7 @@ export async function deleteWarrenFile(
if (status.value !== 'success') {
toast.error(TOAST_TITLE, {
id: 'DELETE_FILE_TOAST',
id: 'WARREN_RM_TOAST',
description: `Failed to delete file`,
});
return { success: false };
@@ -162,7 +196,7 @@ export async function deleteWarrenFile(
await refreshNuxtData('current-directory');
toast.success(TOAST_TITLE, {
id: 'DELETE_FILE_TOAST',
id: 'WARREN_RM_TOAST',
description: `Successfully deleted ${fileName}`,
});
return { success: true };