Skip to content

Commit

Permalink
refactor: moving Stats
Browse files Browse the repository at this point in the history
  • Loading branch information
rpenido committed Jul 3, 2024
1 parent 1bf2708 commit 6aa1b0c
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/library-authoring/LibraryAuthoringPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import {
FilterByTags,
SearchContextProvider,
SearchKeywordsField,
Stats,
} from '../search-manager';
import Stats from '../search-modal/Stats';
import LibraryComponents from './components/LibraryComponents';
import LibraryCollections from './LibraryCollections';
import LibraryHome from './LibraryHome';
Expand Down
4 changes: 2 additions & 2 deletions src/search-modal/Stats.tsx → src/search-manager/Stats.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import { FormattedMessage } from '@edx/frontend-platform/i18n';
import messages from './messages';
import { useSearchContext } from '../search-manager';
import { useSearchContext } from './SearchManager';

/**
* Simple component that displays the # of matching results
*/
const Stats: React.FC<Record<never, never>> = () => {
const Stats: React.FC = () => {
const { totalHits, searchKeywords, canClearFilters } = useSearchContext();

if (!searchKeywords && !canClearFilters) {
Expand Down
1 change: 1 addition & 0 deletions src/search-manager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export { default as ClearFiltersButton } from './ClearFiltersButton';
export { default as FilterByBlockType } from './FilterByBlockType';
export { default as FilterByTags } from './FilterByTags';
export { default as SearchKeywordsField } from './SearchKeywordsField';
export { default as Stats } from './Stats';
export { HIGHLIGHT_PRE_TAG, HIGHLIGHT_POST_TAG } from './data/api';

export type { ContentHit } from './data/api';
5 changes: 5 additions & 0 deletions src/search-manager/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ const messages = defineMessages({
defaultMessage: 'Submit tag keyword search',
description: 'Text shown to screen reader users for the search button on the tags keyword search',
},
numResults: {
id: 'course-authoring.course-search.num-results',
defaultMessage: '{numResults, plural, one {# result} other {# results}} found',
description: 'This count displays how many matching results were found from the user\'s search',
},
});

export default messages;
2 changes: 1 addition & 1 deletion src/search-modal/SearchUI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import {
FilterByTags,
SearchContextProvider,
SearchKeywordsField,
Stats,
} from '../search-manager';
import EmptyStates from './EmptyStates';
import SearchResults from './SearchResults';
import Stats from './Stats';
import messages from './messages';

const SearchUI: React.FC<{ courseId: string, closeSearchModal?: () => void }> = (props) => {
Expand Down
5 changes: 0 additions & 5 deletions src/search-modal/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@ const messages = defineMessages({
defaultMessage: 'Video',
description: 'Name of the "Video" component type in Studio',
},
numResults: {
id: 'course-authoring.course-search.num-results',
defaultMessage: '{numResults, plural, one {# result} other {# results}} found',
description: 'This count displays how many matching results were found from the user\'s search',
},
searchAllCourses: {
id: 'course-authoring.course-search.searchAllCourses',
defaultMessage: 'All courses',
Expand Down

0 comments on commit 6aa1b0c

Please sign in to comment.