diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2016-07-07 13:48:07 +0300 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2016-07-29 12:50:39 +0300 |
commit | ab6096c17261605d835a4a8edae21f31d90026df (patch) | |
tree | 0a4490cc0a62b86bf240fbc5bdff709b2e8d11b0 /app/assets/javascripts | |
parent | f8a04e15371815ad39e2c66056db4ab0439555f4 (diff) |
Add "No One Can Push" to the protected branches UI.
1. Move to dropdowns instead of checkboxes. One each for "Allowed to
Push" and "Allowed to Merge"
2. Refactor the `ProtectedBranches` coffeescript class into
`ProtectedBranchesAccessSelect`.
3. Modify the backend to accept the new parameters.
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r-- | app/assets/javascripts/protected_branches_access_select.js.coffee | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/app/assets/javascripts/protected_branches_access_select.js.coffee b/app/assets/javascripts/protected_branches_access_select.js.coffee new file mode 100644 index 00000000000..b472ff7ec27 --- /dev/null +++ b/app/assets/javascripts/protected_branches_access_select.js.coffee @@ -0,0 +1,39 @@ +class @ProtectedBranchesAccessSelect + constructor: () -> + $(".allowed-to-merge").each (i, element) => + fieldName = $(element).data('field-name') + $(element).glDropdown + data: [{id: 'developers', text: 'Developers'}, {id: 'masters', text: 'Masters'}] + selectable: true + fieldName: fieldName + clicked: _.partial(@onSelect, element) + + $(".allowed-to-push").each (i, element) => + fieldName = $(element).data('field-name') + $(element).glDropdown + data: [{id: 'no_one', text: 'No one'}, + {id: 'developers', text: 'Developers'}, + {id: 'masters', text: 'Masters'}] + selectable: true + fieldName: fieldName + clicked: _.partial(@onSelect, element) + + + onSelect: (dropdown, selected, element, e) => + $(dropdown).find('.dropdown-toggle-text').text(selected.text) + $.ajax + type: "PATCH" + url: $(dropdown).data('url') + dataType: "json" + data: + id: $(dropdown).data('id') + protected_branch: + "#{$(dropdown).data('type')}": selected.id + + success: -> + row = $(e.target) + row.closest('tr').effect('highlight') + + error: -> + new Flash("Failed to update branch!", "alert") + |