Skip to content

Commit

Permalink
limit_max_content_count_on_search_page
Browse files Browse the repository at this point in the history
  • Loading branch information
NoelKova committed Aug 2, 2024
1 parent 8828d49 commit 4ab70b4
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 4ab70b4

Please sign in to comment.