Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
2b2c42a1
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,发现更多精彩内容 >>
提交
2b2c42a1
编写于
8月 03, 2016
作者:
A
Alfredo Sumaran
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor of Protected Branch Edit List
上级
1ac953da
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
79 addition
and
10 deletion
+79
-10
app/assets/javascripts/dispatcher.js
app/assets/javascripts/dispatcher.js
+2
-1
app/assets/javascripts/protect_branch_create.js.es6
app/assets/javascripts/protect_branch_create.js.es6
+1
-1
app/assets/javascripts/protect_branch_edit.js.es6
app/assets/javascripts/protect_branch_edit.js.es6
+69
-0
app/views/projects/protected_branches/_protected_branch.html.haml
...s/projects/protected_branches/_protected_branch.html.haml
+7
-8
未找到文件。
app/assets/javascripts/dispatcher.js
浏览文件 @
2b2c42a1
...
...
@@ -173,7 +173,8 @@
new
Search
();
break
;
case
'
projects:protected_branches:index
'
:
new
CreateProtectedBranch
();
new
ProtectedBranchCreate
();
new
ProtectedBranchEditList
();
break
;
}
switch
(
path
.
first
())
{
...
...
app/assets/javascripts/protect_branch.js.es6
→
app/assets/javascripts/protect_branch
_create
.js.es6
浏览文件 @
2b2c42a1
...
...
@@ -45,7 +45,7 @@ class AllowedToPushSelects {
}
}
class
CreateProtectedBranch
{
class
ProtectedBranchCreate
{
constructor() {
this.$wrap = this.$form = $('#new_protected_branch');
this.buildDropdowns();
...
...
app/assets/javascripts/protect_branch_edit.js.es6
0 → 100644
浏览文件 @
2b2c42a1
class ProtectedBranchEdit {
constructor(options) {
this.$wrap = options.$wrap;
this.$allowedToMergeDropdown = this.$wrap.find('.js-allowed-to-merge');
this.$allowedToPushDropdown = this.$wrap.find('.js-allowed-to-push');
this.buildDropdowns();
}
buildDropdowns() {
// Allowed to merge dropdown
new ProtectedBranchesAccessDropdown({
$dropdown: this.$allowedToMergeDropdown,
data: gon.merge_access_levels,
onSelect: this.onSelect.bind(this)
});
// Allowed to push dropdown
new ProtectedBranchesAccessDropdown({
$dropdown: this.$allowedToPushDropdown,
data: gon.push_access_levels,
onSelect: this.onSelect.bind(this)
});
}
onSelect() {
const $allowedToMergeInput = $(`input[name="${this.$allowedToMergeDropdown.data('fieldName')}"]`);
const $allowedToPushInput = $(`input[name="${this.$allowedToPushDropdown.data('fieldName')}"]`);
$.ajax({
type: 'POST',
url: this.$wrap.data('url'),
dataType: 'json',
data: {
_method: 'PATCH',
id: this.$wrap.data('banchId'),
protected_branch: {
merge_access_level_attributes: {
access_level: $allowedToMergeInput.val()
},
push_access_level_attributes: {
access_level: $allowedToPushInput.val()
}
}
},
success: () => {
this.$wrap.effect('highlight');
},
error: function() {
$.scrollTo(0);
new Flash('Failed to update branch!');
}
});
}
}
class ProtectedBranchEditList {
constructor() {
this.$wrap = $('.protected-branches-list');
// Build edit forms
this.$wrap.find('.js-protected-branch-edit-form').each((i, el) => {
new ProtectedBranchEdit({
$wrap: $(el)
});
});
}
}
app/views/projects/protected_branches/_protected_branch.html.haml
浏览文件 @
2b2c42a1
-
url
=
namespace_project_protected_branch_path
(
@project
.
namespace
,
@project
,
protected_branch
)
%tr
%tr
.js-protected-branch-edit-form
{
data:
{
url:
namespace_project_protected_branch_path
(
@project
.
namespace
,
@project
,
protected_branch
),
branch_id:
protected_branch
.
id
}
}
%td
=
protected_branch
.
name
-
if
@project
.
root_ref?
(
protected_branch
.
name
)
...
...
@@ -16,14 +15,14 @@
(branch was removed from repository)
%td
=
hidden_field_tag
"allowed_to_merge_
#{
protected_branch
.
id
}
"
,
protected_branch
.
merge_access_level
.
access_level
=
dropdown_tag
(
protected_branch
.
merge_access_level
.
humanize
,
options:
{
toggle_class:
'
allowed-to-merge'
,
dropdown_class:
'dropdown-menu-selectable merg
e'
,
data:
{
field_name:
"allowed_to_merge_
#{
protected_branch
.
id
}
"
,
url:
url
,
id:
protected_branch
.
id
,
type:
"merge_access_level"
}})
=
dropdown_tag
(
(
protected_branch
.
merge_access_level
.
humanize
||
'Select'
)
,
options:
{
toggle_class:
'
js-allowed-to-merge'
,
dropdown_class:
'dropdown-menu-selectabl
e'
,
data:
{
field_name:
"allowed_to_merge_
#{
protected_branch
.
id
}
"
}})
%td
=
hidden_field_tag
"allowed_to_push_
#{
protected_branch
.
id
}
"
,
protected_branch
.
push_access_level
.
access_level
=
dropdown_tag
(
protected_branch
.
push_access_level
.
humanize
,
options:
{
toggle_class:
'
allowed-to-push'
,
dropdown_class:
'dropdown-menu-selectable push
'
,
data:
{
field_name:
"allowed_to_push_
#{
protected_branch
.
id
}
"
,
url:
url
,
id:
protected_branch
.
id
,
type:
"push_access_level"
}})
=
dropdown_tag
(
(
protected_branch
.
push_access_level
.
humanize
||
'Select'
)
,
options:
{
toggle_class:
'
js-allowed-to-push'
,
dropdown_class:
'dropdown-menu-selectable
'
,
data:
{
field_name:
"allowed_to_push_
#{
protected_branch
.
id
}
"
}})
-
if
can_admin_project
%td
=
link_to
'Unprotect'
,
[
@project
.
namespace
.
becomes
(
Namespace
),
@project
,
protected_branch
],
data:
{
confirm:
'Branch will be writable for developers. Are you sure?'
},
method: :delete
,
class:
'btn btn-warning'
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录