Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6e0f7af
Add some docs for search
mikejritter Jul 29, 2025
568d0e6
Use search list type and api
mikejritter Jul 29, 2025
bcb1c99
Update to retrieve errors/results via hooks
mikejritter Jul 29, 2025
619f3f5
Remove unused variables
mikejritter Jul 29, 2025
44838e3
Remove unused imports
mikejritter Jul 29, 2025
8869b00
Use search list type as the default
mikejritter Jul 29, 2025
9ee7931
Remove todo
mikejritter Jul 29, 2025
98d0df3
Route subresource queries to regular search page
mikejritter Jul 29, 2025
798fc5c
Clean up some todos/comments
mikejritter Jul 29, 2025
5a1a9be
rm comment
mikejritter Aug 26, 2025
b765a80
Simplify css
mikejritter Aug 26, 2025
e2eda6e
Start on styling for thumbnails
mikejritter Aug 26, 2025
76db459
Fetch search results and errors in SearchResultSummary
mikejritter Aug 26, 2025
19da6ef
Pass listType for correct traversal of search data
mikejritter Aug 26, 2025
b6487d7
Start work for adding thumbnails
mikejritter Aug 26, 2025
cd3b5c0
Correct item location path
mikejritter Aug 26, 2025
e2891ae
Move away from passing listType prop to using functions to get the de…
mikejritter Aug 28, 2025
4548504
Update tests for listType change
mikejritter Aug 29, 2025
b12df38
Use searchName constants
mikejritter Aug 29, 2025
14aedbe
Linting fixes
mikejritter Sep 2, 2025
ca29985
Check if searchDescriptor is not null
mikejritter Sep 2, 2025
667b1c9
Add tests for deriveListType and getListTypeForResult
mikejritter Sep 2, 2025
f66c29b
s/For/From
mikejritter Sep 2, 2025
d726311
Remove old getListType
mikejritter Sep 2, 2025
f1b19c3
Get list type from the search result in new components
mikejritter Sep 2, 2025
e241554
Remove some extraneous code/comments
mikejritter Sep 2, 2025
2ea0a9e
Missed import and add key
mikejritter Sep 2, 2025
63df751
Add comments
mikejritter Sep 2, 2025
bf19447
Additional null handling
mikejritter Sep 3, 2025
5210fee
Remove unused props/function
mikejritter Sep 5, 2025
229e65b
Remove unused render helper
mikejritter Sep 5, 2025
08ead5f
More null safety
mikejritter Sep 5, 2025
a31f3a6
Remove unused listType const and prop
mikejritter Sep 5, 2025
c475021
Use single function for reading search results
mikejritter Sep 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions src/actions/search.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import get from 'lodash/get';
import { getSearchResult, isSearchDirty, isSearchPending } from '../reducers';
import getSession from '../helpers/session';
import { convertAdvancedSearchConditionToNXQL } from '../helpers/searchHelpers';
import { convertAdvancedSearchConditionToNXQL, deriveSearchType } from '../helpers/searchHelpers';

import {
ERR_UNKNOWN_RECORD_TYPE,
Expand Down Expand Up @@ -94,7 +94,16 @@ const buildSearchPath = (csid, subresource, config, recordServicePath, vocabular
*/
const buildAdvancedSearchPath = () => '/advancedsearch';

export const search = (config, searchName, searchDescriptor, listType = 'common', columnSetName = 'default', isNewSearch = false) => (dispatch, getState) => {
/**
* 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 {*} columnSetName The columns for the view being returned, used for sort fields
* @returns
*/
export const search = (config, searchName, searchDescriptor, columnSetName = 'default') => (dispatch, getState) => {
const recordType = searchDescriptor.get('recordType');
const vocabulary = searchDescriptor.get('vocabulary');
const csid = searchDescriptor.get('csid');
Expand All @@ -121,6 +130,11 @@ export const search = (config, searchName, searchDescriptor, listType = 'common'
return Promise.resolve();
}

const {
listType,
searchType,
} = deriveSearchType(config, searchName, searchDescriptor);

const listTypeConfig = config.listTypes[listType];

dispatch({
Expand Down Expand Up @@ -269,7 +283,7 @@ export const search = (config, searchName, searchDescriptor, listType = 'common'
pathParts.push(subresourceServicePath);
}

const path = isNewSearch
const path = searchType === 'advanced'
? buildAdvancedSearchPath()
: buildSearchPath(csid, subresource, config, recordTypeServicePath, vocabularyServicePath);

Expand Down
3 changes: 1 addition & 2 deletions src/components/media/MediaViewerPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,13 @@ export default class MediaViewerPanel extends Component {
const {
columnSetName,
config,
listType,
name,
search,
searchDescriptor,
} = this.props;

if (search) {
search(config, name, searchDescriptor, listType, columnSetName);
search(config, name, searchDescriptor, columnSetName);
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/components/pages/AccountPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { canCreate, canRead } from '../../helpers/permissionHelpers';
import AdminTabButtonBar from '../admin/AdminTabButtonBar';
import AccountSearchBar from '../admin/AccountSearchBar';
import styles from '../../../styles/cspace-ui/AdminTab.css';
import { SEARCH_RESULT_ACCOUNT_PAGE } from '../../constants/searchNames';

const propTypes = {
history: PropTypes.shape({
Expand Down Expand Up @@ -295,7 +296,7 @@ export default class AccountPage extends Component {
isFiltered={!!filterValue}
linkItems={false}
listType="account"
name="accountPage"
name={SEARCH_RESULT_ACCOUNT_PAGE}
pageSizeOptionListName="searchResultPagePageSizes"
searchDescriptor={searchDescriptor}
title={title}
Expand Down
3 changes: 2 additions & 1 deletion src/components/pages/AuthRolePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { canCreate, canRead } from '../../helpers/permissionHelpers';
import AdminTabButtonBar from '../admin/AdminTabButtonBar';
import AuthRoleSearchBar from '../admin/AuthRoleSearchBar';
import styles from '../../../styles/cspace-ui/AdminTab.css';
import { SEARCH_RESULT_AUTH_ROLE_PAGE } from '../../constants/searchNames';

const propTypes = {
history: PropTypes.shape({
Expand Down Expand Up @@ -282,7 +283,7 @@ export default class AuthRolePage extends Component {
isFiltered={!!filterValue}
linkItems={false}
listType="role"
name="authRolePage"
name={SEARCH_RESULT_AUTH_ROLE_PAGE}
pageSizeOptionListName="searchResultPagePageSizes"
searchDescriptor={searchDescriptor}
title={title}
Expand Down
29 changes: 10 additions & 19 deletions src/components/pages/SearchResultPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import ExportModalContainer from '../../containers/search/ExportModalContainer';
import WatchedSearchResultTableContainer from '../../containers/search/WatchedSearchResultTableContainer';
import SearchToRelateModalContainer from '../../containers/search/SearchToRelateModalContainer';
import { canRelate } from '../../helpers/permissionHelpers';
import { getListType } from '../../helpers/searchHelpers';
import { deriveSearchType, getListTypeFromResult } from '../../helpers/searchHelpers';
import { SEARCH_RESULT_PAGE_SEARCH_NAME } from '../../constants/searchNames';

import {
Expand Down Expand Up @@ -206,8 +206,11 @@ export default class SearchResultPage extends Component {
} = this.context;

if (onItemSelectChange) {
// certainly we could use the search result at this point
const searchDescriptor = this.getSearchDescriptor();
const listType = this.getListType(searchDescriptor);
const {
listType,
} = deriveSearchType(config, SEARCH_RESULT_PAGE_SEARCH_NAME, searchDescriptor);

onItemSelectChange(
config, SEARCH_RESULT_PAGE_SEARCH_NAME, searchDescriptor, listType, index, selected,
Expand Down Expand Up @@ -366,14 +369,6 @@ export default class SearchResultPage extends Component {
}
}

getListType(searchDescriptor) {
const {
config,
} = this.context;

return getListType(config, searchDescriptor);
}

getSearchDescriptor() {
// FIXME: Refactor this into a wrapper component that calculates the search descriptor from
// location and params, and passes it into a child. This will eliminate the multiple calls to
Expand Down Expand Up @@ -574,9 +569,7 @@ export default class SearchResultPage extends Component {
// has set them to the defaults.

if (!Number.isNaN(searchQuery.get('p')) && !Number.isNaN(searchQuery.get('size')) && search) {
const listType = this.getListType(searchDescriptor);

search(config, SEARCH_RESULT_PAGE_SEARCH_NAME, searchDescriptor, listType);
search(config, SEARCH_RESULT_PAGE_SEARCH_NAME, searchDescriptor);
}
}

Expand Down Expand Up @@ -663,7 +656,7 @@ export default class SearchResultPage extends Component {
} = this.context;

const searchDescriptor = this.getSearchDescriptor();
const listType = this.getListType(searchDescriptor);
const { listType } = deriveSearchType(config, SEARCH_RESULT_PAGE_SEARCH_NAME, searchDescriptor);

let selectBar;

Expand Down Expand Up @@ -715,9 +708,8 @@ export default class SearchResultPage extends Component {
<SearchResultSummary
config={config}
listType={listType}
searchName={SEARCH_RESULT_PAGE_SEARCH_NAME}
searchDescriptor={searchDescriptor}
searchError={searchError}
searchResult={searchResult}
onEditSearchLinkClick={this.handleEditSearchLinkClick}
onPageSizeChange={this.handlePageSizeChange}
/>
Expand All @@ -732,8 +724,7 @@ export default class SearchResultPage extends Component {
config,
} = this.context;

const searchDescriptor = this.getSearchDescriptor();
const listType = this.getListType(searchDescriptor);
const listType = getListTypeFromResult(config, searchResult);
const listTypeConfig = config.listTypes[listType];
const { listNodeName } = listTypeConfig;

Expand Down Expand Up @@ -784,7 +775,7 @@ export default class SearchResultPage extends Component {

const searchDescriptor = this.getSearchDescriptor();

const listType = this.getListType(searchDescriptor);
const { listType } = deriveSearchType(config, SEARCH_RESULT_PAGE_SEARCH_NAME, searchDescriptor);

const recordType = searchDescriptor.get('recordType');
const vocabulary = searchDescriptor.get('vocabulary');
Expand Down
4 changes: 2 additions & 2 deletions src/components/pages/search/SearchResultRoute.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import { useConfig } from '../../config/ConfigProvider';
* @returns the component to render
*/
export default function SearchResultRoute(props) {
const { recordType } = useParams();
const { recordType, subresource } = useParams();
const config = useConfig();

const isNewSearch = get(config,
const isNewSearch = !subresource && get(config,
['recordTypes', recordType, 'serviceConfig', 'features', 'updatedSearch']);

return isNewSearch
Expand Down
40 changes: 19 additions & 21 deletions src/components/pages/search/SearchResults.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,9 @@ import styles from '../../../../styles/cspace-ui/SearchResults.css';
import selectStyles from '../../../../styles/cspace-ui/SelectBar.css';
import buttonBarStyles from '../../../../styles/cspace-ui/ButtonBar.css';

import {
setSearchResultPagePageSize,
} from '../../../actions/prefs';

import {
search,
} from '../../../actions/search';
import { getSearchError, getSearchResult, isSearchResultSidebarOpen } from '../../../reducers';
import { setSearchResultPagePageSize } from '../../../actions/prefs';
import { search } from '../../../actions/search';
import { isSearchResultSidebarOpen } from '../../../reducers';

const selectBarPropTypes = {
toggleBar: PropTypes.object,
Expand Down Expand Up @@ -183,6 +178,19 @@ function normalizeQuery(props, config) {
return query;
}

/**
* The page for displaying Search Results. Before rendering it first executes the search based on
* the query parameters provided by encapsulating them in a search descriptor and calling the search
* action in redux.
*
* Currently this is more for the new search views on CollectionObjects which includes a grid and
* detail based view compared to the older table based view. Ideally this be the only component for
* displaying search results but we first would need to make sure we only display the views which
* are supported for a given procedure or authority.
*
* @param {*} props
* @returns the SearchResults page component
*/
export default function SearchResults(props) {
const [display, setDisplay] = useState('table');
const [sidebarPosition, setSidebarPosition] = useState('right');
Expand All @@ -194,17 +202,9 @@ export default function SearchResults(props) {
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));
}, [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 = [
Expand Down Expand Up @@ -241,7 +241,7 @@ export default function SearchResults(props) {

let searchDisplay;
if (display === 'table') {
searchDisplay = <SearchResultTable searchDescriptor={searchDescriptor} listType="common" />;
searchDisplay = <SearchResultTable searchDescriptor={searchDescriptor} />;
} else if (display === 'list') {
searchDisplay = <SearchDetailList searchDescriptor={searchDescriptor} />;
} else {
Expand Down Expand Up @@ -272,10 +272,8 @@ export default function SearchResults(props) {
<div className={styles.results}>
<header>
<SearchResultSummary
listType="common"
config={config}
searchResult={searchResults}
searchError={searchErrors}
searchName={SEARCH_RESULT_PAGE_SEARCH_NAME}
searchDescriptor={searchDescriptor}
/>
<SimpleSelectBar toggleBar={displayToggles} />
Expand Down
3 changes: 2 additions & 1 deletion src/components/record/TermsUsedPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Immutable from 'immutable';
import { defineMessages, FormattedMessage } from 'react-intl';
import { getUpdatedTimestamp } from '../../helpers/recordDataHelpers';
import SearchPanelContainer from '../../containers/search/SearchPanelContainer';
import { SEARCH_RESULT_TERMS_USED_PANEL } from '../../constants/searchNames';

const messages = defineMessages({
title: {
Expand Down Expand Up @@ -121,7 +122,7 @@ export default class TermsUsedPanel extends Component {
config={config}
csid={csid}
listType="authRef"
name="termsUsedPanel"
name={SEARCH_RESULT_TERMS_USED_PANEL}
searchDescriptor={searchDescriptor}
recordType={recordType}
vocabulary={vocabulary}
Expand Down
3 changes: 2 additions & 1 deletion src/components/record/UsedByPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Immutable from 'immutable';
import { defineMessages, FormattedMessage } from 'react-intl';
import { getUpdatedTimestamp } from '../../helpers/recordDataHelpers';
import SearchPanelContainer from '../../containers/search/SearchPanelContainer';
import { SEARCH_RESULT_USED_BY_PANEL } from '../../constants/searchNames';

const messages = defineMessages({
title: {
Expand Down Expand Up @@ -142,7 +143,7 @@ export default class UsedByPanel extends Component {
config={config}
csid={csid}
listType="refDoc"
name="usedByPanel"
name={SEARCH_RESULT_USED_BY_PANEL}
searchDescriptor={searchDescriptor}
recordType={recordType}
vocabulary={vocabulary}
Expand Down
18 changes: 9 additions & 9 deletions src/components/search/SearchPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { baseComponents as inputComponents } from 'cspace-input';
import { ConnectedPanel as Panel } from '../../containers/layout/PanelContainer';
import SearchResultTableContainer from '../../containers/search/SearchResultTableContainer';
import SearchToRelateModalContainer from '../../containers/search/SearchToRelateModalContainer';
import { searchDescriptorToLocation } from '../../helpers/searchHelpers';
import { getListTypeFromResult, searchDescriptorToLocation } from '../../helpers/searchHelpers';
import Pager from './Pager';
import styles from '../../../styles/cspace-ui/SearchPanel.css';

Expand Down Expand Up @@ -235,14 +235,13 @@ export default class SearchPanel extends Component {
const {
columnSetName,
config,
listType,
name,
search,
searchDescriptor,
} = this.props;

if (search) {
search(config, name, searchDescriptor, listType, columnSetName);
search(config, name, searchDescriptor, columnSetName);
}
}

Expand Down Expand Up @@ -285,16 +284,17 @@ export default class SearchPanel extends Component {
const {
config,
isFiltered,
listType,
searchResult,
title,
} = this.props;

const listTypeConfig = config.listTypes[listType];
let totalItems = null;
if (searchResult) {
const listType = getListTypeFromResult(config, searchResult);
const listTypeConfig = config.listTypes[listType];

const totalItems = searchResult
? searchResult.getIn([listTypeConfig.listNodeName, 'totalItems'])
: null;
totalItems = searchResult.getIn([listTypeConfig.listNodeName, 'totalItems']);
}

let headerContent;

Expand Down Expand Up @@ -322,11 +322,11 @@ export default class SearchPanel extends Component {
renderFooter({ searchResult }) {
const {
config,
listType,
pageSizeOptionListName,
} = this.props;

if (searchResult) {
const listType = getListTypeFromResult(config, searchResult);
const listTypeConfig = config.listTypes[listType];
const list = searchResult.get(listTypeConfig.listNodeName);

Expand Down
4 changes: 2 additions & 2 deletions src/components/search/SearchResultFooter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ 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';
import { getListTypeFromResult } from '../../helpers/searchHelpers';

const propTypes = {
searchDescriptor: PropTypes.object,
Expand Down Expand Up @@ -72,7 +72,7 @@ export default function SearchResultFooter({ searchDescriptor }) {
});
}

const listType = getListType(searchDescriptor);
const listType = getListTypeFromResult(config, results);
const listTypeConfig = config.listTypes[listType];
const { listNodeName } = listTypeConfig;

Expand Down
Loading