summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFatih Acet <acetfatih@gmail.com>2016-06-21 00:05:33 +0300
committerFatih Acet <acetfatih@gmail.com>2016-06-21 22:20:42 +0300
commit1898cb03d0c31534d8d82ef389e6858e1e6c6185 (patch)
tree046f52b94743b69b85725bf4a9f7f64a9324b03f
parent2527ae6c60bbd230ccca11ef24deec24cdc50742 (diff)
downloadgitlab-ce-global-ajax-error-handler.tar.gz
Added global ajax error handler to show a flash notification for failed requests.global-ajax-error-handler
-rw-r--r--CHANGELOG1
-rw-r--r--app/assets/javascripts/application.js.coffee9
2 files changed, 10 insertions, 0 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 118dd79dda6..a4709f7fa82 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -145,6 +145,7 @@ v 8.9.0 (unreleased)
- Filter parameters for request_uri value on instrumented transactions.
- Remove duplicated keys add UNIQUE index to keys fingerprint column
- ExtractsPath get ref_names from repository cache, if not there access git.
+ - Show a flash warning about the error detail of XHR requests which failed with status code 404 and 500
- Cache user todo counts from TodoService
- Ensure Todos counters doesn't count Todos for projects pending delete
- Add left/right arrows horizontal navigation
diff --git a/app/assets/javascripts/application.js.coffee b/app/assets/javascripts/application.js.coffee
index 0206db461da..0b68612430d 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')