-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
You can add collection filters to a dashboard and then use them in the search bar on the index page. eg. `email:[email protected]` However, these collection filters are not discoverable. You have to know about them already to know how to use them. This change introduces a tooltip which lists the available collection filters, allowing all users to discover what is available. The tooltip icon is `question-mark-circle` from [heroicons] (MIT licensed) We use [anchor positioning] with a [polyfill] to position the [popover] by the tooltip. Some basic JavaScript is introduced to show/hide the popover on hover to ensure the tooltip behaviour works as expected for a tooltip. I've had a first pass at the design, borrowing from existing styles. But I don't feel strongly about it if we want to go in a different direction. Do we want an option to disable the tooltip even if there are collection filters? [heroicons]: https://heroicons.com/solid [anchor positioning]: https://developer.mozilla.org/en-US/docs/Web/CSS/position-anchor [polyfill]: https://github.com/oddbird/css-anchor-positioning [popover]: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/popover Closes #2750
- Loading branch information
1 parent
841b091
commit 7b11e28
Showing
13 changed files
with
202 additions
and
12 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,54 @@ def have_a_search_bar | |
end | ||
end | ||
|
||
describe "search bar tooltip" do | ||
def have_a_search_tooltip | ||
have_css("button[popovertarget=search-tooltip]") | ||
end | ||
|
||
def search_tooltip_icon | ||
find("button[popovertarget=search-tooltip]") | ||
end | ||
|
||
it "is visible when the current dashboard has collection filters" do | ||
visit admin_customers_path | ||
|
||
expect(page).to have_a_search_tooltip | ||
end | ||
|
||
context "when clicked" do | ||
it "shows a popover with the available filters" do | ||
visit admin_customers_path | ||
|
||
search_tooltip_icon.click | ||
|
||
expect(page).to have_content("Use filters to refine your search") | ||
expect(page).to have_content("vip:<value>") | ||
expect(page).to have_content("kind:<value>") | ||
end | ||
end | ||
|
||
it "is hidden when the current dashboard has no collection filters" do | ||
stub_const("CustomerDashboard::COLLECTION_FILTERS", {}) | ||
|
||
visit admin_customers_path | ||
|
||
expect(page).not_to have_a_search_tooltip | ||
end | ||
|
||
it "is hidden when nothing is searchable in the current dashboard" do | ||
CustomerDashboard::ATTRIBUTE_TYPES.each do |_name, field_class| | ||
allow(field_class).to( | ||
receive(:searchable?).and_return(false) | ||
) | ||
end | ||
|
||
visit admin_customers_path | ||
|
||
expect(page).not_to have_a_search_tooltip | ||
end | ||
end | ||
|
||
scenario "admin searches for customer by email", :js do | ||
query = "[email protected]" | ||
perfect_match = create(:customer, email: "[email protected]") | ||
|