From 5ef360a0419766097f30663b69142ae55bd0b8e6 Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Mon, 2 Nov 2026 16:51:06 +0530 Subject: [PATCH 1/2] OpenConceptLab/ocl_issues#2987 | owner level concepts search --- src/components/search/SearchInput.jsx | 12 +++-- src/components/search/SearchInputDrawer.jsx | 52 +++++++++++++++++---- src/i18n/locales/en/translations.json | 1 + src/i18n/locales/es/translations.json | 1 + src/i18n/locales/pt-BR/translations.json | 1 + src/i18n/locales/zh/translations.json | 1 + 6 files changed, 54 insertions(+), 14 deletions(-) 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 && +