From 4ab70b46c6bd1da47322ba93728a81cbecca64d1 Mon Sep 17 00:00:00 2001 From: NoelKova Date: Fri, 2 Aug 2024 13:01:35 +0200 Subject: [PATCH] limit_max_content_count_on_search_page --- apps/sensenet/src/components/search/search-results.tsx | 7 ++++++- apps/sensenet/src/context/search.tsx | 7 ++++++- apps/sensenet/src/localization/default.ts | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/apps/sensenet/src/components/search/search-results.tsx b/apps/sensenet/src/components/search/search-results.tsx index f26e4b1fc..8ab6b2e6a 100644 --- a/apps/sensenet/src/components/search/search-results.tsx +++ b/apps/sensenet/src/components/search/search-results.tsx @@ -36,7 +36,12 @@ export const SearchResults = () => { {searchState.isLoading && } - {localization.resultCount(searchState.resultCount)} + + {localization.resultCount(searchState.resultCount) + + (searchState.resultCount > searchState.maxSearchResult + ? localization.onlyResultCountDisplayed(searchState.maxSearchResult) + : '')} + diff --git a/apps/sensenet/src/context/search.tsx b/apps/sensenet/src/context/search.tsx index f00b05e97..e2a4e96eb 100644 --- a/apps/sensenet/src/context/search.tsx +++ b/apps/sensenet/src/context/search.tsx @@ -27,6 +27,7 @@ const SearchContext = createContext<{ setFilters: React.Dispatch> result: GenericContent[] resultCount: number + maxSearchResult: number error: string isLoading: boolean }>({ @@ -41,6 +42,7 @@ const SearchContext = createContext<{ setFilters: () => null, result: [], resultCount: 0, + maxSearchResult: 0, error: '', isLoading: false, }) @@ -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([]) @@ -93,6 +96,7 @@ export function SearchProvider({ ] as Array) : repository.configuration.requiredSelect, expand: ['ModifiedBy'], + top: maxSearchResult, }, requestInit: { signal: ac.signal }, }) @@ -116,7 +120,8 @@ export function SearchProvider({ }, [term, repository, history, filters]) return ( - + {children} ) diff --git a/apps/sensenet/src/localization/default.ts b/apps/sensenet/src/localization/default.ts index 2ad618f45..c29788a22 100644 --- a/apps/sensenet/src/localization/default.ts +++ b/apps/sensenet/src/localization/default.ts @@ -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',