@@ -42,8 +42,19 @@ const Layout = () => {
4242 } ) ;
4343
4444 const registryPath = currentProject ?. registryPath || "" ;
45- const { data } = useLoadRegistry ( registryPath ) ;
4645
46+ // For global search, use the first available registry path (typically all projects share the same registry)
47+ // If projects have different registries, we use the first one as the "global" registry
48+ const globalRegistryPath =
49+ projectsData ?. projects ?. [ 0 ] ?. registryPath || registryPath ;
50+
51+ // Load filtered data for current project (for sidebar and page-level search)
52+ const { data } = useLoadRegistry ( registryPath , projectName ) ;
53+
54+ // Load unfiltered data for global search (across all projects)
55+ const { data : globalData } = useLoadRegistry ( globalRegistryPath ) ;
56+
57+ // Categories for page-level search (filtered to current project)
4758 const categories = data
4859 ? [
4960 {
@@ -84,31 +95,92 @@ const Layout = () => {
8495 ]
8596 : [ ] ;
8697
98+ // Helper function to extract project ID from an item
99+ const getProjectId = ( item : any ) : string => {
100+ // Try different possible locations for the project field
101+ return item ?. spec ?. project || item ?. project || projectName || "unknown" ;
102+ } ;
103+
104+ // Categories for global search (includes all projects)
105+ const globalCategories = globalData
106+ ? [
107+ {
108+ name : "Data Sources" ,
109+ data : ( globalData . objects . dataSources || [ ] ) . map ( ( item : any ) => ( {
110+ ...item ,
111+ projectId : getProjectId ( item ) ,
112+ } ) ) ,
113+ getLink : ( item : any ) => {
114+ const project = item ?. projectId || getProjectId ( item ) ;
115+ return `/p/${ project } /data-source/${ item . name } ` ;
116+ } ,
117+ } ,
118+ {
119+ name : "Entities" ,
120+ data : ( globalData . objects . entities || [ ] ) . map ( ( item : any ) => ( {
121+ ...item ,
122+ projectId : getProjectId ( item ) ,
123+ } ) ) ,
124+ getLink : ( item : any ) => {
125+ const project = item ?. projectId || getProjectId ( item ) ;
126+ return `/p/${ project } /entity/${ item . name } ` ;
127+ } ,
128+ } ,
129+ {
130+ name : "Features" ,
131+ data : ( globalData . allFeatures || [ ] ) . map ( ( item : any ) => ( {
132+ ...item ,
133+ projectId : getProjectId ( item ) ,
134+ } ) ) ,
135+ getLink : ( item : any ) => {
136+ const featureView = item ?. featureView ;
137+ const project = item ?. projectId || getProjectId ( item ) ;
138+ return featureView
139+ ? `/p/${ project } /feature-view/${ featureView } /feature/${ item . name } `
140+ : "#" ;
141+ } ,
142+ } ,
143+ {
144+ name : "Feature Views" ,
145+ data : ( globalData . mergedFVList || [ ] ) . map ( ( item : any ) => ( {
146+ ...item ,
147+ projectId : getProjectId ( item ) ,
148+ } ) ) ,
149+ getLink : ( item : any ) => {
150+ const project = item ?. projectId || getProjectId ( item ) ;
151+ return `/p/${ project } /feature-view/${ item . name } ` ;
152+ } ,
153+ } ,
154+ {
155+ name : "Feature Services" ,
156+ data : ( globalData . objects . featureServices || [ ] ) . map ( ( item : any ) => ( {
157+ ...item ,
158+ projectId : getProjectId ( item ) ,
159+ } ) ) ,
160+ getLink : ( item : any ) => {
161+ const serviceName = item ?. name || item ?. spec ?. name ;
162+ const project = item ?. projectId || getProjectId ( item ) ;
163+ return serviceName
164+ ? `/p/${ project } /feature-service/${ serviceName } `
165+ : "#" ;
166+ } ,
167+ } ,
168+ ]
169+ : [ ] ;
170+
87171 const handleSearchOpen = ( ) => {
88- console . log ( "Opening command palette - before state update" ) ; // Debug log
89172 setIsCommandPaletteOpen ( true ) ;
90- console . log ( "Command palette state should be updated to true" ) ;
91173 } ;
92174
93175 useEffect ( ( ) => {
94176 const handleKeyDown = ( event : KeyboardEvent ) => {
95- console . log (
96- "Layout key pressed:" ,
97- event . key ,
98- "metaKey:" ,
99- event . metaKey ,
100- "ctrlKey:" ,
101- event . ctrlKey ,
102- ) ;
103177 if ( ( event . metaKey || event . ctrlKey ) && event . key . toLowerCase ( ) === "k" ) {
104- console . log ( "Layout detected Cmd+K, preventing default" ) ;
105178 event . preventDefault ( ) ;
106179 event . stopPropagation ( ) ;
107180 handleSearchOpen ( ) ;
108181 }
109182 } ;
110183
111- console . log ( "Layout adding keydown event listener" ) ;
112184 window . addEventListener ( "keydown" , handleKeyDown , true ) ;
113185 return ( ) => {
114186 window . removeEventListener ( "keydown" , handleKeyDown , true ) ;
@@ -121,7 +193,7 @@ const Layout = () => {
121193 < CommandPalette
122194 isOpen = { isCommandPaletteOpen }
123195 onClose = { ( ) => setIsCommandPaletteOpen ( false ) }
124- categories = { categories }
196+ categories = { globalCategories }
125197 />
126198 < EuiPage paddingSize = "none" style = { { background : "transparent" } } >
127199 < EuiPageSidebar
@@ -179,7 +251,10 @@ const Layout = () => {
179251 grow = { false }
180252 style = { { width : "600px" , maxWidth : "90%" } }
181253 >
182- < RegistrySearch ref = { searchRef } categories = { categories } />
254+ < RegistrySearch
255+ ref = { searchRef }
256+ categories = { globalCategories }
257+ />
183258 </ EuiFlexItem >
184259 </ EuiFlexGroup >
185260 </ div >
0 commit comments