javascript: add a helpful message on connectivity error

This commit is contained in:
Pierre de La Morinerie 2020-04-15 16:34:25 +02:00
parent 432967bd76
commit 55788990da

View file

@ -1,5 +1,6 @@
import Uploader from '../../shared/activestorage/uploader'; import Uploader from '../../shared/activestorage/uploader';
import { show, hide, toggle } from '@utils'; import { show, hide, toggle } from '@utils';
import { FAILURE_CONNECTIVITY } from '../../shared/activestorage/file-upload-error';
// Given a file input in a champ with a selected file, upload a file, // Given a file input in a champ with a selected file, upload a file,
// then attach it to the dossier. // then attach it to the dossier.
@ -61,11 +62,18 @@ export default class AutoUploadController {
let message = error.message || error.toString(); let message = error.message || error.toString();
let canRetry = error.status && error.status != 422; let canRetry = error.status && error.status != 422;
if (error.failureReason == FAILURE_CONNECTIVITY) {
return { return {
title: 'Le fichier na pas pu être envoyé.', title: 'Le fichier na pas pu être envoyé.',
description: message, description: 'Vérifiez votre connexion à Internet, puis ré-essayez.',
retry: canRetry retry: true
};
} else {
return {
title: 'Le fichier na pas pu être envoyé.',
description: message,
retry: canRetry
};
} }
} }