Commit 0d1fa878 authored by Luke Bennett's avatar Luke Bennett

Changed compare dropdowns to dropdowns with isolated search input

Updated compare specs
parent 166c6cd8
...@@ -23,8 +23,9 @@ ...@@ -23,8 +23,9 @@
selectable: true, selectable: true,
filterable: true, filterable: true,
filterByText: true, filterByText: true,
fieldName: $dropdown.attr('name'), toggleLabel: true,
filterInput: 'input[type="text"]', fieldName: $dropdown.data('field-name'),
filterInput: 'input[type="search"]',
renderRow: function(ref) { renderRow: function(ref) {
var link; var link;
if (ref.header != null) { if (ref.header != null) {
......
...@@ -743,6 +743,19 @@ pre.light-well { ...@@ -743,6 +743,19 @@ pre.light-well {
.dropdown-menu { .dropdown-menu {
width: 300px; width: 300px;
} }
> .input-group > .compare-dropdown-toggle {
width: 200px;
.dropdown-toggle-text {
display: block;
height: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
width: 100%;
}
}
} }
.clearable-input { .clearable-input {
......
...@@ -5,13 +5,17 @@ ...@@ -5,13 +5,17 @@
.form-group.dropdown.compare-form-group.js-compare-from-dropdown .form-group.dropdown.compare-form-group.js-compare-from-dropdown
.input-group.inline-input-group .input-group.inline-input-group
%span.input-group-addon from %span.input-group-addon from
= text_field_tag :from, params[:from], class: "form-control js-compare-dropdown", required: true, data: { refs_url: refs_namespace_project_path(@project.namespace, @project), toggle: "dropdown", target: ".js-compare-from-dropdown", selected: params[:from].presence } = hidden_field_tag :from, params[:from]
= button_tag type: 'button', class: "form-control compare-dropdown-toggle js-compare-dropdown", required: true, data: { refs_url: refs_namespace_project_path(@project.namespace, @project), toggle: "dropdown", target: ".js-compare-from-dropdown", selected: params[:from], field_name: :from } do
.dropdown-toggle-text= params[:from] || 'Select branch/tag'
= render "ref_dropdown" = render "ref_dropdown"
= "..." = "..."
.form-group.dropdown.compare-form-group.js-compare-to-dropdown .form-group.dropdown.compare-form-group.js-compare-to-dropdown
.input-group.inline-input-group .input-group.inline-input-group
%span.input-group-addon to %span.input-group-addon to
= text_field_tag :to, params[:to], class: "form-control js-compare-dropdown", required: true, data: { refs_url: refs_namespace_project_path(@project.namespace, @project), toggle: "dropdown", target: ".js-compare-to-dropdown", selected: params[:to].presence } = hidden_field_tag :to, params[:to]
= button_tag type: 'button', class: "form-control compare-dropdown-toggle js-compare-dropdown", required: true, data: { refs_url: refs_namespace_project_path(@project.namespace, @project), toggle: "dropdown", target: ".js-compare-to-dropdown", selected: params[:to], field_name: :to } do
.dropdown-toggle-text= params[:to] || 'Select branch/tag'
= render "ref_dropdown" = render "ref_dropdown"
   
= button_tag "Compare", class: "btn btn-create commits-compare-btn" = button_tag "Compare", class: "btn btn-create commits-compare-btn"
......
.dropdown-menu.dropdown-menu-selectable .dropdown-menu.dropdown-menu-selectable
= dropdown_title "Select branch/tag" = dropdown_title "Select branch/tag"
= dropdown_filter "Filter by branch/tag"
= dropdown_content = dropdown_content
= dropdown_loading = dropdown_loading
...@@ -12,15 +12,16 @@ describe "Compare", js: true do ...@@ -12,15 +12,16 @@ describe "Compare", js: true do
describe "branches" do describe "branches" do
it "pre-populates fields" do it "pre-populates fields" do
expect(page.find_field("from").value).to eq("master") expect(find(".js-compare-from-dropdown .dropdown-toggle-text")).to have_content("master")
expect(find(".js-compare-to-dropdown .dropdown-toggle-text")).to have_content("master")
end end
it "compares branches" do it "compares branches" do
fill_in "from", with: "fea" select_using_dropdown "from", "feature"
find("#from").click expect(find(".js-compare-from-dropdown .dropdown-toggle-text")).to have_content("feature")
click_link "feature" select_using_dropdown "to", "binary-encoding"
expect(page.find_field("from").value).to eq("feature") expect(find(".js-compare-to-dropdown .dropdown-toggle-text")).to have_content("binary-encoding")
click_button "Compare" click_button "Compare"
expect(page).to have_content "Commits" expect(page).to have_content "Commits"
...@@ -29,14 +30,21 @@ describe "Compare", js: true do ...@@ -29,14 +30,21 @@ describe "Compare", js: true do
describe "tags" do describe "tags" do
it "compares tags" do it "compares tags" do
fill_in "from", with: "v1.0" select_using_dropdown "from", "v1.0.0"
find("#from").click expect(find(".js-compare-from-dropdown .dropdown-toggle-text")).to have_content("v1.0.0")
click_link "v1.0.0" select_using_dropdown "to", "v1.1.0"
expect(page.find_field("from").value).to eq("v1.0.0") expect(find(".js-compare-to-dropdown .dropdown-toggle-text")).to have_content("v1.1.0")
click_button "Compare" click_button "Compare"
expect(page).to have_content "Commits" expect(page).to have_content "Commits"
end end
end end
def select_using_dropdown(dropdown_type, selection)
dropdown = find(".js-compare-#{dropdown_type}-dropdown")
dropdown.find(".compare-dropdown-toggle").click
dropdown.fill_in("Filter by branch/tag", with: selection)
click_link selection
end
end end
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