mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Merge pull request #3928 from Ocelot-Social-Community/allow-only-supported-file-formats
feat: 🍰 Allow Only Supported Image File Formats
This commit is contained in:
commit
f1346b595a
@ -27,11 +27,18 @@ describe('ImageUploader.vue', () => {
|
|||||||
beforeEach(() => jest.useFakeTimers())
|
beforeEach(() => jest.useFakeTimers())
|
||||||
const message = 'File upload failed'
|
const message = 'File upload failed'
|
||||||
const fileError = { status: 'error' }
|
const fileError = { status: 'error' }
|
||||||
|
const unSupportedFileMessage =
|
||||||
|
'Please upload an image of file format : JPG , JPEG , PNG or GIF'
|
||||||
|
|
||||||
it('shows an error toaster when verror is called', () => {
|
it('shows an error toaster when verror is called', () => {
|
||||||
wrapper.vm.onDropzoneError(fileError, message)
|
wrapper.vm.onDropzoneError(fileError, message)
|
||||||
expect(mocks.$toast.error).toHaveBeenCalledWith(fileError.status, message)
|
expect(mocks.$toast.error).toHaveBeenCalledWith(fileError.status, message)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('shows an error toaster when unSupported file is uploaded', () => {
|
||||||
|
wrapper.vm.onUnSupportedFormat(fileError.status, unSupportedFileMessage)
|
||||||
|
expect(mocks.$toast.error).toHaveBeenCalledWith(fileError.status, unSupportedFileMessage)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -65,6 +65,7 @@ export default {
|
|||||||
url: () => '',
|
url: () => '',
|
||||||
maxFilesize: 5.0,
|
maxFilesize: 5.0,
|
||||||
previewTemplate: '<span class="no-preview" />',
|
previewTemplate: '<span class="no-preview" />',
|
||||||
|
acceptedFiles: '.png,.jpg,.jpeg,.gif',
|
||||||
},
|
},
|
||||||
cropper: null,
|
cropper: null,
|
||||||
file: null,
|
file: null,
|
||||||
@ -76,7 +77,20 @@ export default {
|
|||||||
onDropzoneError(file, message) {
|
onDropzoneError(file, message) {
|
||||||
this.$toast.error(file.status, message)
|
this.$toast.error(file.status, message)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onUnSupportedFormat(status, message) {
|
||||||
|
this.$toast.error(status, message)
|
||||||
|
},
|
||||||
initCropper(file) {
|
initCropper(file) {
|
||||||
|
const supportedFormats = ['image/jpg', 'image/jpeg', 'image/png', 'image/gif']
|
||||||
|
|
||||||
|
if (supportedFormats.indexOf(file.type) < 0) {
|
||||||
|
this.onUnSupportedFormat(
|
||||||
|
'error',
|
||||||
|
this.$t('contribution.teaserImage.errors.unSupported-file-format'),
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
this.showCropper = true
|
this.showCropper = true
|
||||||
this.file = file
|
this.file = file
|
||||||
|
|
||||||
|
|||||||
@ -214,6 +214,9 @@
|
|||||||
"success": "Gespeichert!",
|
"success": "Gespeichert!",
|
||||||
"teaserImage": {
|
"teaserImage": {
|
||||||
"cropperConfirm": "Bestätigen",
|
"cropperConfirm": "Bestätigen",
|
||||||
|
"errors": {
|
||||||
|
"unSupported-file-format": "Bitte lade ein Bild in den folgenden Formaten hoch: JPG, JPEG, PNG or GIF!"
|
||||||
|
},
|
||||||
"supportedFormats": "Füge ein Bild im Dateiformat JPG, PNG oder GIF ein"
|
"supportedFormats": "Füge ein Bild im Dateiformat JPG, PNG oder GIF ein"
|
||||||
},
|
},
|
||||||
"title": "Titel"
|
"title": "Titel"
|
||||||
|
|||||||
@ -214,6 +214,9 @@
|
|||||||
"success": "Saved!",
|
"success": "Saved!",
|
||||||
"teaserImage": {
|
"teaserImage": {
|
||||||
"cropperConfirm": "Confirm",
|
"cropperConfirm": "Confirm",
|
||||||
|
"errors": {
|
||||||
|
"unSupported-file-format": "Please upload an image of file format: JPG, JPEG, PNG or GIF!"
|
||||||
|
},
|
||||||
"supportedFormats": "Insert a picture of file format JPG, PNG or GIF"
|
"supportedFormats": "Insert a picture of file format JPG, PNG or GIF"
|
||||||
},
|
},
|
||||||
"title": "Title"
|
"title": "Title"
|
||||||
|
|||||||
@ -209,7 +209,7 @@
|
|||||||
"success": "¡Guardado!",
|
"success": "¡Guardado!",
|
||||||
"teaserImage": {
|
"teaserImage": {
|
||||||
"cropperConfirm": "Confirmar",
|
"cropperConfirm": "Confirmar",
|
||||||
"supportedFormats": "Insertar una imagen de formato de archivo JPG, PNG o GIF"
|
"supportedFormats": "Insertar una imagen de formato de archivo JPG, PNG o GIF!"
|
||||||
},
|
},
|
||||||
"title": "Título"
|
"title": "Título"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -209,7 +209,7 @@
|
|||||||
"success": "Enregistré!",
|
"success": "Enregistré!",
|
||||||
"teaserImage": {
|
"teaserImage": {
|
||||||
"cropperConfirm": "Confirmer",
|
"cropperConfirm": "Confirmer",
|
||||||
"supportedFormats": "Insérer une image au format de fichier JPG, PNG ou GIF"
|
"supportedFormats": "Insérer une image au format de fichier JPG, PNG ou GIF!"
|
||||||
},
|
},
|
||||||
"title": "Titre"
|
"title": "Titre"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -215,7 +215,7 @@
|
|||||||
"success": null,
|
"success": null,
|
||||||
"teaserImage": {
|
"teaserImage": {
|
||||||
"cropperConfirm": "Confermare",
|
"cropperConfirm": "Confermare",
|
||||||
"supportedFormats": "Inserisci un'immagine in formato file JPG, PNG o GIF"
|
"supportedFormats": "Inserisci un'immagine in formato file JPG, PNG o GIF!"
|
||||||
},
|
},
|
||||||
"title": null
|
"title": null
|
||||||
},
|
},
|
||||||
|
|||||||
@ -69,7 +69,7 @@
|
|||||||
"edit": "Bijdrage bewerken",
|
"edit": "Bijdrage bewerken",
|
||||||
"teaserImage": {
|
"teaserImage": {
|
||||||
"cropperConfirm": "Bevestigen",
|
"cropperConfirm": "Bevestigen",
|
||||||
"supportedFormats": "Voeg een afbeelding in met het bestandsformaat JPG, PNG of GIF"
|
"supportedFormats": "Voeg een afbeelding in met het bestandsformaat JPG, PNG of GIF!"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"disable": {
|
"disable": {
|
||||||
|
|||||||
@ -120,7 +120,7 @@
|
|||||||
"success": "Zapisano!",
|
"success": "Zapisano!",
|
||||||
"teaserImage": {
|
"teaserImage": {
|
||||||
"cropperConfirm": "Potwierdzać",
|
"cropperConfirm": "Potwierdzać",
|
||||||
"supportedFormats": "Wstaw zdjęcie w formacie pliku JPG, PNG lub GIF"
|
"supportedFormats": "Wstaw zdjęcie w formacie pliku JPG, PNG lub GIF!"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"delete": {
|
"delete": {
|
||||||
|
|||||||
@ -253,7 +253,7 @@
|
|||||||
"success": "Salvo!",
|
"success": "Salvo!",
|
||||||
"teaserImage": {
|
"teaserImage": {
|
||||||
"cropperConfirm": "Confirmar",
|
"cropperConfirm": "Confirmar",
|
||||||
"supportedFormats": "Insira uma imagem do formato JPG, PNG ou GIF"
|
"supportedFormats": "Insira uma imagem do formato JPG, PNG ou GIF!"
|
||||||
},
|
},
|
||||||
"title": "Título"
|
"title": "Título"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -209,7 +209,7 @@
|
|||||||
"success": "Сохранено!",
|
"success": "Сохранено!",
|
||||||
"teaserImage": {
|
"teaserImage": {
|
||||||
"cropperConfirm": "Подтвердить",
|
"cropperConfirm": "Подтвердить",
|
||||||
"supportedFormats": "Вставьте изображение файла формата JPG, PNG или GIF"
|
"supportedFormats": "Вставьте изображение файла формата JPG, PNG или GIF!"
|
||||||
},
|
},
|
||||||
"title": "Заголовок"
|
"title": "Заголовок"
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user