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
2b2c42a1
Commit
2b2c42a1
authored
Aug 03, 2016
by
Alfredo Sumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor of Protected Branch Edit List
parent
1ac953da
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
10 deletions
+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
No files found.
app/assets/javascripts/dispatcher.js
View file @
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
View file @
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
View file @
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
View file @
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'
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