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
0
Merge Requests
0
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
Tatuya Kamada
gitlab-ce
Commits
8f29c332
Commit
8f29c332
authored
Aug 05, 2016
by
Alfredo Sumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wrap classes with IIFE and define it inside gl namespace
parent
45454c3c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
141 additions
and
121 deletions
+141
-121
app/assets/javascripts/dispatcher.js
app/assets/javascripts/dispatcher.js
+2
-2
app/assets/javascripts/protected_branch_access_dropdown.js.es6
...ssets/javascripts/protected_branch_access_dropdown.js.es6
+21
-16
app/assets/javascripts/protected_branch_create.js.es6
app/assets/javascripts/protected_branch_create.js.es6
+49
-44
app/assets/javascripts/protected_branch_edit.js.es6
app/assets/javascripts/protected_branch_edit.js.es6
+55
-50
app/assets/javascripts/protected_branch_edit_list.js.es6
app/assets/javascripts/protected_branch_edit_list.js.es6
+14
-9
No files found.
app/assets/javascripts/dispatcher.js
View file @
8f29c332
...
@@ -173,8 +173,8 @@
...
@@ -173,8 +173,8 @@
new
Search
();
new
Search
();
break
;
break
;
case
'
projects:protected_branches:index
'
:
case
'
projects:protected_branches:index
'
:
new
ProtectedBranchCreate
();
new
gl
.
ProtectedBranchCreate
();
new
ProtectedBranchEditList
();
new
gl
.
ProtectedBranchEditList
();
break
;
break
;
}
}
switch
(
path
.
first
())
{
switch
(
path
.
first
())
{
...
...
app/assets/javascripts/protected_branch_access_dropdown.js.es6
View file @
8f29c332
class ProtectedBranchAccessDropdown {
(global => {
constructor(options) {
global.gl = global.gl || {};
const { $dropdown, data, onSelect } = options;
$dropdown.glDropdown({
gl.ProtectedBranchAccessDropdown = class {
data: data,
constructor(options) {
selectable: true,
const { $dropdown, data, onSelect } = options;
fieldName: $dropdown.data('field-name'),
toggleLabel(item) {
$dropdown.glDropdown({
return item.text;
data: data,
},
selectable: true,
clicked(item, $el, e) {
fieldName: $dropdown.data('field-name'),
e.preventDefault();
toggleLabel(item) {
onSelect();
return item.text;
}
},
});
clicked(item, $el, e) {
e.preventDefault();
onSelect();
}
});
}
}
}
}
})(window);
app/assets/javascripts/protected_branch_create.js.es6
View file @
8f29c332
class ProtectedBranchCreate {
(global => {
constructor() {
global.gl = global.gl || {};
this.$wrap = this.$form = $('#new_protected_branch');
this.buildDropdowns();
}
buildDropdowns() {
gl.ProtectedBranchCreate = class {
// Allowed to Merge dropdown
constructor() {
const $allowedToMergeDropdown = this.$wrap.find('.js-allowed-to-merge');
this.$wrap = this.$form = $('#new_protected_branch');
const $allowedToPushDropdown = this.$wrap.find('.js-allowed-to-push');
this.buildDropdowns();
}
new ProtectedBranchAccessDropdown({
$dropdown: $allowedToMergeDropdown,
data: gon.merge_access_levels,
onSelect: this.onSelect.bind(this)
});
// Select default
$allowedToMergeDropdown.data('glDropdown').selectRowAtIndex(0);
// Allowed to Push dropdown
new ProtectedBranchAccessDropdown({
$dropdown: $allowedToPushDropdown,
data: gon.push_access_levels,
onSelect: this.onSelect.bind(this)
});
// Select default
$allowedToPushDropdown.data('glDropdown').selectRowAtIndex(0);
// Protected branch dropdown
new ProtectedBranchDropdown({
$dropdown: this.$wrap.find('.js-protected-branch-select'),
onSelect: this.onSelect.bind(this)
});
}
// This will run after clicked callback
buildDropdowns() {
onSelect() {
// Allowed to Merge dropdown
// Enable submit button
const $allowedToMergeDropdown = this.$wrap.find('.js-allowed-to-merge');
const $branchInput = this.$wrap.find('input[name="protected_branch[name]"]');
const $allowedToPushDropdown = this.$wrap.find('.js-allowed-to-push');
const $allowedToMergeInput = this.$wrap.find('input[name="protected_branch[merge_access_level_attributes][access_level]"]');
const $allowedToPushInput = this.$wrap.find('input[name="protected_branch[push_access_level_attributes][access_level]"]');
new gl.ProtectedBranchAccessDropdown({
$dropdown: $allowedToMergeDropdown,
data: gon.merge_access_levels,
onSelect: this.onSelect.bind(this)
});
// Select default
$allowedToMergeDropdown.data('glDropdown').selectRowAtIndex(0);
// Allowed to Push dropdown
new gl.ProtectedBranchAccessDropdown({
$dropdown: $allowedToPushDropdown,
data: gon.push_access_levels,
onSelect: this.onSelect.bind(this)
});
// Select default
$allowedToPushDropdown.data('glDropdown').selectRowAtIndex(0);
// Protected branch dropdown
new ProtectedBranchDropdown({
$dropdown: this.$wrap.find('.js-protected-branch-select'),
onSelect: this.onSelect.bind(this)
});
}
// This will run after clicked callback
onSelect() {
// Enable submit button
const $branchInput = this.$wrap.find('input[name="protected_branch[name]"]');
const $allowedToMergeInput = this.$wrap.find('input[name="protected_branch[merge_access_level_attributes][access_level]"]');
const $allowedToPushInput = this.$wrap.find('input[name="protected_branch[push_access_level_attributes][access_level]"]');
if ($branchInput.val() && $allowedToMergeInput.val() && $allowedToPushInput.val()){
if ($branchInput.val() && $allowedToMergeInput.val() && $allowedToPushInput.val()){
this.$form.find('[type="submit"]').removeAttr('disabled');
this.$form.find('[type="submit"]').removeAttr('disabled');
}
}
}
}
}
}
})(window);
app/assets/javascripts/protected_branch_edit.js.es6
View file @
8f29c332
class ProtectedBranchEdit {
(global => {
constructor(options) {
global.gl = global.gl || {};
this.$wrap = options.$wrap;
this.$allowedToMergeDropdown = this.$wrap.find('.js-allowed-to-merge');
this.$allowedToPushDropdown = this.$wrap.find('.js-allowed-to-push');
this.buildDropdowns();
gl.ProtectedBranchEdit = class {
}
constructor(options) {
this.$wrap = options.$wrap;
this.$allowedToMergeDropdown = this.$wrap.find('.js-allowed-to-merge');
this.$allowedToPushDropdown = this.$wrap.find('.js-allowed-to-push');
buildDropdowns() {
this.buildDropdowns();
}
// Allowed to merge dropdown
new ProtectedBranchAccessDropdown({
buildDropdowns() {
$dropdown: this.$allowedToMergeDropdown,
data: gon.merge_access_levels,
// Allowed to merge dropdown
onSelect: this.onSelect.bind(this)
new gl.ProtectedBranchAccessDropdown({
});
$dropdown: this.$allowedToMergeDropdown,
data: gon.merge_access_levels,
// Allowed to push dropdown
onSelect: this.onSelect.bind(this)
new ProtectedBranchAccessDropdown({
});
$dropdown: this.$allowedToPushDropdown,
data: gon.push_access_levels,
onSelect: this.onSelect.bind(this)
});
}
onSelect() {
// Allowed to push dropdown
const $allowedToMergeInput = $(`input[name="${this.$allowedToMergeDropdown.data('fieldName')}"]`);
new gl.ProtectedBranchAccessDropdown({
const $allowedToPushInput = $(`input[name="${this.$allowedToPushDropdown.data('fieldName')}"]`);
$dropdown: this.$allowedToPushDropdown,
data: gon.push_access_levels,
$.ajax({
onSelect: this.onSelect.bind(this)
type: 'POST',
});
url: this.$wrap.data('url'),
}
dataType: 'json',
data: {
onSelect() {
_method: 'PATCH',
const $allowedToMergeInput = $(`input[name="${this.$allowedToMergeDropdown.data('fieldName')}"]`);
id: this.$wrap.data('banchId'),
const $allowedToPushInput = $(`input[name="${this.$allowedToPushDropdown.data('fieldName')}"]`);
protected_branch: {
merge_access_level_attributes: {
$.ajax({
access_level: $allowedToMergeInput.val()
type: 'POST',
},
url: this.$wrap.data('url'),
push_access_level_attributes: {
dataType: 'json',
access_level: $allowedToPushInput.val()
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() {
$.scrollTo(0);
new Flash('Failed to update branch!');
}
}
},
});
success: () => {
}
this.$wrap.effect('highlight');
},
error() {
$.scrollTo(0);
new Flash('Failed to update branch!');
}
});
}
}
}
})(window);
app/assets/javascripts/protected_branch_edit_list.js.es6
View file @
8f29c332
class ProtectedBranchEditList {
(global => {
constructor() {
global.gl = global.gl || {};
this.$wrap = $('.protected-branches-list');
// Build edit forms
gl.ProtectedBranchEditList = class {
this.$wrap.find('.js-protected-branch-edit-form').each((i, el) => {
constructor() {
new ProtectedBranchEdit({
this.$wrap = $('.protected-branches-list');
$wrap: $(el)
// Build edit forms
this.$wrap.find('.js-protected-branch-edit-form').each((i, el) => {
new gl.ProtectedBranchEdit({
$wrap: $(el)
});
});
});
}
);
}
}
}
}
})(window);
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