Skip to content

Commit

Permalink
Merge pull request #1631 from SenseNet/fix/1570-search_page_limit_max…
Browse files Browse the repository at this point in the history
…_count

limit_max_content_count_on_search_page
  • Loading branch information
NoelKova authored Aug 5, 2024
2 parents 8828d49 + 4ab70b4 commit 3dad028
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
7 changes: 6 additions & 1 deletion apps/sensenet/src/components/search/search-results.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ export const SearchResults = () => {

{searchState.isLoading && <LinearProgress style={{ margin: '15px 15px 0' }} />}

<Typography style={{ margin: '1rem' }}>{localization.resultCount(searchState.resultCount)}</Typography>
<Typography style={{ margin: '1rem' }}>
{localization.resultCount(searchState.resultCount) +
(searchState.resultCount > searchState.maxSearchResult
? localization.onlyResultCountDisplayed(searchState.maxSearchResult)
: '')}
</Typography>

<CurrentContentContext.Provider value={ConstantContent.PORTAL_ROOT}>
<CurrentChildrenContext.Provider value={searchState.result}>
Expand Down
7 changes: 6 additions & 1 deletion apps/sensenet/src/context/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const SearchContext = createContext<{
setFilters: React.Dispatch<React.SetStateAction<Filters>>
result: GenericContent[]
resultCount: number
maxSearchResult: number
error: string
isLoading: boolean
}>({
Expand All @@ -41,6 +42,7 @@ const SearchContext = createContext<{
setFilters: () => null,
result: [],
resultCount: 0,
maxSearchResult: 0,
error: '',
isLoading: false,
})
Expand All @@ -52,6 +54,7 @@ export function SearchProvider({
}: PropsWithChildren<{ defaultTerm?: string; defaultFilters?: Filters }>) {
const repository = useRepository()
const history = useHistory()
const maxSearchResult = 200

const [term, setTerm] = useState(defaultTerm ?? '')
const [result, setResult] = useState<GenericContent[]>([])
Expand Down Expand Up @@ -93,6 +96,7 @@ export function SearchProvider({
] as Array<keyof GenericContent>)
: repository.configuration.requiredSelect,
expand: ['ModifiedBy'],
top: maxSearchResult,
},
requestInit: { signal: ac.signal },
})
Expand All @@ -116,7 +120,8 @@ export function SearchProvider({
}, [term, repository, history, filters])

return (
<SearchContext.Provider value={{ term, setTerm, filters, setFilters, result, resultCount, error, isLoading }}>
<SearchContext.Provider
value={{ term, setTerm, filters, setFilters, result, resultCount, maxSearchResult, error, isLoading }}>
{children}
</SearchContext.Provider>
)
Expand Down
1 change: 1 addition & 0 deletions apps/sensenet/src/localization/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ const values = {
queryHelperText: 'Enter a keyword',
clearTerm: 'Clear input',
resultCount: (count: number) => `${count} results`,
onlyResultCountDisplayed: (maxSearchResult: number) => ` (only the first ${maxSearchResult} are displayed)`,
openInSearchTitle: (term: string) => `See all results for '${term}'`,
openInSearchDescription: 'Opens the query expression in the Search view',
saveQuery: 'Save Query',
Expand Down

0 comments on commit 3dad028

Please sign in to comment.