From 6e0f7af9753975d1ede352dcc24242c236c6a053 Mon Sep 17 00:00:00 2001 From: Michael Ritter Date: Tue, 29 Jul 2025 14:53:23 -0600 Subject: [PATCH 01/38] Add some docs for search --- src/actions/search.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/actions/search.js b/src/actions/search.js index cb0c7017..77375319 100644 --- a/src/actions/search.js +++ b/src/actions/search.js @@ -94,6 +94,17 @@ const buildSearchPath = (csid, subresource, config, recordServicePath, vocabular */ const buildAdvancedSearchPath = () => '/advancedsearch'; +/** + * Build and dispatch a search + * + * @param {*} config The cspace configuration + * @param {*} searchName The search being executed (e.g. SEARCH_RESULT_PAGE_SEARCH_NAME) + * @param {*} searchDescriptor The search descriptor (record type, query params, etc) + * @param {*} listType The type of list being returned by the API (common, advancedsearch, etc) + * @param {*} columnSetName The columns for the view being returned, used for sort fields + * @param {*} isNewSearch If the search should use the new API + * @returns + */ export const search = (config, searchName, searchDescriptor, listType = 'common', columnSetName = 'default', isNewSearch = false) => (dispatch, getState) => { const recordType = searchDescriptor.get('recordType'); const vocabulary = searchDescriptor.get('vocabulary'); From 568d0e6b5bde9a13c97dd29856b7fdd681f01c54 Mon Sep 17 00:00:00 2001 From: Michael Ritter Date: Tue, 29 Jul 2025 14:55:38 -0600 Subject: [PATCH 02/38] Use search list type and api --- .../pages/search/SearchResultRoute.jsx | 2 +- src/components/pages/search/SearchResults.jsx | 25 ++++++++++++++----- src/components/search/SearchResultFooter.jsx | 5 ++-- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/components/pages/search/SearchResultRoute.jsx b/src/components/pages/search/SearchResultRoute.jsx index c71c62d8..96bde26d 100644 --- a/src/components/pages/search/SearchResultRoute.jsx +++ b/src/components/pages/search/SearchResultRoute.jsx @@ -20,6 +20,6 @@ export default function SearchResultRoute(props) { ['recordTypes', recordType, 'serviceConfig', 'features', 'updatedSearch']); return isNewSearch - ? + ? : ; } diff --git a/src/components/pages/search/SearchResults.jsx b/src/components/pages/search/SearchResults.jsx index c44f2f86..56a4f90b 100644 --- a/src/components/pages/search/SearchResults.jsx +++ b/src/components/pages/search/SearchResults.jsx @@ -34,6 +34,10 @@ const selectBarPropTypes = { toggleBar: PropTypes.object, }; +const propTypes = { + isNewSearch: PropTypes.bool, +}; + export function SimpleSelectBar({ toggleBar }) { // button bar (relate/export) const exportButton = ( @@ -190,21 +194,28 @@ export default function SearchResults(props) { const dispatch = useDispatch(); const history = useHistory(); + const { + isNewSearch, + } = props; + + const listType = isNewSearch ? 'search' : 'common'; const normalizedQuery = normalizeQuery(props, config); const searchDescriptor = getSearchDescriptor(normalizedQuery, props); useEffect(() => { setPreferredPageSize(props, dispatch); - dispatch(search(config, SEARCH_RESULT_PAGE_SEARCH_NAME, searchDescriptor, 'common')); // , 'common', true)); + dispatch(search(config, SEARCH_RESULT_PAGE_SEARCH_NAME, searchDescriptor, listType, 'common', isNewSearch)); }, [normalizedQuery, searchDescriptor]); // todo: should these be called in each component? they're at the top level for now // as to not make too many changes at once + /* const searchResults = useSelector((state) => getSearchResult(state, SEARCH_RESULT_PAGE_SEARCH_NAME, searchDescriptor)); const searchErrors = useSelector((state) => getSearchError(state, SEARCH_RESULT_PAGE_SEARCH_NAME, searchDescriptor)); + */ const isSidebarOpen = useSelector((state) => isSearchResultSidebarOpen(state)); const toggles = [ @@ -241,7 +252,7 @@ export default function SearchResults(props) { let searchDisplay; if (display === 'table') { - searchDisplay = ; + searchDisplay = ; } else if (display === 'list') { searchDisplay = ; } else { @@ -272,16 +283,17 @@ export default function SearchResults(props) {
{searchDisplay} - +
{sidebarPosition === 'right' ? sidebar : null} @@ -289,4 +301,5 @@ export default function SearchResults(props) { ); } +SearchResults.propTypes = propTypes; SimpleSelectBar.propTypes = selectBarPropTypes; diff --git a/src/components/search/SearchResultFooter.jsx b/src/components/search/SearchResultFooter.jsx index 82fe56bb..061da25c 100644 --- a/src/components/search/SearchResultFooter.jsx +++ b/src/components/search/SearchResultFooter.jsx @@ -5,20 +5,20 @@ import { useHistory, useLocation } from 'react-router-dom'; import qs from 'qs'; import Pager from './Pager'; import { useConfig } from '../config/ConfigProvider'; -import { getListType } from '../../helpers/searchHelpers'; import { SEARCH_RESULT_PAGE_SEARCH_NAME } from '../../constants/searchNames'; import { getSearchResult } from '../../reducers'; import { setSearchResultPagePageSize } from '../../actions/prefs'; const propTypes = { searchDescriptor: PropTypes.object, + listType: PropTypes.string, }; /** * A wrapper around a Pager to query for search results and populate the pagination info * @returns A wrapped in a