summaryrefslogtreecommitdiff
path: root/app/assets/javascripts
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2017-02-03 15:45:48 +0000
committerFilipa Lacerda <filipa@gitlab.com>2017-02-03 15:45:48 +0000
commit2159694e5024a129ef77f7b81af4fadcde84334a (patch)
tree6ebe803347cd5008d3e7fa8a38757c9ed9d12369 /app/assets/javascripts
parentea43f58689bd5ee26a7672889913c2bb8a30d842 (diff)
parent806b038a44cda37fa7d8ba9afae4b7adb07afe94 (diff)
downloadgitlab-ce-2159694e5024a129ef77f7b81af4fadcde84334a.tar.gz
Merge branch 'master' into fe-commit-mr-pipelines
* master: Backport changes from EE squash replace `find_with_namespace` with `find_by_full_path` PlantUML support for Markdown Update api docs and minor changes Force new password after password reset via API Fixed protected branches dropdown Fixed up tests Fixed the active branch selected indicator Changed how the data is returned - we only care about the branch/tag name Uses take rather than Kaminari Use cloneNode instead of createElement Improved ref switcher dropdown performance
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r--app/assets/javascripts/project.js29
-rw-r--r--app/assets/javascripts/protected_branches/protected_branch_dropdown.js.es62
2 files changed, 25 insertions, 6 deletions
diff --git a/app/assets/javascripts/project.js b/app/assets/javascripts/project.js
index 7cf630a1d76..67f8804666d 100644
--- a/app/assets/javascripts/project.js
+++ b/app/assets/javascripts/project.js
@@ -58,6 +58,11 @@
};
Project.prototype.initRefSwitcher = function() {
+ var refListItem = document.createElement('li'),
+ refLink = document.createElement('a');
+
+ refLink.href = '#';
+
return $('.js-project-refs-dropdown').each(function() {
var $dropdown, selected;
$dropdown = $(this);
@@ -67,7 +72,8 @@
return $.ajax({
url: $dropdown.data('refs-url'),
data: {
- ref: $dropdown.data('ref')
+ ref: $dropdown.data('ref'),
+ search: term
},
dataType: "json"
}).done(function(refs) {
@@ -76,16 +82,29 @@
},
selectable: true,
filterable: true,
+ filterRemote: true,
filterByText: true,
fieldName: $dropdown.data('field-name'),
renderRow: function(ref) {
- var link;
+ var li = refListItem.cloneNode(false);
+
if (ref.header != null) {
- return $('<li />').addClass('dropdown-header').text(ref.header);
+ li.className = 'dropdown-header';
+ li.textContent = ref.header;
} else {
- link = $('<a />').attr('href', '#').addClass(ref === selected ? 'is-active' : '').text(ref).attr('data-ref', ref);
- return $('<li />').append(link);
+ var link = refLink.cloneNode(false);
+
+ if (ref === selected) {
+ link.className = 'is-active';
+ }
+
+ link.textContent = ref;
+ link.dataset.ref = ref;
+
+ li.appendChild(link);
}
+
+ return li;
},
id: function(obj, $el) {
return $el.attr('data-ref');
diff --git a/app/assets/javascripts/protected_branches/protected_branch_dropdown.js.es6 b/app/assets/javascripts/protected_branches/protected_branch_dropdown.js.es6
index 03f4531abf5..5cf28aa7a73 100644
--- a/app/assets/javascripts/protected_branches/protected_branch_dropdown.js.es6
+++ b/app/assets/javascripts/protected_branches/protected_branch_dropdown.js.es6
@@ -49,7 +49,7 @@ class ProtectedBranchDropdown {
onClickCreateWildcard() {
// Refresh the dropdown's data, which ends up calling `getProtectedBranches`
this.$dropdown.data('glDropdown').remote.execute();
- this.$dropdown.data('glDropdown').selectRowAtIndex(0);
+ this.$dropdown.data('glDropdown').selectRowAtIndex();
}
getProtectedBranches(term, callback) {