From f83ad50f4030e08928af29bcd905b3b1c510c3d6 Mon Sep 17 00:00:00 2001 From: Tamara Steinwender <tamara.steinwender@tugraz.at> Date: Tue, 12 Jul 2022 14:08:56 +0200 Subject: [PATCH] Fix replace file upload bug --- .../src/i18n/de/translation.json | 4 ++- .../src/i18n/en/translation.json | 4 ++- .../src/nextcloud-file-picker.js | 26 ++++++++++++++++--- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/packages/file-handling/src/i18n/de/translation.json b/packages/file-handling/src/i18n/de/translation.json index 0c087610..1279d935 100644 --- a/packages/file-handling/src/i18n/de/translation.json +++ b/packages/file-handling/src/i18n/de/translation.json @@ -136,7 +136,9 @@ "something-went-wrong": "Etwas ist schief gelaufen. Bitte verbinden Sie sich erneut.", "upload-to": "Es wird nach {{- path}} hochgeladen ...", "webdav-error": "Etwas ist schief gelaufen: {{error}}", - "file-error": "Die Datei \"{{file}}\" ist fehlerhaft und konnte nicht hochgeladen werden." + "file-error": "Das Dateiformat wird nicht unterstützt oder die Datei ist fehlerhaft und konnte nicht hochgeladen werden.", + "forbidden": "Sie sind nicht berechtigt, diese Aktion in diesem Ordner auszuführen.", + "file-upload-error": "Entschuldigung, etwas ist schief gelaufen. Bitte versuchen Sie es später noch einmal." }, "upload-label": "Dateiauswahl" } diff --git a/packages/file-handling/src/i18n/en/translation.json b/packages/file-handling/src/i18n/en/translation.json index 071724f2..3cea0b10 100644 --- a/packages/file-handling/src/i18n/en/translation.json +++ b/packages/file-handling/src/i18n/en/translation.json @@ -136,7 +136,9 @@ "something-went-wrong": "Something went wrong. Please reload.", "upload-to": "Uploading to {{- path}} ...", "webdav-error": "Something went wrong", - "file-error": "The file \"{{file}}\" is corrupt and could not be uploaded." + "file-error": "The file format is not supported or the file is corrupt and could not be uploaded.", + "forbidden": "You don't have permissions to perform this action in this folder.", + "file-upload-error": "Sorry, something went wrong. Please try again later." }, "upload-label": "Select some files" } diff --git a/packages/file-handling/src/nextcloud-file-picker.js b/packages/file-handling/src/nextcloud-file-picker.js index 87d77aca..28aa479b 100644 --- a/packages/file-handling/src/nextcloud-file-picker.js +++ b/packages/file-handling/src/nextcloud-file-picker.js @@ -1637,14 +1637,32 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { } }) .catch((error) => { - this.statusText = i18n.t('nextcloud-file-picker.file-error', {file: file.name}); + this.loading = false; + if(error.response && error.response.status) { + switch (error.response.status) { + case 403: + this.statusText = i18n.t('nextcloud-file-picker.forbidden'); + return; + case 415: + this.statusText = i18n.t('nextcloud-file-picker.file-error'); + this.sendSetPropertyEvent('analytics-event', { + category: 'FileHandlingNextcloud', + action: 'UploadFilesPutfilesError', + name: "415", + }); + return; + default: + break; + } + } + + this.statusText = i18n.t('nextcloud-file-picker.file-upload-error'); this.sendSetPropertyEvent('analytics-event', { category: 'FileHandlingNextcloud', action: 'UploadFilesPutfilesError', - name: "", + name: error, }); - this.loading = false; - throw error; + console.error(error); }); } else { this.loadDirectory(this.directoryPath); -- GitLab