From 55788990da1c3be5390c2f2d4bc1d1cab2d9eb5e Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 15 Apr 2020 16:34:25 +0200 Subject: [PATCH] javascript: add a helpful message on connectivity error --- .../dossiers/auto-upload-controller.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/app/javascript/new_design/dossiers/auto-upload-controller.js b/app/javascript/new_design/dossiers/auto-upload-controller.js index 5ac04e7ad..a2780a65e 100644 --- a/app/javascript/new_design/dossiers/auto-upload-controller.js +++ b/app/javascript/new_design/dossiers/auto-upload-controller.js @@ -1,5 +1,6 @@ import Uploader from '../../shared/activestorage/uploader'; 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, // then attach it to the dossier. @@ -61,11 +62,18 @@ export default class AutoUploadController { let message = error.message || error.toString(); let canRetry = error.status && error.status != 422; - - return { - title: 'Le fichier n’a pas pu être envoyé.', - description: message, - retry: canRetry + if (error.failureReason == FAILURE_CONNECTIVITY) { + return { + title: 'Le fichier n’a pas pu être envoyé.', + description: 'Vérifiez votre connexion à Internet, puis ré-essayez.', + retry: true + }; + } else { + return { + title: 'Le fichier n’a pas pu être envoyé.', + description: message, + retry: canRetry + }; } }