Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
9103afa0
Commit
9103afa0
authored
Sep 24, 2019
by
Winnie Hellmann
Committed by
Clement Ho
Sep 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Merge branch 'nfriend-dont-show-error-messages-on-browser-navigation-2' into 'master'"
This reverts merge request !16545
parent
cfeb9bc5
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
0 additions
and
84 deletions
+0
-84
app/assets/javascripts/lib/utils/axios_utils.js
app/assets/javascripts/lib/utils/axios_utils.js
+0
-15
app/assets/javascripts/lib/utils/suppress_ajax_errors_during_navigation.js
...ripts/lib/utils/suppress_ajax_errors_during_navigation.js
+0
-16
ee/changelogs/unreleased/nfriend-dont-show-error-messages-on-browser-navigation.yml
...friend-dont-show-error-messages-on-browser-navigation.yml
+0
-5
lib/gitlab/gon_helper.rb
lib/gitlab/gon_helper.rb
+0
-4
spec/frontend/lib/utils/suppress_ajax_errors_during_navigation_spec.js
.../lib/utils/suppress_ajax_errors_during_navigation_spec.js
+0
-37
spec/javascripts/frequent_items/components/app_spec.js
spec/javascripts/frequent_items/components/app_spec.js
+0
-7
No files found.
app/assets/javascripts/lib/utils/axios_utils.js
View file @
9103afa0
import
axios
from
'
axios
'
;
import
csrf
from
'
./csrf
'
;
import
suppressAjaxErrorsDuringNavigation
from
'
./suppress_ajax_errors_during_navigation
'
;
axios
.
defaults
.
headers
.
common
[
csrf
.
headerKey
]
=
csrf
.
token
;
// Used by Rails to check if it is a valid XHR request
...
...
@@ -26,20 +25,6 @@ axios.interceptors.response.use(
},
);
let
isUserNavigating
=
false
;
window
.
addEventListener
(
'
beforeunload
'
,
()
=>
{
isUserNavigating
=
true
;
});
// Ignore AJAX errors caused by requests
// being cancelled due to browser navigation
const
{
gon
}
=
window
;
const
featureFlagEnabled
=
gon
&&
gon
.
features
&&
gon
.
features
.
suppressAjaxNavigationErrors
;
axios
.
interceptors
.
response
.
use
(
response
=>
response
,
err
=>
suppressAjaxErrorsDuringNavigation
(
err
,
isUserNavigating
,
featureFlagEnabled
),
);
export
default
axios
;
/**
...
...
app/assets/javascripts/lib/utils/suppress_ajax_errors_during_navigation.js
deleted
100644 → 0
View file @
cfeb9bc5
/**
* An Axios error interceptor that suppresses AJAX errors caused
* by the request being cancelled when the user navigates to a new page
*/
export
default
(
err
,
isUserNavigating
,
featureFlagEnabled
)
=>
{
if
(
featureFlagEnabled
&&
isUserNavigating
&&
err
.
code
===
'
ECONNABORTED
'
)
{
// If the user is navigating away from the current page,
// prevent .then() and .catch() handlers from being
// called by returning a Promise that never resolves
return
new
Promise
(()
=>
{});
}
// The error is not related to browser navigation,
// so propagate the error
return
Promise
.
reject
(
err
);
};
ee/changelogs/unreleased/nfriend-dont-show-error-messages-on-browser-navigation.yml
deleted
100644 → 0
View file @
cfeb9bc5
---
title
:
Suppress error messages shown when navigating to a new page
merge_request
:
16545
author
:
type
:
fixed
lib/gitlab/gon_helper.rb
View file @
9103afa0
...
...
@@ -38,10 +38,6 @@ module Gitlab
gon
.
current_user_fullname
=
current_user
.
name
gon
.
current_user_avatar_url
=
current_user
.
avatar_url
end
# Initialize gon.features with any flags that should be
# made globally available to the frontend
push_frontend_feature_flag
(
:suppress_ajax_navigation_errors
,
default_enabled:
true
)
end
# Exposes the state of a feature flag to the frontend code.
...
...
spec/frontend/lib/utils/suppress_ajax_errors_during_navigation_spec.js
deleted
100644 → 0
View file @
cfeb9bc5
import
suppressAjaxErrorsDuringNavigation
from
'
~/lib/utils/suppress_ajax_errors_during_navigation
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
describe
(
'
suppressAjaxErrorsDuringNavigation
'
,
()
=>
{
const
OTHER_ERR_CODE
=
'
foo
'
;
const
NAV_ERR_CODE
=
'
ECONNABORTED
'
;
it
.
each
`
isFeatureFlagEnabled | isUserNavigating | code
${
false
}
|
${
false
}
|
${
OTHER_ERR_CODE
}
${
false
}
|
${
false
}
|
${
NAV_ERR_CODE
}
${
false
}
|
${
true
}
|
${
OTHER_ERR_CODE
}
${
false
}
|
${
true
}
|
${
NAV_ERR_CODE
}
${
true
}
|
${
false
}
|
${
OTHER_ERR_CODE
}
${
true
}
|
${
false
}
|
${
NAV_ERR_CODE
}
${
true
}
|
${
true
}
|
${
OTHER_ERR_CODE
}
`
(
'
should return a rejected Promise
'
,
({
isFeatureFlagEnabled
,
isUserNavigating
,
code
})
=>
{
const
err
=
{
code
};
const
actual
=
suppressAjaxErrorsDuringNavigation
(
err
,
isUserNavigating
,
isFeatureFlagEnabled
);
return
expect
(
actual
).
rejects
.
toBe
(
err
);
});
it
(
'
should return a Promise that never resolves
'
,
()
=>
{
const
err
=
{
code
:
NAV_ERR_CODE
};
const
actual
=
suppressAjaxErrorsDuringNavigation
(
err
,
true
,
true
);
const
thenCallback
=
jest
.
fn
();
const
catchCallback
=
jest
.
fn
();
actual
.
then
(
thenCallback
).
catch
(
catchCallback
);
return
waitForPromises
().
then
(()
=>
{
expect
(
thenCallback
).
not
.
toHaveBeenCalled
();
expect
(
catchCallback
).
not
.
toHaveBeenCalled
();
});
});
});
spec/javascripts/frequent_items/components/app_spec.js
View file @
9103afa0
...
...
@@ -236,15 +236,8 @@ describe('Frequent Items App Component', () => {
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.loading-animation
'
)).
toBeDefined
();
})
// This test waits for multiple ticks in order to allow the responses to
// propagate through each interceptor installed on the Axios instance.
// This shouldn't be necessary; this test should be refactored to avoid this.
// https://gitlab.com/gitlab-org/gitlab/issues/32479
.
then
(
vm
.
$nextTick
)
.
then
(
vm
.
$nextTick
)
.
then
(
vm
.
$nextTick
)
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelectorAll
(
'
.frequent-items-list-container li
'
).
length
).
toBe
(
mockSearchedProjects
.
length
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment