summaryrefslogtreecommitdiff
path: root/app/views
diff options
context:
space:
mode:
authorTimothy Andrew <mail@timothyandrew.net>2016-06-30 13:02:05 +0530
committerTimothy Andrew <mail@timothyandrew.net>2016-07-07 10:07:05 +0530
commitd8d5424d25c1738b170d58657ef71d4dbc89ca5e (patch)
tree98c3a9d5b892838dddfff900776a9df9d2652442 /app/views
parent10c446eaa2ca4b46f454bde7f9715dc839efa5b9 (diff)
downloadgitlab-ce-d8d5424d25c1738b170d58657ef71d4dbc89ca5e.tar.gz
Use the `GLDropdown` component to select protected branches.
1. Modify the component to support a callback for every key press in the filter. We need this so we can update the "Create: <branch_name" label. 2. Modify the component to use `$(<selector>).first().click()` instead of `$(selector)[0].click()`, because the latter is non-standard, and doesn't work in PhantomJS.
Diffstat (limited to 'app/views')
-rw-r--r--app/views/projects/protected_branches/_dropdown.html.haml17
-rw-r--r--app/views/projects/protected_branches/index.html.haml9
2 files changed, 18 insertions, 8 deletions
diff --git a/app/views/projects/protected_branches/_dropdown.html.haml b/app/views/projects/protected_branches/_dropdown.html.haml
new file mode 100644
index 00000000000..b803d932e67
--- /dev/null
+++ b/app/views/projects/protected_branches/_dropdown.html.haml
@@ -0,0 +1,17 @@
+= f.hidden_field(:name)
+
+= dropdown_tag("Protected Branch",
+ options: { title: "Pick protected branch", toggle_class: 'js-protected-branch-select js-filter-submit',
+ filter: true, dropdown_class: "dropdown-menu-selectable", placeholder: "Search protected branches",
+ footer_content: true,
+ data: { show_no: true, show_any: true, show_upcoming: true,
+ selected: params[:protected_branch_name],
+ project_id: @project.try(:id) } }) do
+
+ %ul.dropdown-footer-list.hidden.protected-branch-select-footer-list
+ %li
+ = link_to '#', title: "New Protected Branch", class: "create-new-protected-branch" do
+ Create new
+
+:javascript
+ new ProtectedBranchSelect();
diff --git a/app/views/projects/protected_branches/index.html.haml b/app/views/projects/protected_branches/index.html.haml
index 684cb175e68..5669713d9a1 100644
--- a/app/views/projects/protected_branches/index.html.haml
+++ b/app/views/projects/protected_branches/index.html.haml
@@ -21,7 +21,7 @@
.form-group
= f.label :name, "Branch", class: "label-light"
- = f.text_field(:name)
+ = render partial: "dropdown", locals: { f: f }
%p.help-block
= link_to "Wildcards", help_page_path(category: 'workflow', file: 'protected_branches', format: 'md', anchor: "wildcard-protected-branches")
such as
@@ -39,10 +39,3 @@
= f.submit "Protect", class: "btn-create btn protect-branch-btn", disabled: true
%hr
= render "branches_list"
-
-:javascript
- $("#protected_branch_name").select2({
- placeholder: "Select branch",
- createSearchChoice: function(term) { return { id: term, text: term }; },
- data: gon.open_branches
- })