Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
504ab1e3
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
504ab1e3
编写于
9月 25, 2019
作者:
G
GitLab Bot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add latest changes from gitlab-org/gitlab@master
上级
150effab
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
2 addition
and
81 deletion
+2
-81
Gemfile.lock
Gemfile.lock
+2
-2
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
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
未找到文件。
Gemfile.lock
浏览文件 @
504ab1e3
...
...
@@ -108,7 +108,7 @@ GEM
binding_ninja (0.2.3)
binding_of_caller (0.8.0)
debug_inspector (>= 0.0.1)
bootsnap (1.4.
4
)
bootsnap (1.4.
5
)
msgpack (~> 1.0)
bootstrap_form (4.2.0)
actionpack (>= 5.0)
...
...
@@ -586,7 +586,7 @@ GEM
mini_mime (1.0.1)
mini_portile2 (2.4.0)
minitest (5.11.3)
msgpack (1.3.
0
)
msgpack (1.3.
1
)
multi_json (1.13.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
...
...
app/assets/javascripts/lib/utils/axios_utils.js
浏览文件 @
504ab1e3
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
已删除
100644 → 0
浏览文件 @
150effab
/**
* 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
);
};
lib/gitlab/gon_helper.rb
浏览文件 @
504ab1e3
...
...
@@ -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
已删除
100644 → 0
浏览文件 @
150effab
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
浏览文件 @
504ab1e3
...
...
@@ -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
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录