(parentPath, name, isBulkDeleting = false)
| 375 | document.body.removeChild(link); |
| 376 | } |
| 377 | async function onClickDeleteDirectory(parentPath, name, isBulkDeleting = false) { |
| 378 | if (isBulkDeleting || confirm('Are you sure you want to delete this directory?')) { |
| 379 | if (!isBulkDeleting && isDeleting.value) { |
| 380 | return; |
| 381 | } |
| 382 | isDeleting.value = true; |
| 383 | try { |
| 384 | const requestBody = { |
| 385 | parentPath, |
| 386 | name |
| 387 | }; |
| 388 | const response = await fetch(`/api/files/delete-directory`, { |
| 389 | method: 'POST', |
| 390 | body: JSON.stringify(requestBody) |
| 391 | }); |
| 392 | if (!response.ok) { |
| 393 | throw new Error(`Failed to delete directory. ${response.statusText} ${await response.text()}`); |
| 394 | } |
| 395 | const result = await response.json(); |
| 396 | if (!result.success) { |
| 397 | throw new Error('Failed to delete directory!'); |
| 398 | } |
| 399 | directories.value = [...result.newDirectories]; |
| 400 | } catch (error) { |
| 401 | console.error(error); |
| 402 | } |
| 403 | isDeleting.value = false; |
| 404 | } |
| 405 | } |
| 406 | async function onClickDeleteFile(parentPath, name, isBulkDeleting = false) { |
| 407 | if (isBulkDeleting || confirm('Are you sure you want to delete this file?')) { |
| 408 | if (!isBulkDeleting && isDeleting.value) { |
no test coverage detected