Show the error when selecting a folder fails in FilesDialog

Selecting a folder lists it recursively. When the server refuses that listing, the dialog stayed on Loading, kept the folder selected and showed no error.
This commit is contained in:
Arash
2026-10-15 10:04:03 +02:00
parent 92e66c5339
commit 9cdcb8a7ab
2 changed files with 38 additions and 14 deletions
@@ -261,6 +261,22 @@ describe("FilesDialog, file mode", () => {
await utils.navigateBack();
expect(utils.getRenderedRows().length).toBe(rootResponse.length);
});
it("should show the error and undo the selection when a recursive listing fails", async () => {
await utils.openRootDirectory();
server.use(
http.get("/api/remote_files", ({ response }) => {
return response("4XX").json({ err_msg: someErrorText, err_code: 400 }, { status: 400 });
}),
);
suppressDebugConsole(); // expecting error message.
await utils.clickOn(utils.findRenderedDirectory(directoryId));
utils.expectErrorMessage();
expect(utils.getSelectionDialog().props("isBusy")).toBe(false);
utils.expectOkButtonDisabled();
});
});
describe("FilesDialog, create new file source button", () => {
@@ -182,21 +182,29 @@ function selectDirectoryRecursive(record: SelectionItem) {
// look for subdirectories
const recursive = true;
isBusy.value = true;
browseRemoteFiles(record.url, recursive).then((incoming) => {
incoming.entries.forEach((item) => {
// construct record
const subRecord = entryToRecord(item);
if (subRecord.isLeaf) {
// select file under this path
selectSingleRecord(subRecord, true);
} else {
// select subdirectory
selectedDirectories.value.push(subRecord);
}
browseRemoteFiles(record.url, recursive)
.then((incoming) => {
incoming.entries.forEach((item) => {
// construct record
const subRecord = entryToRecord(item);
if (subRecord.isLeaf) {
// select file under this path
selectSingleRecord(subRecord, true);
} else {
// select subdirectory
selectedDirectories.value.push(subRecord);
}
});
totalItems.value = incoming.totalMatches;
isBusy.value = false;
})
.catch((error) => {
// undo the directory selection made above
unselectPath(record.url, false, record.id);
formatRows();
errorMessage.value = errorMessageAsString(error);
isBusy.value = false;
});
totalItems.value = incoming.totalMatches;
isBusy.value = false;
});
}
}