Commit 7001c914 authored by Alfredo Sumaran's avatar Alfredo Sumaran

Pass access level data to dropdowns

parent 3a343be8
......@@ -3,10 +3,11 @@
gl.ProtectedBranchAccessDropdown = class {
constructor(options) {
const { $dropdown, onSelect, onHide, accessLevel } = options;
const { $dropdown, onSelect, onHide, accessLevel, accessLevelsData } = options;
const self = this;
this.accessLevel = accessLevel;
this.accessLevelsData = accessLevelsData;
this.$dropdown = $dropdown;
this.$wrap = this.$dropdown.parents().eq(1); // TODO: Find a better way to get the wrap element
this.usersPath = '/autocomplete/users.json';
......@@ -85,7 +86,7 @@
return user;
});
let mergeAccessLevels = gon.merge_access_levels.map((level) => {
let mergeAccessLevels = this.accessLevelsData.map((level) => {
level.type = 'role';
return level;
});
......
......@@ -17,14 +17,14 @@
// Allowed to Merge dropdown
new gl.allowedToMergeDropdown({
$dropdown: $allowedToMergeDropdown,
data: gon.merge_access_levels,
accessLevelsData: gon.merge_access_levels,
onSelect: this.onSelectCallback
});
// Allowed to Push dropdown
new gl.allowedToPushDropdown({
$dropdown: $allowedToPushDropdown,
data: gon.push_access_levels,
accessLevelsData: gon.push_access_levels,
onSelect: this.onSelectCallback
});
......
......@@ -35,14 +35,16 @@
// Allowed to merge dropdown
new gl.allowedToMergeDropdown({
accessLevel: ACCESS_LEVELS.MERGE,
accessLevelsData: gon.merge_access_levels,
$dropdown: this.$allowedToMergeDropdown,
onSelect: this.onSelectOption.bind(this),
onHide: this.onDropdownHide.bind(this),
onHide: this.onDropdownHide.bind(this)
});
// Allowed to push dropdown
new gl.allowedToPushDropdown({
accessLevel: ACCESS_LEVELS.PUSH,
accessLevelsData: gon.push_access_levels,
$dropdown: this.$allowedToPushDropdown,
onSelect: this.onSelectOption.bind(this),
onHide: this.onDropdownHide.bind(this)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment