1919import cx from "classnames" ;
2020import { ReactNode , useEffect , useRef } from "react" ;
2121import {
22+ Database ,
2223 Folder2Open ,
2324 Globe2 ,
2425 Icon ,
@@ -39,16 +40,18 @@ import {
3940} from "reactstrap" ;
4041
4142import ClampedParagraph from "../../../components/clamped/ClampedParagraph" ;
43+ import { RtkOrNotebooksError } from "../../../components/errors/RtkErrorAlert" ;
4244import { Loader } from "../../../components/Loader" ;
4345import Pagination from "../../../components/Pagination" ;
4446import { TimeCaption } from "../../../components/TimeCaption" ;
4547import { ABSOLUTE_ROUTES } from "../../../routing/routes.constants" ;
4648import useAppSelector from "../../../utils/customHooks/useAppSelector.hook" ;
4749import {
48- Group ,
49- Project ,
50- SearchEntity ,
51- User ,
50+ type DataConnector ,
51+ type Group ,
52+ type Project ,
53+ type SearchEntity ,
54+ type User ,
5255 searchV2Api ,
5356} from "../api/searchV2Api.api" ;
5457import useClampSearchPage from "../hooks/useClampSearchPage.hook" ;
@@ -107,8 +110,14 @@ function SearchV2ResultsContent() {
107110 return < Loader /> ;
108111 }
109112
113+ if ( searchResults . error ) {
114+ return (
115+ < RtkOrNotebooksError error = { searchResults . error } dismissible = { false } />
116+ ) ;
117+ }
118+
110119 if ( ! searchResults . data ?. items ?. length ) {
111- return query == null ? (
120+ return query == null || query === "" ? (
112121 < p > No results</ p >
113122 ) : (
114123 < >
@@ -136,6 +145,14 @@ function SearchV2ResultsContent() {
136145 return (
137146 < SearchV2ResultUser key = { `user-result-${ entity . id } ` } user = { entity } />
138147 ) ;
148+ } else if ( entity . type === "DataConnector" ) {
149+ entity ;
150+ return (
151+ < SearchV2ResultDataConnector
152+ key = { `user-result-${ entity . id } ` }
153+ dataConnector = { entity }
154+ />
155+ ) ;
139156 }
140157 // Unknown entity type, in case backend introduces new types before the UI catches up
141158 return < SearchV2ResultsUnknown key = { `unknown-result-${ index } ` } /> ;
@@ -216,6 +233,8 @@ export function EntityPill({
216233 ? People
217234 : entityType === "User"
218235 ? Person
236+ : entityType === "DataConnector"
237+ ? Database
219238 : Question ;
220239 const sizeClass =
221240 size == "sm"
@@ -379,6 +398,39 @@ function SearchV2ResultUser({ user }: SearchV2ResultUserProps) {
379398 ) ;
380399}
381400
401+ interface SearchV2ResultDataConnectorProps {
402+ dataConnector : DataConnector ;
403+ }
404+ function SearchV2ResultDataConnector ( {
405+ dataConnector,
406+ } : SearchV2ResultDataConnectorProps ) {
407+ const { id, name, namespace } = dataConnector ;
408+
409+ const namespaceUrl =
410+ namespace ?. type === "User"
411+ ? generatePath ( ABSOLUTE_ROUTES . v2 . users . show , {
412+ username : namespace ?. namespace ?? "" ,
413+ } )
414+ : generatePath ( ABSOLUTE_ROUTES . v2 . groups . show . root , {
415+ slug : namespace ?. namespace ?? "" ,
416+ } ) ;
417+ const hash = `data-connector-${ id } ` ;
418+ const dcUrl = `${ namespaceUrl } #${ hash } ` ;
419+
420+ return (
421+ < SearchV2ResultsContainer >
422+ < SearchV2CardTitle
423+ entityType = "DataConnector"
424+ entityUrl = { dcUrl }
425+ name = { name }
426+ namespace = { namespace ?. namespace ?? "" }
427+ namespaceUrl = { namespaceUrl }
428+ />
429+ < CardBody />
430+ </ SearchV2ResultsContainer >
431+ ) ;
432+ }
433+
382434function SearchV2ResultsUnknown ( ) {
383435 return (
384436 < SearchV2ResultsContainer >
0 commit comments