Skip to content
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 50 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
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 Mar 5, 2024
ed28225
feat: Refine by XBlock type too
bradenmacdonald Mar 5, 2024
50ed3dd
chore: update to match backend changes
bradenmacdonald Mar 15, 2024
130ab39
feat: display breadcrumbs
bradenmacdonald Mar 15, 2024
8a963a9
chore: convert back to JSX
bradenmacdonald Mar 22, 2024
f454ec8
chore: change modal dialog title to match design
bradenmacdonald Mar 22, 2024
a32a48b
feat: move search controls to the modal header, add This/All dropdown
bradenmacdonald Mar 22, 2024
0fdc39a
feat: start to implement filter widget, improve result formatting
bradenmacdonald Mar 23, 2024
c3ad930
chore: upgrade to newer instantsearch package
bradenmacdonald Mar 23, 2024
62c3582
fix: use fixed height for the search modal
bradenmacdonald Mar 24, 2024
fa73255
feat: paragon search keywords field
bradenmacdonald Mar 24, 2024
dadaaac
feat: limit search to the current course
bradenmacdonald Mar 24, 2024
8a48d16
feat: show a bottom border on the filter header, per the design
bradenmacdonald Mar 24, 2024
46eaa2b
feat: implement filter by block (component) type
bradenmacdonald Mar 24, 2024
ce211be
docs: better docstring for SearchFilterWidget
bradenmacdonald Mar 24, 2024
b25b0c8
fix: i18n, close button zIndex
bradenmacdonald Mar 25, 2024
56bdce0
feat: Clear Filters button
bradenmacdonald Mar 25, 2024
1714ab1
feat: Adjust size of filter buttons
bradenmacdonald Mar 25, 2024
b8598fe
fix: styling of this course / all courses toggle button
bradenmacdonald Mar 25, 2024
a546b5b
feat: Display friendly names for component types
bradenmacdonald Mar 25, 2024
3966a38
fix: styling of scroll area for results
bradenmacdonald Mar 25, 2024
268712a
fix: the list of types shouldn't change order when selecting a filter
bradenmacdonald Mar 25, 2024
3f25217
fix: display friendly component type name in active filter indicator
bradenmacdonald Mar 25, 2024
cd0ae53
feat: show message if there's no "Type" filter options
bradenmacdonald Mar 26, 2024
ac76db2
feat: improve styling of the filter buttons per UX feedback
bradenmacdonald Mar 26, 2024
9ed967b
feat: filter by tags widget
bradenmacdonald Mar 26, 2024
4687caa
chore: remove fix that's now in upstream paragon :)
bradenmacdonald Mar 26, 2024
4c6b11c
feat: Simplify the "# of results" indicator.
bradenmacdonald Mar 26, 2024
8745b1c
chore: make i18n messages more consistent
bradenmacdonald Mar 26, 2024
d1b44d7
feat: add empty states
bradenmacdonald Mar 26, 2024
7b37866
fix: sorting of Component Type filter
bradenmacdonald Mar 26, 2024
968fda0
fix: Missing 'key' prop for React in list of tags
bradenmacdonald Mar 26, 2024
a81da5d
docs: expand JSDoc comments for the components
bradenmacdonald Mar 26, 2024
e39deb9
fix: styling of the "This Course" / "All courses" toggle
bradenmacdonald Mar 27, 2024
d162d91
feat: preserve the order of the user's block type filter selection
bradenmacdonald Mar 27, 2024
e2b285d
chore: fix lint issues
bradenmacdonald Mar 27, 2024
e60da45
chore: update with latest master branch
bradenmacdonald Mar 27, 2024
9c2b484
fix: type errors found in latest version of Paragon
bradenmacdonald Mar 27, 2024
2f2a3db
test: Add tests for the content search UI
bradenmacdonald Mar 27, 2024
7a62769
chore: revert Paragon version bump - introduces other issues
bradenmacdonald Apr 3, 2024
c114076
fix: <SearchModal> was causing any tests with the header to fail
bradenmacdonald Apr 3, 2024
a44bfc1
feat: add search icon and tests
rpenido Mar 28, 2024
0e96c7d
refactor: moving api and adding more tests
rpenido Mar 29, 2024
9096a12
fix: search API endpoint was re-fetched too often
bradenmacdonald Apr 3, 2024
1eb5f9b
test: fix broken test, remove broken test that was removed in other PR
bradenmacdonald Apr 3, 2024
a414f72
test: add a test for the "Tags" filter too
bradenmacdonald Apr 3, 2024
30689b6
fix: various fixes from Romulo
bradenmacdonald Apr 3, 2024
7f4d236
fix: more minor cleanups from Romulo
bradenmacdonald Apr 6, 2024
584e95a
chore: update this branch with latest master
bradenmacdonald Apr 8, 2024
650b733
chore: fix some missing internationalization
bradenmacdonald Apr 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 126 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"@fortawesome/free-regular-svg-icons": "5.15.4",
"@fortawesome/free-solid-svg-icons": "5.15.4",
"@fortawesome/react-fontawesome": "0.2.0",
"@meilisearch/instant-meilisearch": "^0.16.0",
"@meilisearch/instant-meilisearch": "^0.17.0",
"@openedx-plugins/course-app-calculator": "file:plugins/course-apps/calculator",
"@openedx-plugins/course-app-edxnotes": "file:plugins/course-apps/edxnotes",
"@openedx-plugins/course-app-learning_assistant": "file:plugins/course-apps/learning_assistant",
Expand Down Expand Up @@ -110,6 +110,7 @@
"axios": "^0.28.0",
"axios-mock-adapter": "1.22.0",
"eslint-import-resolver-webpack": "^0.13.8",
"fetch-mock-jest": "^1.5.1",
"glob": "7.2.3",
"husky": "7.0.4",
"jest-canvas-mock": "^2.5.2",
Expand Down
2 changes: 1 addition & 1 deletion src/content-tags-drawer/ContentTagsDropDownSelector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ const ContentTagsDropDownSelector = ({
<Icon
src={isOpen(tagData.value) ? ArrowDropUp : ArrowDropDown}
onClick={() => clickAndEnterHandler(tagData.value)}
tabIndex="-1"
tabIndex={-1}
/>
</div>
)}
Expand Down
2 changes: 1 addition & 1 deletion src/header/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const Header = ({
const [isShowSearchModalOpen, openSearchModal, closeSearchModal] = useToggle(false);

const studioBaseUrl = getConfig().STUDIO_BASE_URL;
const meiliSearchEnabled = getConfig().MEILISEARCH_ENABLED || null;
const meiliSearchEnabled = [true, 'true'].includes(getConfig().MEILISEARCH_ENABLED);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Liked it!

const mainMenuDropdowns = [
{
id: `${intl.formatMessage(messages['header.links.content'])}-dropdown-menu`,
Expand Down
1 change: 1 addition & 0 deletions src/index.scss
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@
@import "course-checklist/CourseChecklist";
@import "content-tags-drawer/ContentTagsDropDownSelector";
@import "content-tags-drawer/ContentTagsCollapsible";
@import "search-modal/SearchModal";
@import "certificates/scss/Certificates";
25 changes: 25 additions & 0 deletions src/search-modal/BlockTypeLabel.jsx
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;
25 changes: 25 additions & 0 deletions src/search-modal/ClearFiltersButton.jsx
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;
30 changes: 30 additions & 0 deletions src/search-modal/EmptyStates.jsx
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;
Loading
Loading