Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
fa29bc28
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 搜索 >>
提交
fa29bc28
编写于
6月 13, 2018
作者:
W
Winnie Hellmann
提交者:
Mike Greiling
6月 13, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix branch name encoding for dropdown on issue page
上级
adb06988
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
107 addition
and
16 deletion
+107
-16
app/assets/javascripts/create_merge_request_dropdown.js
app/assets/javascripts/create_merge_request_dropdown.js
+35
-16
changelogs/unreleased/winh-new-branch-url-encode.yml
changelogs/unreleased/winh-new-branch-url-encode.yml
+5
-0
spec/javascripts/create_merge_request_dropdown_spec.js
spec/javascripts/create_merge_request_dropdown_spec.js
+67
-0
未找到文件。
app/assets/javascripts/create_merge_request_dropdown.js
浏览文件 @
fa29bc28
...
...
@@ -66,8 +66,14 @@ export default class CreateMergeRequestDropdown {
}
bindEvents
()
{
this
.
createMergeRequestButton
.
addEventListener
(
'
click
'
,
this
.
onClickCreateMergeRequestButton
.
bind
(
this
));
this
.
createTargetButton
.
addEventListener
(
'
click
'
,
this
.
onClickCreateMergeRequestButton
.
bind
(
this
));
this
.
createMergeRequestButton
.
addEventListener
(
'
click
'
,
this
.
onClickCreateMergeRequestButton
.
bind
(
this
),
);
this
.
createTargetButton
.
addEventListener
(
'
click
'
,
this
.
onClickCreateMergeRequestButton
.
bind
(
this
),
);
this
.
branchInput
.
addEventListener
(
'
keyup
'
,
this
.
onChangeInput
.
bind
(
this
));
this
.
dropdownToggle
.
addEventListener
(
'
click
'
,
this
.
onClickSetFocusOnBranchNameInput
.
bind
(
this
));
this
.
refInput
.
addEventListener
(
'
keyup
'
,
this
.
onChangeInput
.
bind
(
this
));
...
...
@@ -77,7 +83,8 @@ export default class CreateMergeRequestDropdown {
checkAbilityToCreateBranch
()
{
this
.
setUnavailableButtonState
();
axios
.
get
(
this
.
canCreatePath
)
axios
.
get
(
this
.
canCreatePath
)
.
then
(({
data
})
=>
{
this
.
setUnavailableButtonState
(
false
);
...
...
@@ -105,7 +112,8 @@ export default class CreateMergeRequestDropdown {
createBranch
()
{
this
.
isCreatingBranch
=
true
;
return
axios
.
post
(
this
.
createBranchPath
)
return
axios
.
post
(
this
.
createBranchPath
)
.
then
(({
data
})
=>
{
this
.
branchCreated
=
true
;
window
.
location
.
href
=
data
.
url
;
...
...
@@ -116,7 +124,8 @@ export default class CreateMergeRequestDropdown {
createMergeRequest
()
{
this
.
isCreatingMergeRequest
=
true
;
return
axios
.
post
(
this
.
createMrPath
)
return
axios
.
post
(
this
.
createMrPath
)
.
then
(({
data
})
=>
{
this
.
mergeRequestCreated
=
true
;
window
.
location
.
href
=
data
.
url
;
...
...
@@ -195,7 +204,8 @@ export default class CreateMergeRequestDropdown {
getRef
(
ref
,
target
=
'
all
'
)
{
if
(
!
ref
)
return
false
;
return
axios
.
get
(
this
.
refsPath
+
ref
)
return
axios
.
get
(
`
${
this
.
refsPath
}${
encodeURIComponent
(
ref
)}
`
)
.
then
(({
data
})
=>
{
const
branches
=
data
[
Object
.
keys
(
data
)[
0
]];
const
tags
=
data
[
Object
.
keys
(
data
)[
1
]];
...
...
@@ -204,7 +214,8 @@ export default class CreateMergeRequestDropdown {
if
(
target
===
'
branch
'
)
{
result
=
CreateMergeRequestDropdown
.
findByValue
(
branches
,
ref
);
}
else
{
result
=
CreateMergeRequestDropdown
.
findByValue
(
branches
,
ref
,
true
)
||
result
=
CreateMergeRequestDropdown
.
findByValue
(
branches
,
ref
,
true
)
||
CreateMergeRequestDropdown
.
findByValue
(
tags
,
ref
,
true
);
this
.
suggestedRef
=
result
;
}
...
...
@@ -255,11 +266,13 @@ export default class CreateMergeRequestDropdown {
}
isBusy
()
{
return
this
.
isCreatingMergeRequest
||
return
(
this
.
isCreatingMergeRequest
||
this
.
mergeRequestCreated
||
this
.
isCreatingBranch
||
this
.
branchCreated
||
this
.
isGettingRef
;
this
.
isGettingRef
);
}
onChangeInput
(
event
)
{
...
...
@@ -271,7 +284,8 @@ export default class CreateMergeRequestDropdown {
value
=
this
.
branchInput
.
value
;
}
else
if
(
event
.
target
===
this
.
refInput
)
{
target
=
'
ref
'
;
value
=
event
.
target
.
value
.
slice
(
0
,
event
.
target
.
selectionStart
)
+
value
=
event
.
target
.
value
.
slice
(
0
,
event
.
target
.
selectionStart
)
+
event
.
target
.
value
.
slice
(
event
.
target
.
selectionEnd
);
}
else
{
return
false
;
...
...
@@ -396,7 +410,8 @@ export default class CreateMergeRequestDropdown {
showNotAvailableMessage
(
target
)
{
const
{
input
,
message
}
=
this
.
getTargetData
(
target
);
const
text
=
target
===
'
branch
'
?
__
(
'
Branch is already taken
'
)
:
__
(
'
Source is not available
'
);
const
text
=
target
===
'
branch
'
?
__
(
'
Branch is already taken
'
)
:
__
(
'
Source is not available
'
);
this
.
removeMessage
(
target
);
input
.
classList
.
add
(
'
gl-field-error-outline
'
);
...
...
@@ -459,11 +474,15 @@ export default class CreateMergeRequestDropdown {
// target - 'branch' or 'ref'
// ref - string - the new value to use as branch or ref
updateCreatePaths
(
target
,
ref
)
{
const
pathReplacement
=
`$1
${
ref
}
`
;
const
pathReplacement
=
`$1
${
encodeURIComponent
(
ref
)
}
`
;
this
.
createBranchPath
=
this
.
createBranchPath
.
replace
(
this
.
regexps
[
target
].
createBranchPath
,
pathReplacement
);
this
.
createMrPath
=
this
.
createMrPath
.
replace
(
this
.
regexps
[
target
].
createMrPath
,
pathReplacement
);
this
.
createBranchPath
=
this
.
createBranchPath
.
replace
(
this
.
regexps
[
target
].
createBranchPath
,
pathReplacement
,
);
this
.
createMrPath
=
this
.
createMrPath
.
replace
(
this
.
regexps
[
target
].
createMrPath
,
pathReplacement
,
);
}
}
changelogs/unreleased/winh-new-branch-url-encode.yml
0 → 100644
浏览文件 @
fa29bc28
---
title
:
Fix branch name encoding for dropdown on issue page
merge_request
:
19634
author
:
type
:
fixed
spec/javascripts/create_merge_request_dropdown_spec.js
0 → 100644
浏览文件 @
fa29bc28
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
CreateMergeRequestDropdown
from
'
~/create_merge_request_dropdown
'
;
import
{
TEST_HOST
}
from
'
spec/test_constants
'
;
describe
(
'
CreateMergeRequestDropdown
'
,
()
=>
{
let
axiosMock
;
let
dropdown
;
beforeEach
(()
=>
{
axiosMock
=
new
MockAdapter
(
axios
);
setFixtures
(
`
<div id="dummy-wrapper-element">
<div class="available"></div>
<div class="unavailable">
<div class="fa"></div>
<div class="text"></div>
</div>
<div class="js-ref"></div>
<div class="js-create-merge-request"></div>
<div class="js-create-target"></div>
<div class="js-dropdown-toggle"></div>
</div>
`
);
const
dummyElement
=
document
.
getElementById
(
'
dummy-wrapper-element
'
);
dropdown
=
new
CreateMergeRequestDropdown
(
dummyElement
);
dropdown
.
refsPath
=
`
${
TEST_HOST
}
/dummy/refs?search=`
;
});
afterEach
(()
=>
{
axiosMock
.
restore
();
});
describe
(
'
getRef
'
,
()
=>
{
it
(
'
escapes branch names correctly
'
,
done
=>
{
const
endpoint
=
`
${
dropdown
.
refsPath
}
contains%23hash`
;
spyOn
(
axios
,
'
get
'
).
and
.
callThrough
();
axiosMock
.
onGet
(
endpoint
).
replyOnce
({});
dropdown
.
getRef
(
'
contains#hash
'
)
.
then
(()
=>
{
expect
(
axios
.
get
).
toHaveBeenCalledWith
(
endpoint
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
describe
(
'
updateCreatePaths
'
,
()
=>
{
it
(
'
escapes branch names correctly
'
,
()
=>
{
dropdown
.
createBranchPath
=
`
${
TEST_HOST
}
/branches?branch_name=some-branch&issue=42`
;
dropdown
.
createMrPath
=
`
${
TEST_HOST
}
/create_merge_request?branch_name=some-branch&ref=master`
;
dropdown
.
updateCreatePaths
(
'
branch
'
,
'
contains#hash
'
);
expect
(
dropdown
.
createBranchPath
).
toBe
(
`
${
TEST_HOST
}
/branches?branch_name=contains%23hash&issue=42`
,
);
expect
(
dropdown
.
createMrPath
).
toBe
(
`
${
TEST_HOST
}
/create_merge_request?branch_name=contains%23hash&ref=master`
,
);
});
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录