From 3af60f74e1bb43c779d660bda187d780b677188e Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Thu, 22 Oct 2020 20:22:56 -0300 Subject: [PATCH] 15685: Avoids the webdav service to report server error responses as success. This makes the rename file dialog code to report errors correctly. Probably will fix other file managing issues. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- src/common/webdav.ts | 4 +++- .../collection-panel-files/collection-panel-files-actions.ts | 2 +- .../rename-file-dialog/rename-file-dialog.tsx | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/common/webdav.ts b/src/common/webdav.ts index 17032768..b51cff30 100644 --- a/src/common/webdav.ts +++ b/src/common/webdav.ts @@ -85,14 +85,16 @@ export class WebDAV { r.upload.addEventListener('progress', config.onUploadProgress); } + // This event gets triggered on *any* server response r.addEventListener('load', () => { - if (r.status === 404) { + if (r.status >= 400) { return reject(r); } else { return resolve(r); } }); + // This event gets triggered on network errors r.addEventListener('error', () => { return reject(r); }); diff --git a/src/store/collection-panel/collection-panel-files/collection-panel-files-actions.ts b/src/store/collection-panel/collection-panel-files/collection-panel-files-actions.ts index 704e2999..19f5a7ee 100644 --- a/src/store/collection-panel/collection-panel-files/collection-panel-files-actions.ts +++ b/src/store/collection-panel/collection-panel-files/collection-panel-files-actions.ts @@ -146,7 +146,7 @@ export const renameFile = (newName: string) => dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'File name changed.', hideDuration: 2000 })); } catch (e) { const errors: FormErrors = { - name: 'Could not rename the file' + name: `Could not rename the file: ${e.responseText}` }; dispatch(stopSubmit(RENAME_FILE_DIALOG, errors)); } diff --git a/src/views-components/rename-file-dialog/rename-file-dialog.tsx b/src/views-components/rename-file-dialog/rename-file-dialog.tsx index 1a806511..d05c110b 100644 --- a/src/views-components/rename-file-dialog/rename-file-dialog.tsx +++ b/src/views-components/rename-file-dialog/rename-file-dialog.tsx @@ -37,5 +37,5 @@ const RenameDialogFormFields = (props: WithDialogProps) => component={TextField} autoFocus={true} /> - + ; -- 2.30.2