-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Content Search Modal: Filters [FC-0040] #918
Merged
Merged
Changes from all commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
80ef950
feat: Prototype search UI using Instantsearch + Meilisearch
bradenmacdonald ed28225
feat: Refine by XBlock type too
bradenmacdonald 50ed3dd
chore: update to match backend changes
bradenmacdonald 130ab39
feat: display breadcrumbs
bradenmacdonald 8a963a9
chore: convert back to JSX
bradenmacdonald f454ec8
chore: change modal dialog title to match design
bradenmacdonald a32a48b
feat: move search controls to the modal header, add This/All dropdown
bradenmacdonald 0fdc39a
feat: start to implement filter widget, improve result formatting
bradenmacdonald c3ad930
chore: upgrade to newer instantsearch package
bradenmacdonald 62c3582
fix: use fixed height for the search modal
bradenmacdonald fa73255
feat: paragon search keywords field
bradenmacdonald dadaaac
feat: limit search to the current course
bradenmacdonald 8a48d16
feat: show a bottom border on the filter header, per the design
bradenmacdonald 46eaa2b
feat: implement filter by block (component) type
bradenmacdonald ce211be
docs: better docstring for SearchFilterWidget
bradenmacdonald b25b0c8
fix: i18n, close button zIndex
bradenmacdonald 56bdce0
feat: Clear Filters button
bradenmacdonald 1714ab1
feat: Adjust size of filter buttons
bradenmacdonald b8598fe
fix: styling of this course / all courses toggle button
bradenmacdonald a546b5b
feat: Display friendly names for component types
bradenmacdonald 3966a38
fix: styling of scroll area for results
bradenmacdonald 268712a
fix: the list of types shouldn't change order when selecting a filter
bradenmacdonald 3f25217
fix: display friendly component type name in active filter indicator
bradenmacdonald cd0ae53
feat: show message if there's no "Type" filter options
bradenmacdonald ac76db2
feat: improve styling of the filter buttons per UX feedback
bradenmacdonald 9ed967b
feat: filter by tags widget
bradenmacdonald 4687caa
chore: remove fix that's now in upstream paragon :)
bradenmacdonald 4c6b11c
feat: Simplify the "# of results" indicator.
bradenmacdonald 8745b1c
chore: make i18n messages more consistent
bradenmacdonald d1b44d7
feat: add empty states
bradenmacdonald 7b37866
fix: sorting of Component Type filter
bradenmacdonald 968fda0
fix: Missing 'key' prop for React in list of tags
bradenmacdonald a81da5d
docs: expand JSDoc comments for the components
bradenmacdonald e39deb9
fix: styling of the "This Course" / "All courses" toggle
bradenmacdonald d162d91
feat: preserve the order of the user's block type filter selection
bradenmacdonald e2b285d
chore: fix lint issues
bradenmacdonald e60da45
chore: update with latest master branch
bradenmacdonald 9c2b484
fix: type errors found in latest version of Paragon
bradenmacdonald 2f2a3db
test: Add tests for the content search UI
bradenmacdonald 7a62769
chore: revert Paragon version bump - introduces other issues
bradenmacdonald c114076
fix: <SearchModal> was causing any tests with the header to fail
bradenmacdonald a44bfc1
feat: add search icon and tests
rpenido 0e96c7d
refactor: moving api and adding more tests
rpenido 9096a12
fix: search API endpoint was re-fetched too often
bradenmacdonald 1eb5f9b
test: fix broken test, remove broken test that was removed in other PR
bradenmacdonald a414f72
test: add a test for the "Tags" filter too
bradenmacdonald 30689b6
fix: various fixes from Romulo
bradenmacdonald 7f4d236
fix: more minor cleanups from Romulo
bradenmacdonald 584e95a
chore: update this branch with latest master
bradenmacdonald 650b733
chore: fix some missing internationalization
bradenmacdonald File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* eslint-disable react/prop-types */ | ||
// @ts-check | ||
import React from 'react'; | ||
import { FormattedMessage } from '@edx/frontend-platform/i18n'; | ||
import messages from './messages'; | ||
|
||
/** | ||
* Displays a friendly, localized text name for the given XBlock/component type | ||
* e.g. `vertical` becomes `"Unit"` | ||
* @type {React.FC<{type: string}>} | ||
*/ | ||
const BlockTypeLabel = ({ type }) => { | ||
// TODO: Load the localized list of Component names from Studio REST API? | ||
const msg = messages[`blockType.${type}`]; | ||
|
||
if (msg) { | ||
return <FormattedMessage {...msg} />; | ||
} | ||
// Replace underscores and hypens with spaces, then let the browser capitalize this | ||
// in a locale-aware way to get a reasonable display value. | ||
// e.g. 'drag-and-drop-v2' -> "Drag And Drop V2" | ||
return <span style={{ textTransform: 'capitalize' }}>{type.replace(/[_-]/g, ' ')}</span>; | ||
}; | ||
|
||
export default BlockTypeLabel; |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* eslint-disable react/prop-types */ | ||
// @ts-check | ||
import React from 'react'; | ||
import { useClearRefinements } from 'react-instantsearch'; | ||
import { FormattedMessage } from '@edx/frontend-platform/i18n'; | ||
import { Button } from '@openedx/paragon'; | ||
import messages from './messages'; | ||
|
||
/** | ||
* A button that appears when at least one filter is active, and will clear the filters when clicked. | ||
* @type {React.FC<Record<never, never>>} | ||
*/ | ||
const ClearFiltersButton = () => { | ||
const { refine, canRefine } = useClearRefinements(); | ||
if (canRefine) { | ||
return ( | ||
<Button variant="link" size="sm" onClick={refine}> | ||
<FormattedMessage {...messages.clearFilters} /> | ||
</Button> | ||
); | ||
} | ||
return null; | ||
}; | ||
|
||
export default ClearFiltersButton; |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* eslint-disable react/prop-types */ | ||
// @ts-check | ||
import React from 'react'; | ||
import { useStats, useClearRefinements } from 'react-instantsearch'; | ||
|
||
/** | ||
* If the user hasn't put any keywords/filters yet, display an "empty state". | ||
* Likewise, if the results are empty (0 results), display a special message. | ||
* Otherwise, display the results, which are assumed to be the children prop. | ||
* @type {React.FC<{children: React.ReactElement}>} | ||
*/ | ||
const EmptyStates = ({ children }) => { | ||
const { nbHits, query } = useStats(); | ||
const { canRefine: hasFiltersApplied } = useClearRefinements(); | ||
const hasQuery = !!query; | ||
|
||
if (!hasQuery && !hasFiltersApplied) { | ||
// We haven't started the search yet. Display the "start your search" empty state | ||
// Note this isn't localized because it's going to be replaced in a fast-follow PR. | ||
return <p className="text-muted text-center mt-6">Enter a keyword or select a filter to begin searching.</p>; | ||
} | ||
if (nbHits === 0) { | ||
// Note this isn't localized because it's going to be replaced in a fast-follow PR. | ||
return <p className="text-muted text-center mt-6">No results found. Change your search and try again.</p>; | ||
} | ||
|
||
return children; | ||
}; | ||
|
||
export default EmptyStates; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Liked it!