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
8c3b7ee6
Commit
8c3b7ee6
authored
Aug 18, 2016
by
Alfredo Sumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Be able to update protected branches
[ci skip]
parent
75ac9804
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
16 deletions
+69
-16
app/assets/javascripts/protected_branch_access_dropdown.js.es6
...ssets/javascripts/protected_branch_access_dropdown.js.es6
+9
-2
app/assets/javascripts/protected_branch_edit.js.es6
app/assets/javascripts/protected_branch_edit.js.es6
+59
-13
app/views/projects/protected_branches/_access_level_dropdown.html.haml
...jects/protected_branches/_access_level_dropdown.html.haml
+1
-1
No files found.
app/assets/javascripts/protected_branch_access_dropdown.js.es6
View file @
8c3b7ee6
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
gl.ProtectedBranchAccessDropdown = class {
gl.ProtectedBranchAccessDropdown = class {
constructor(options) {
constructor(options) {
const { $dropdown,
data, onSelect
} = options;
const { $dropdown,
onSelect, onHide
} = options;
const self = this;
const self = this;
this.$dropdown = $dropdown;
this.$dropdown = $dropdown;
...
@@ -25,6 +25,10 @@
...
@@ -25,6 +25,10 @@
hidden() {
hidden() {
// Here because last selected item is not considered after first close
// Here because last selected item is not considered after first close
this.activeIds = self.getActiveIds();
this.activeIds = self.getActiveIds();
if (onHide) {
onHide();
}
},
},
setActiveIds() {
setActiveIds() {
// Needed for pre select options
// Needed for pre select options
...
@@ -33,7 +37,10 @@
...
@@ -33,7 +37,10 @@
clicked(item, $el, e) {
clicked(item, $el, e) {
e.preventDefault();
e.preventDefault();
self.inputCount++;
self.inputCount++;
onSelect();
if (onSelect) {
onSelect();
}
}
}
});
});
}
}
...
...
app/assets/javascripts/protected_branch_edit.js.es6
View file @
8c3b7ee6
...
@@ -3,34 +3,85 @@
...
@@ -3,34 +3,85 @@
gl.ProtectedBranchEdit = class {
gl.ProtectedBranchEdit = class {
constructor(options) {
constructor(options) {
this.hasChanges = false;
this.$wrap = options.$wrap;
this.$wrap = options.$wrap;
this.$allowedToMergeDropdown = this.$wrap.find('.js-allowed-to-merge');
this.$allowedToMergeDropdown = this.$wrap.find('.js-allowed-to-merge');
this.$allowedToMergeDropdownWrap = this.$allowedToMergeDropdown.parents().eq(1);
this.$allowedToPushDropdown = this.$wrap.find('.js-allowed-to-push');
this.$allowedToPushDropdown = this.$wrap.find('.js-allowed-to-push');
this.$allowedToPushDropdownWrap = this.$allowedToPushDropdown.parents().eq(1);
this.buildDropdowns();
this.buildDropdowns();
}
}
buildDropdowns() {
buildDropdowns() {
// Allowed to merge dropdown
// Allowed to merge dropdown
new gl.allowedToMergeDropdown({
new gl.allowedToMergeDropdown({
$dropdown: this.$allowedToMergeDropdown,
$dropdown: this.$allowedToMergeDropdown,
data: gon.merge_access_levels
,
onSelect: this.onSelect.bind(this)
,
on
Select: this.onSelect.bind(this)
on
Hide: this.onHide.bind(this),
});
});
// Allowed to push dropdown
// Allowed to push dropdown
new gl.allowedToPushDropdown({
new gl.allowedToPushDropdown({
$dropdown: this.$allowedToPushDropdown,
$dropdown: this.$allowedToPushDropdown,
data: gon.push_access_levels
,
onSelect: this.onSelect.bind(this)
,
on
Select: this.onSelect
.bind(this)
on
Hide: this.onHide
.bind(this)
});
});
}
}
onSelect() {
onSelect() {
this.hasChanges = true;
}
onHide() {
if (!this.hasChanges) {
return;
}
this.hasChanges = true;
const $allowedToMergeInput = this.$wrap.find(`input[name="${this.$allowedToMergeDropdown.data('fieldName')}"]`);
const $allowedToMergeInput = this.$wrap.find(`input[name="${this.$allowedToMergeDropdown.data('fieldName')}"]`);
const $allowedToPushInput = this.$wrap.find(`input[name="${this.$allowedToPushDropdown.data('fieldName')}"]`);
const $allowedToPushInput = this.$wrap.find(`input[name="${this.$allowedToPushDropdown.data('fieldName')}"]`);
let $mergeInputs = this.$allowedToMergeDropdownWrap.find('input[name^="protected_branch[merge_access_levels_attributes]"]')
let $pushInputs = this.$allowedToPushDropdownWrap.find('input[name^="protected_branch[push_access_levels_attributes]"]')
let merge_access_levels_attributes = [];
let push_access_levels_attributes = [];
$mergeInputs.map((i, el) => {
const $el = $(el);
const type = $el.data('type');
const value = $el.val();
if (type === 'role') {
merge_access_levels_attributes.push({
access_level: value
});
} else if (type === 'user') {
merge_access_levels_attributes.push({
user_id: value
});
}
});
$pushInputs.map((i, el) => {
const $el = $(el);
const type = $el.data('type');
const value = $el.val();
if (type === 'role') {
push_access_levels_attributes.push({
access_level: value
});
} else if (type === 'user') {
push_access_levels_attributes.push({
user_id: value
});
}
});
$.ajax({
$.ajax({
type: 'POST',
type: 'POST',
url: this.$wrap.data('url'),
url: this.$wrap.data('url'),
...
@@ -39,18 +90,13 @@
...
@@ -39,18 +90,13 @@
_method: 'PATCH',
_method: 'PATCH',
id: this.$wrap.data('banchId'),
id: this.$wrap.data('banchId'),
protected_branch: {
protected_branch: {
merge_access_levels_attributes: [{
merge_access_levels_attributes,
id: this.$allowedToMergeDropdown.data('access-level-id'),
push_access_levels_attributes
access_level: $allowedToMergeInput.val()
}],
push_access_levels_attributes: [{
id: this.$allowedToPushDropdown.data('access-level-id'),
access_level: $allowedToPushInput.val()
}]
}
}
},
},
success: () => {
success: () => {
this.$wrap.effect('highlight');
this.$wrap.effect('highlight');
this.hasChanges = false;
},
},
error() {
error() {
$.scrollTo(0);
$.scrollTo(0);
...
...
app/views/projects/protected_branches/_access_level_dropdown.html.haml
View file @
8c3b7ee6
...
@@ -10,4 +10,4 @@
...
@@ -10,4 +10,4 @@
value:
value
,
data:
{
type:
level
.
type
}
}
value:
value
,
data:
{
type:
level
.
type
}
}
=
dropdown_tag
(
'Select'
,
options:
{
toggle_class:
"
#{
toggle_class
}
js-multiselect"
,
dropdown_class:
'dropdown-menu-user dropdown-menu-selectable'
,
filter:
true
,
=
dropdown_tag
(
'Select'
,
options:
{
toggle_class:
"
#{
toggle_class
}
js-multiselect"
,
dropdown_class:
'dropdown-menu-user dropdown-menu-selectable'
,
filter:
true
,
data:
{
input_id:
input_basic_name
,
default_label:
'Select'
}
})
data:
{
default_label:
'Select'
}
})
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