Commit 35e49d3b authored by Paul Slaughter's avatar Paul Slaughter

Merge branch '47814-search-view-labels' into 'master'

Resolve "Selected project in the search view is not fully readable"

Closes #47814

See merge request gitlab-org/gitlab-ce!31137
parents 2b7218cf f89a8fee
...@@ -37,9 +37,6 @@ export default class Search { ...@@ -37,9 +37,6 @@ export default class Search {
text(obj) { text(obj) {
return obj.full_name; return obj.full_name;
}, },
toggleLabel(obj) {
return `${$groupDropdown.data('defaultLabel')} ${obj.full_name}`;
},
clicked: () => Search.submitSearch(), clicked: () => Search.submitSearch(),
}); });
...@@ -70,9 +67,6 @@ export default class Search { ...@@ -70,9 +67,6 @@ export default class Search {
text(obj) { text(obj) {
return obj.name_with_namespace; return obj.name_with_namespace;
}, },
toggleLabel(obj) {
return `${$projectDropdown.data('defaultLabel')} ${obj.name_with_namespace}`;
},
clicked: () => Search.submitSearch(), clicked: () => Search.submitSearch(),
}); });
} }
......
...@@ -186,15 +186,12 @@ input[type='checkbox']:hover { ...@@ -186,15 +186,12 @@ input[type='checkbox']:hover {
} }
} }
.search-holder { .search-field-holder,
@include media-breakpoint-up(sm) { .project-filter-form {
display: flex;
}
.search-field-holder,
.project-filter-form {
flex: 1 0 auto; flex: 1 0 auto;
position: relative; position: relative;
.search-holder & {
margin-right: 0; margin-right: 0;
@include media-breakpoint-up(sm) { @include media-breakpoint-up(sm) {
...@@ -202,6 +199,7 @@ input[type='checkbox']:hover { ...@@ -202,6 +199,7 @@ input[type='checkbox']:hover {
} }
} }
.search-icon { .search-icon {
position: absolute; position: absolute;
left: 10px; left: 10px;
...@@ -215,9 +213,16 @@ input[type='checkbox']:hover { ...@@ -215,9 +213,16 @@ input[type='checkbox']:hover {
padding-left: $gl-padding + 15px; padding-left: $gl-padding + 15px;
padding-right: $gl-padding + 15px; padding-right: $gl-padding + 15px;
} }
}
.search-holder {
@include media-breakpoint-up(sm) {
display: flex;
}
.btn-search, .btn-search,
.btn-success { .btn-success,
.dropdown-menu-toggle {
width: 100%; width: 100%;
margin-top: 5px; margin-top: 5px;
...@@ -236,9 +241,6 @@ input[type='checkbox']:hover { ...@@ -236,9 +241,6 @@ input[type='checkbox']:hover {
} }
.dropdown-menu-toggle { .dropdown-menu-toggle {
width: 100%;
margin-top: 5px;
@include media-breakpoint-up(sm) { @include media-breakpoint-up(sm) {
width: 180px; width: 180px;
margin-top: 0; margin-top: 0;
...@@ -262,6 +264,25 @@ input[type='checkbox']:hover { ...@@ -262,6 +264,25 @@ input[type='checkbox']:hover {
} }
} }
.search-page-form {
.dropdown-menu-toggle,
.btn-search {
width: 100%;
}
.dropdown-menu-toggle {
@include media-breakpoint-up(lg) {
width: 240px;
}
}
.btn-search {
@include media-breakpoint-up(lg) {
width: auto;
}
}
}
// Disable webkit input icons, link to solution: https://stackoverflow.com/questions/9421551/how-do-i-remove-all-default-webkit-search-field-styling // Disable webkit input icons, link to solution: https://stackoverflow.com/questions/9421551/how-do-i-remove-all-default-webkit-search-field-styling
/* stylelint-disable property-no-vendor-prefix */ /* stylelint-disable property-no-vendor-prefix */
input[type='search']::-webkit-search-decoration, input[type='search']::-webkit-search-decoration,
......
...@@ -2,10 +2,11 @@ ...@@ -2,10 +2,11 @@
= hidden_field_tag :group_id, params[:group_id] = hidden_field_tag :group_id, params[:group_id]
- if params[:project_id].present? - if params[:project_id].present?
= hidden_field_tag :project_id, params[:project_id] = hidden_field_tag :project_id, params[:project_id]
.dropdown .dropdown.form-group.mb-lg-0.mx-lg-1
%button.dropdown-menu-toggle.js-search-group-dropdown{ type: "button", data: { toggle: "dropdown", default_label: _('Group:'), group_id: params[:group_id] } } %label.d-block{ for: "dashboard_search_group" }
= _("Group")
%button.dropdown-menu-toggle.js-search-group-dropdown.mt-0{ type: "button", id: "dashboard_search_group", data: { toggle: "dropdown", group_id: params[:group_id] } }
%span.dropdown-toggle-text %span.dropdown-toggle-text
= _("Group:")
- if @group.present? - if @group.present?
= @group.name = @group.name
- else - else
...@@ -17,10 +18,11 @@ ...@@ -17,10 +18,11 @@
= dropdown_content = dropdown_content
= dropdown_loading = dropdown_loading
.dropdown.project-filter .dropdown.project-filter.form-group.mb-lg-0.mx-lg-1
%button.dropdown-menu-toggle.js-search-project-dropdown{ type: "button", data: { toggle: "dropdown", default_label: _('Project:') } } %label.d-block{ for: "dashboard_search_project" }
= _("Project")
%button.dropdown-menu-toggle.js-search-project-dropdown.mt-0{ type: "button", id: "dashboard_search_project", data: { toggle: "dropdown"} }
%span.dropdown-toggle-text %span.dropdown-toggle-text
= _("Project:")
- if @project.present? - if @project.present?
= @project.full_name = @project.full_name
- else - else
......
= form_tag search_path, method: :get, class: 'js-search-form' do |f| = form_tag search_path, method: :get, class: 'search-page-form js-search-form' do |f|
= hidden_field_tag :snippets, params[:snippets] = hidden_field_tag :snippets, params[:snippets]
= hidden_field_tag :scope, params[:scope] = hidden_field_tag :scope, params[:scope]
.search-holder .d-lg-flex.align-items-end
.search-field-holder .search-field-holder.form-group.mr-lg-1.mb-lg-0
%label{ for: "dashboard_search" }
= _("What are you searching for?")
.position-relative
= search_field_tag :search, params[:search], placeholder: _("Search for projects, issues, etc."), class: "form-control search-text-input js-search-input", id: "dashboard_search", autofocus: true, spellcheck: false = search_field_tag :search, params[:search], placeholder: _("Search for projects, issues, etc."), class: "form-control search-text-input js-search-input", id: "dashboard_search", autofocus: true, spellcheck: false
= icon("search", class: "search-icon") = icon("search", class: "search-icon")
%button.search-clear.js-search-clear{ class: ("hidden" if !params[:search].present?), type: "button", tabindex: "-1" } %button.search-clear.js-search-clear{ class: ("hidden" if !params[:search].present?), type: "button", tabindex: "-1" }
...@@ -12,5 +15,6 @@ ...@@ -12,5 +15,6 @@
= _("Clear search") = _("Clear search")
- unless params[:snippets].eql? 'true' - unless params[:snippets].eql? 'true'
= render 'filter' = render 'filter'
= button_tag _("Search"), class: "btn btn-success btn-search" .d-flex-center.flex-column.flex-lg-row
= button_tag _("Search"), class: "btn btn-success btn-search form-control mt-lg-0 ml-lg-1 align-self-end"
= render_if_exists 'search/form_elasticsearch' = render_if_exists 'search/form_elasticsearch'
- @hide_top_links = true - @hide_top_links = true
- breadcrumb_title _("Search")
- page_title @search_term - page_title @search_term
- @hide_breadcrumbs = true
.page-title-holder.d-flex.align-items-center
%h1.page-title<
= _('Search')
.prepend-top-default .prepend-top-default
= render 'search/form' = render 'search/form'
......
---
title: Moved labels out of fields on Search page
merge_request: 31137
author:
type: fixed
...@@ -5260,9 +5260,6 @@ msgstr "" ...@@ -5260,9 +5260,6 @@ msgstr ""
msgid "Group was successfully updated." msgid "Group was successfully updated."
msgstr "" msgstr ""
msgid "Group:"
msgstr ""
msgid "Group: %{group_name}" msgid "Group: %{group_name}"
msgstr "" msgstr ""
...@@ -8486,9 +8483,6 @@ msgstr "" ...@@ -8486,9 +8483,6 @@ msgstr ""
msgid "Project visibility level will be changed to match namespace rules when transferring to a group." msgid "Project visibility level will be changed to match namespace rules when transferring to a group."
msgstr "" msgstr ""
msgid "Project:"
msgstr ""
msgid "ProjectActivityRSS|Subscribe" msgid "ProjectActivityRSS|Subscribe"
msgstr "" msgstr ""
...@@ -12437,6 +12431,9 @@ msgstr "" ...@@ -12437,6 +12431,9 @@ msgstr ""
msgid "Welcome to your Issue Board!" msgid "Welcome to your Issue Board!"
msgstr "" msgstr ""
msgid "What are you searching for?"
msgstr ""
msgid "When a runner is locked, it cannot be assigned to other projects" msgid "When a runner is locked, it cannot be assigned to other projects"
msgstr "" msgstr ""
......
...@@ -22,7 +22,7 @@ describe 'User uses header search field', :js do ...@@ -22,7 +22,7 @@ describe 'User uses header search field', :js do
fill_in('search', with: 'gitlab') fill_in('search', with: 'gitlab')
find('#search').native.send_keys(:enter) find('#search').native.send_keys(:enter)
page.within('.breadcrumbs-sub-title') do page.within('.page-title') do
expect(page).to have_content('Search') expect(page).to have_content('Search')
end end
end end
......
...@@ -22,7 +22,7 @@ describe 'User uses search filters', :js do ...@@ -22,7 +22,7 @@ describe 'User uses search filters', :js do
wait_for_requests wait_for_requests
page.within('.search-holder') do page.within('.search-page-form') do
click_link(group.name) click_link(group.name)
end end
......
# frozen_string_literal: true
require 'spec_helper'
describe 'search/_filter' do
context 'when the search page is opened' do
it 'displays the correct elements' do
render
expect(rendered).to have_selector('label[for="dashboard_search_group"]')
expect(rendered).to have_selector('button#dashboard_search_group')
expect(rendered).to have_selector('label[for="dashboard_search_project"]')
expect(rendered).to have_selector('button#dashboard_search_project')
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe 'search/_form' do
context 'when the search page is opened' do
it 'displays the correct elements' do
render
expect(rendered).to have_selector('.search-field-holder.form-group')
expect(rendered).to have_selector('label[for="dashboard_search"]')
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe 'search/show' do
let(:search_term) { nil }
before do
stub_template "search/_category.html.haml" => 'Category Partial'
stub_template "search/_results.html.haml" => 'Results Partial'
@search_term = search_term
render
end
context 'when the search page is opened' do
it 'displays the title' do
expect(rendered).to have_selector('h1.page-title', text: 'Search')
expect(rendered).not_to have_selector('h1.page-title code')
end
it 'does not render partials' do
expect(rendered).not_to render_template('search/_category')
expect(rendered).not_to render_template('search/_results')
end
end
context 'when search term is supplied' do
let(:search_term) { 'Search Foo' }
it 'renders partials' do
expect(rendered).to render_template('search/_category')
expect(rendered).to render_template('search/_results')
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