diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2016-06-30 16:05:03 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2016-06-30 16:05:03 +0300 |
commit | 99e5ae10bebfcb8e26117426bb773fcd531c45f1 (patch) | |
tree | 47d20fda309938db4b72b74c214dd8356b525da4 /app/assets | |
parent | 1c2e7af6afa4be48c4d95e3b5de8005746db9bc7 (diff) | |
parent | 1898cb03d0c31534d8d82ef389e6858e1e6c6185 (diff) |
Merge branch 'global-ajax-error-handler' into 'master'
Global Ajax error handler
## What does this MR do?
Introduces a new global Ajax error handler to show a flash warning about the error detail of XHR requests which failed with status code 404 and 500
## Are there points in the code the reviewer needs to double check?
Double check the wording.
## Why was this MR needed?
A global solution for the problem in the #17880
## What are the relevant issue numbers?
Fixes #17880
## Screenshots (if relevant)
For requests failed with 404 - 500
![Screen_Shot_2016-06-21_at_00.07.26](/uploads/04bb3a5a958c3d21aef4fd12bd3d105a/Screen_Shot_2016-06-21_at_00.07.26.png)
For requests failed with 401
![Screen_Shot_2016-06-21_at_00.08.30](/uploads/25cc885ba388f4c6f4c555fa338e1a63/Screen_Shot_2016-06-21_at_00.08.30.png)
See merge request !4797
Diffstat (limited to 'app/assets')
-rw-r--r-- | app/assets/javascripts/application.js.coffee | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/app/assets/javascripts/application.js.coffee b/app/assets/javascripts/application.js.coffee index b6dbf2d0cc1..f936b6116cd 100644 --- a/app/assets/javascripts/application.js.coffee +++ b/app/assets/javascripts/application.js.coffee @@ -185,6 +185,15 @@ $ -> else buttons.enable() + $(document).ajaxError (e, xhrObj, xhrSetting, xhrErrorText) -> + + if xhrObj.status is 401 + new Flash 'You need to be logged in.', 'alert' + + else if xhrObj.status in [ 404, 500 ] + new Flash 'Something went wrong on our end.', 'alert' + + # Show/Hide the profile menu when hovering the account box $('.account-box').hover -> $(@).toggleClass('hover') |