Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Andrew <mail@timothyandrew.net>2016-07-25 12:12:52 +0300
committerTimothy Andrew <mail@timothyandrew.net>2016-07-29 12:50:39 +0300
commit7b2ad2d5b99d84fc2d2c11a654085afc02a05bb1 (patch)
tree3ee132c1ad1187e0905f08b6f360a18bd8a1519f /app/assets/javascripts
parentb3a29b3180c4edda33d82fc3564bd4991831e06c (diff)
Implement review comments from @dbalexandre.
1. Remove `master_or_greater?` and `developer_or_greater?` in favor of `max_member_access`, which is a lot nicer. 2. Remove a number of instances of `include Gitlab::Database::MigrationHelpers` in migrations that don't need this module. Also remove comments where not necessary. 3. Remove duplicate entry in CHANGELOG. 4. Move `ProtectedBranchAccessSelect` from Coffeescript to ES6. 5. Split the `set_access_levels!` method in two - one each for `merge` and `push` access levels.
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r--app/assets/javascripts/protected_branches.js35
-rw-r--r--app/assets/javascripts/protected_branches_access_select.js.coffee40
-rw-r--r--app/assets/javascripts/protected_branches_access_select.js.es653
3 files changed, 53 insertions, 75 deletions
diff --git a/app/assets/javascripts/protected_branches.js b/app/assets/javascripts/protected_branches.js
deleted file mode 100644
index db21a19964d..00000000000
--- a/app/assets/javascripts/protected_branches.js
+++ /dev/null
@@ -1,35 +0,0 @@
-(function() {
- $(function() {
- return $(".protected-branches-list :checkbox").change(function(e) {
- var can_push, id, name, obj, url;
- name = $(this).attr("name");
- if (name === "developers_can_push" || name === "developers_can_merge") {
- id = $(this).val();
- can_push = $(this).is(":checked");
- url = $(this).data("url");
- return $.ajax({
- type: "PATCH",
- url: url,
- dataType: "json",
- data: {
- id: id,
- protected_branch: (
- obj = {},
- obj["" + name] = can_push,
- obj
- )
- },
- success: function() {
- var row;
- row = $(e.target);
- return row.closest('tr').effect('highlight');
- },
- error: function() {
- return new Flash("Failed to update branch!", "alert");
- }
- });
- }
- });
- });
-
-}).call(this);
diff --git a/app/assets/javascripts/protected_branches_access_select.js.coffee b/app/assets/javascripts/protected_branches_access_select.js.coffee
deleted file mode 100644
index a4d9b6eb616..00000000000
--- a/app/assets/javascripts/protected_branches_access_select.js.coffee
+++ /dev/null
@@ -1,40 +0,0 @@
-class @ProtectedBranchesAccessSelect
- constructor: (@container, @saveOnSelect) ->
- @container.find(".allowed-to-merge").each (i, element) =>
- fieldName = $(element).data('field-name')
- $(element).glDropdown
- data: gon.merge_access_levels
- selectable: true
- fieldName: fieldName
- clicked: _.partial(@onSelect, element)
-
- @container.find(".allowed-to-push").each (i, element) =>
- fieldName = $(element).data('field-name')
- $(element).glDropdown
- data: gon.push_access_levels
- selectable: true
- fieldName: fieldName
- clicked: _.partial(@onSelect, element)
-
-
- onSelect: (dropdown, selected, element, e) =>
- $(dropdown).find('.dropdown-toggle-text').text(selected.text)
- if @saveOnSelect
- $.ajax
- type: "POST"
- url: $(dropdown).data('url')
- dataType: "json"
- data:
- _method: 'PATCH'
- id: $(dropdown).data('id')
- protected_branch:
- "#{$(dropdown).data('type')}": selected.id
-
- success: ->
- row = $(e.target)
- row.closest('tr').effect('highlight')
- new Flash("Updated protected branch!", "notice")
-
- error: ->
- new Flash("Failed to update branch!", "alert")
-
diff --git a/app/assets/javascripts/protected_branches_access_select.js.es6 b/app/assets/javascripts/protected_branches_access_select.js.es6
new file mode 100644
index 00000000000..93b7d7755a7
--- /dev/null
+++ b/app/assets/javascripts/protected_branches_access_select.js.es6
@@ -0,0 +1,53 @@
+class ProtectedBranchesAccessSelect {
+ constructor(container, saveOnSelect) {
+ this.container = container;
+ this.saveOnSelect = saveOnSelect;
+
+ this.container.find(".allowed-to-merge").each((i, element) => {
+ var fieldName = $(element).data('field-name');
+ return $(element).glDropdown({
+ data: gon.merge_access_levels,
+ selectable: true,
+ fieldName: fieldName,
+ clicked: _.chain(this.onSelect).partial(element).bind(this).value()
+ });
+ });
+
+
+ this.container.find(".allowed-to-push").each((i, element) => {
+ var fieldName = $(element).data('field-name');
+ return $(element).glDropdown({
+ data: gon.push_access_levels,
+ selectable: true,
+ fieldName: fieldName,
+ clicked: _.chain(this.onSelect).partial(element).bind(this).value()
+ });
+ });
+ }
+
+ onSelect(dropdown, selected, element, e) {
+ $(dropdown).find('.dropdown-toggle-text').text(selected.text);
+ if (this.saveOnSelect) {
+ return $.ajax({
+ type: "POST",
+ url: $(dropdown).data('url'),
+ dataType: "json",
+ data: {
+ _method: 'PATCH',
+ id: $(dropdown).data('id'),
+ protected_branch: {
+ ["" + ($(dropdown).data('type'))]: selected.id
+ }
+ },
+ success: function() {
+ var row;
+ row = $(e.target);
+ return row.closest('tr').effect('highlight');
+ },
+ error: function() {
+ return new Flash("Failed to update branch!", "alert");
+ }
+ });
+ }
+ }
+}