diff --git a/src/components/search/Search.jsx b/src/components/search/Search.jsx index f67b6b7b2..ea622ea29 100644 --- a/src/components/search/Search.jsx +++ b/src/components/search/Search.jsx @@ -26,6 +26,7 @@ import SearchResults from './SearchResults'; import SearchFilters from './SearchFilters' import ReleaseSearchInfo from './ReleaseSearchInfo' import { isReleaseOnlySearch } from './releaseOnlySearch' +import { getOwnerScopeFilters } from './ownerScopeFilters' import { OperationsContext } from '../app/LayoutContext'; import ReferenceFilters from '../repos/ReferenceFilters' import { EXCLUDE_FILTER_KEY } from './ResultConstants' @@ -361,9 +362,10 @@ const Search = props => { const handleResourceChange = (event, newTab) => { event.preventDefault() event.stopPropagation() - setFilters({}) + const ownerScope = getAppliedFacetFromQueryParam(getOwnerScopeFilters(location.search, newTab)) + setFilters(ownerScope) - history.push(getCurrentLayoutURL(getQueryParams(input, page, pageSize, {}), newTab)) + history.push(getCurrentLayoutURL(getQueryParams(input, page, pageSize, ownerScope), newTab)) } const getURL = __resource => { diff --git a/src/components/search/SearchInput.jsx b/src/components/search/SearchInput.jsx index 1fb0b95f3..2b19d63e8 100644 --- a/src/components/search/SearchInput.jsx +++ b/src/components/search/SearchInput.jsx @@ -94,17 +94,17 @@ const SearchInput = props => { return false } - const initiateSearch = (event, global, isMatch, forcedType) => { - performSearch(event, input, global, isMatch, forcedType) + const initiateSearch = (event, global, isMatch, forcedType, ownerScope) => { + performSearch(event, input, global, isMatch, forcedType, ownerScope) setOpen(false) setTimeout(blurInput, 1000) } - const performSearch = (event, value, global, isMatch, forcedType) => { + const performSearch = (event, value, global, isMatch, forcedType, ownerScope) => { event.preventDefault() event.stopPropagation() - props.onSearch ? props.onSearch(value) : moveToSearchPage(value, global, isMatch, forcedType) + props.onSearch ? props.onSearch(value) : moveToSearchPage(value, global, isMatch, forcedType, ownerScope) } const blurInput = () => { @@ -133,7 +133,7 @@ const SearchInput = props => { return URL } - const moveToSearchPage = (value, global, isMatch, forcedType) => { + const moveToSearchPage = (value, global, isMatch, forcedType, ownerScope) => { if(!props.nested || global) { let _input = value || ''; const queryParams = new URLSearchParams(location.search) @@ -143,6 +143,8 @@ const SearchInput = props => { // A facet filter (Class/Map Type) from a prior Searchlight search is unrelated to // this new query - drop it so it doesn't silently carry over. queryParams.delete('filters') + if(ownerScope) + queryParams.set('filters', JSON.stringify(ownerScope)) // A new search term means a different result set -- start over from the first page. queryParams.delete('page') if(isMatch) diff --git a/src/components/search/SearchInputDrawer.jsx b/src/components/search/SearchInputDrawer.jsx index 898327df5..9afbeef4f 100644 --- a/src/components/search/SearchInputDrawer.jsx +++ b/src/components/search/SearchInputDrawer.jsx @@ -98,13 +98,21 @@ const SearchInputDrawer = ({open, onClose, input, initiateSearch, inputProps, is const user = getCurrentUser() const canMatchSemantic = Boolean(isNested && (contextRepo?.version || version) !== 'HEAD' && contextRepo?.match_algorithms?.includes('llm') && user?.username && (!resource || resource === 'concepts')) && hasAuthGroup(user, 'mapper-approved') && hasAuthGroup(user, 'core_user') - let lastIndex = isNested ? 2 : 1 + const ownerScope = {owner, ownerType: ownerType === 'orgs' ? 'Organization' : 'User'} + const canSearchOwnerConcepts = Boolean(isNested && (ownerType === 'orgs' || ownerType === 'users') && owner && !isURLRegistry) + const ownerConceptsIndex = canSearchOwnerConcepts ? 2 : null + const globalIndex = isNested ? (canSearchOwnerConcepts ? 3 : 2) : 1 + const matchIndex = globalIndex + 1 + let lastIndex = globalIndex if (canMatchSemantic) lastIndex += 1 const inputPlaceholder = input || '...' const onClickOption = (event, nested) => { event.persist() - initiateSearch(event, !nested, event?.currentTarget?.id === 'match_repo' && canMatchSemantic) + if(event?.currentTarget?.id === 'search_owner_concepts') + initiateSearch(event, true, false, 'concepts', ownerScope) + else + initiateSearch(event, !nested, event?.currentTarget?.id === 'match_repo' && canMatchSemantic) } const onRemoveFilter = () => { removeFilter() @@ -229,7 +237,11 @@ const SearchInputDrawer = ({open, onClose, input, initiateSearch, inputProps, is inputRef.current.blur() if(focus === 1) inputProps.handleKeyPress(event) - else if(focus === 3 && canMatchSemantic) { + else if(focus === ownerConceptsIndex) { + setFocus(1) + initiateSearch(event, true, false, 'concepts', ownerScope) + } + else if(focus === matchIndex && canMatchSemantic) { initiateSearch(event, false, true) } else { @@ -408,25 +420,47 @@ const SearchInputDrawer = ({open, onClose, input, initiateSearch, inputProps, is onKeyDown={event => onItemKeyDown(event, 1)} /> } + { + canSearchOwnerConcepts && +