Improve error messages

This commit is contained in:
rinpatch 2018-12-08 22:36:54 +01:00
parent 788383d8a1
commit f69331e49d
3 changed files with 7 additions and 6 deletions

View File

@ -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
})
},

View File

@ -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 () {

View File

@ -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"
},