@@ -97,7 +97,9 @@ export const SQLEditorNav = ({ searchText: _searchText }: SQLEditorNavProps) =>
9797 ? [ ROOT_NODE ]
9898 : formatFolderResponseForTreeView ( { folders, contents : privateSnippets } )
9999
100- const favoriteSnippets = useFavoriteSnippets ( projectRef as string )
100+ const favoriteSnippets = useFavoriteSnippets ( projectRef as string ) . filter ( ( x ) =>
101+ searchText . length > 0 ? x . name . toLowerCase ( ) . includes ( searchText . toLowerCase ( ) ) : true
102+ )
101103 const numFavoriteSnippets = favoriteSnippets . length
102104 const favoritesTreeState =
103105 numFavoriteSnippets === 0
@@ -341,31 +343,29 @@ export const SQLEditorNav = ({ searchText: _searchText }: SQLEditorNavProps) =>
341343 < >
342344 < Separator />
343345
344- { ( ( numFavoriteSnippets === 0 && searchText . length === 0 ) || numFavoriteSnippets > 0 ) && (
346+ { ( ( numProjectSnippets === 0 && searchText . length === 0 ) || numProjectSnippets > 0 ) && (
345347 < >
346- < Collapsible_Shadcn_ open = { showFavouriteSnippets } onOpenChange = { setShowFavouriteSnippets } >
348+ < Collapsible_Shadcn_ open = { showSharedSnippets } onOpenChange = { setShowSharedSnippets } >
347349 < CollapsibleTrigger_Shadcn_ className = { COLLAPSIBLE_TRIGGER_CLASS_NAMES } >
348350 < ChevronRight size = { 16 } className = { COLLAPSIBLE_ICON_CLASS_NAMES } />
349351 < span className = { COLLASIBLE_HEADER_CLASS_NAMES } >
350- Favorites { numFavoriteSnippets > 0 && ` (${ numFavoriteSnippets } )` }
352+ Shared { numProjectSnippets > 0 && ` (${ numProjectSnippets } )` }
351353 </ span >
352354 </ CollapsibleTrigger_Shadcn_ >
353355 < CollapsibleContent_Shadcn_ className = "pt-2" >
354- { numFavoriteSnippets === 0 ? (
356+ { numProjectSnippets === 0 ? (
355357 < div className = "mx-4" >
356358 < Alert_Shadcn_ className = "p-3" >
357- < AlertTitle_Shadcn_ className = "text-xs" > No favorite queries</ AlertTitle_Shadcn_ >
359+ < AlertTitle_Shadcn_ className = "text-xs" > No shared queries</ AlertTitle_Shadcn_ >
358360 < AlertDescription_Shadcn_ className = "text-xs " >
359- Save a query to favorites for easy accessbility by clicking the{ ' ' }
360- < Heart size = { 12 } className = "inline-block relative align-center -top-[1px]" /> { ' ' }
361- icon.
361+ Share queries with your team by right-clicking on the query.
362362 </ AlertDescription_Shadcn_ >
363363 </ Alert_Shadcn_ >
364364 </ div >
365365 ) : (
366366 < TreeView
367- data = { favoritesTreeState }
368- aria-label = "favorite -snippets"
367+ data = { projectSnippetsTreeState }
368+ aria-label = "project-level -snippets"
369369 nodeRenderer = { ( { element, ...props } ) => (
370370 < SQLEditorTreeViewItem
371371 { ...props }
@@ -384,7 +384,6 @@ export const SQLEditorNav = ({ searchText: _searchText }: SQLEditorNavProps) =>
384384 onSelectCopyPersonal = { ( ) => {
385385 onSelectCopyPersonal ( element . metadata as Snippet )
386386 } }
387- onSelectShare = { ( ) => setSelectedSnippetToShare ( element . metadata as Snippet ) }
388387 onSelectUnshare = { ( ) => {
389388 setSelectedSnippetToUnshare ( element . metadata as Snippet )
390389 } }
@@ -398,29 +397,31 @@ export const SQLEditorNav = ({ searchText: _searchText }: SQLEditorNavProps) =>
398397 </ >
399398 ) }
400399
401- { ( ( numProjectSnippets === 0 && searchText . length === 0 ) || numProjectSnippets > 0 ) && (
400+ { ( ( numFavoriteSnippets === 0 && searchText . length === 0 ) || numFavoriteSnippets > 0 ) && (
402401 < >
403- < Collapsible_Shadcn_ open = { showSharedSnippets } onOpenChange = { setShowSharedSnippets } >
402+ < Collapsible_Shadcn_ open = { showFavouriteSnippets } onOpenChange = { setShowFavouriteSnippets } >
404403 < CollapsibleTrigger_Shadcn_ className = { COLLAPSIBLE_TRIGGER_CLASS_NAMES } >
405404 < ChevronRight size = { 16 } className = { COLLAPSIBLE_ICON_CLASS_NAMES } />
406405 < span className = { COLLASIBLE_HEADER_CLASS_NAMES } >
407- Shared { numProjectSnippets > 0 && ` (${ numProjectSnippets } )` }
406+ Favorites { numFavoriteSnippets > 0 && ` (${ numFavoriteSnippets } )` }
408407 </ span >
409408 </ CollapsibleTrigger_Shadcn_ >
410409 < CollapsibleContent_Shadcn_ className = "pt-2" >
411- { numProjectSnippets === 0 ? (
410+ { numFavoriteSnippets === 0 ? (
412411 < div className = "mx-4" >
413412 < Alert_Shadcn_ className = "p-3" >
414- < AlertTitle_Shadcn_ className = "text-xs" > No shared queries</ AlertTitle_Shadcn_ >
413+ < AlertTitle_Shadcn_ className = "text-xs" > No favorite queries</ AlertTitle_Shadcn_ >
415414 < AlertDescription_Shadcn_ className = "text-xs " >
416- Share queries with your team by right-clicking on the query.
415+ Save a query to favorites for easy accessbility by clicking the{ ' ' }
416+ < Heart size = { 12 } className = "inline-block relative align-center -top-[1px]" /> { ' ' }
417+ icon.
417418 </ AlertDescription_Shadcn_ >
418419 </ Alert_Shadcn_ >
419420 </ div >
420421 ) : (
421422 < TreeView
422- data = { projectSnippetsTreeState }
423- aria-label = "project-level -snippets"
423+ data = { favoritesTreeState }
424+ aria-label = "favorite -snippets"
424425 nodeRenderer = { ( { element, ...props } ) => (
425426 < SQLEditorTreeViewItem
426427 { ...props }
@@ -439,6 +440,7 @@ export const SQLEditorNav = ({ searchText: _searchText }: SQLEditorNavProps) =>
439440 onSelectCopyPersonal = { ( ) => {
440441 onSelectCopyPersonal ( element . metadata as Snippet )
441442 } }
443+ onSelectShare = { ( ) => setSelectedSnippetToShare ( element . metadata as Snippet ) }
442444 onSelectUnshare = { ( ) => {
443445 setSelectedSnippetToUnshare ( element . metadata as Snippet )
444446 } }
0 commit comments