From f69331e49d19a26be27d1188f721703fe04a493d Mon Sep 17 00:00:00 2001 From: rinpatch Date: Sat, 8 Dec 2018 22:36:54 +0100 Subject: [PATCH] Improve error messages --- src/components/media_upload/media_upload.js | 4 ++-- src/components/post_status_form/post_status_form.js | 6 +++--- src/i18n/en.json | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/components/media_upload/media_upload.js b/src/components/media_upload/media_upload.js index c2f3c3c718..91ae36274e 100644 --- a/src/components/media_upload/media_upload.js +++ b/src/components/media_upload/media_upload.js @@ -22,7 +22,7 @@ const mediaUpload = { const self = this const store = this.$store if (file.size > store.state.instance.uploadlimit) { - self.$emit('upload-failed', 'upload_error_file_too_big') + self.$emit('upload-failed', 'upload_error_file_too_big', {filesize: file.size, allowedsize: store.state.instance.uploadlimit}) return } const formData = new FormData() @@ -36,7 +36,7 @@ const mediaUpload = { self.$emit('uploaded', fileData) self.uploading = false }, (error) => { // eslint-disable-line handle-callback-err - self.$emit('upload-failed') + self.$emit('upload-failed', 'upload_error_generic') self.uploading = false }) }, diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index f7ba3cd5cd..5f092da355 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -262,9 +262,9 @@ const PostStatusForm = { let index = this.newStatus.files.indexOf(fileInfo) this.newStatus.files.splice(index, 1) }, - uploadFailed (errString) { - errString = errString || 'upload_error' - this.error = this.$t('post_status.' + errString) + uploadFailed (errString, templateArgs) { + templateArgs = templateArgs || {}; + this.error = this.$t('post_status.upload_error') + ' ' + this.$t('post_status.' + errString, templateArgs) this.enableSubmit() }, disableSubmit () { diff --git a/src/i18n/en.json b/src/i18n/en.json index 93a2474313..17c28c6171 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -53,7 +53,8 @@ "account_not_locked_warning_link": "locked", "attachments_sensitive": "Mark attachments as sensitive", "upload_error": "Upload failed.", - "upload_error_file_too_big": "Upload failed. File too big", + "upload_error_file_too_big": "File too big [{filesize}/{allowedsize}]", + "upload_error_generic": "Try again later", "content_type": { "plain_text": "Plain text" },