The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Pass search term to entity query (#29986)
Terry Sutton262c43934578
diff --git a/apps/studio/components/interfaces/Database/Indexes/CreateIndexSidePanel.tsx b/apps/studio/components/interfaces/Database/Indexes/CreateIndexSidePanel.tsxindex dd527130d09..9faecac311e 100644--- a/apps/studio/components/interfaces/Database/Indexes/CreateIndexSidePanel.tsx+++ b/apps/studio/components/interfaces/Database/Indexes/CreateIndexSidePanel.tsx@@ -1,4 +1,4 @@-import { Check, ChevronsUpDown } from 'lucide-react'+import { Check, ChevronsUpDown, Loader2 } from 'lucide-react'import Link from 'next/link'import { useEffect, useMemo, useState } from 'react'import { toast } from 'sonner'@@ -50,7 +50,7 @@ const CreateIndexSidePanel = ({ visible, onClose }: CreateIndexSidePanelProps) =const [selectedIndexType, setSelectedIndexType] = useState<string>(INDEX_TYPES[0].value)const [schemaDropdownOpen, setSchemaDropdownOpen] = useState(false)const [tableDropdownOpen, setTableDropdownOpen] = useState(false)-+ const [searchTerm, setSearchTerm] = useState('')const { refetch: refetchIndexes } = useIndexesQuery({schema: selectedSchema,projectRef: project?.ref,@@ -60,10 +60,10 @@ const CreateIndexSidePanel = ({ visible, onClose }: CreateIndexSidePanelProps) =projectRef: project?.ref,connectionString: project?.connectionString,})- const { data: entities, isLoading } = useEntityTypesQuery({+ const { data: entities, isLoading: isLoadingEntities } = useEntityTypesQuery({schema: selectedSchema,sort: 'alphabetical',- search: undefined,+ search: searchTerm,projectRef: project?.ref,connectionString: project?.connectionString,})@@ -94,6 +94,10 @@ const CreateIndexSidePanel = ({ visible, onClose }: CreateIndexSidePanelProps) =[entities?.pages])+ function handleSearchChange(value: string) {+ setSearchTerm(value)+ }+const columns = tableColumns?.result[0]?.columns ?? []const columnOptions: MultiSelectOption[] = columns.filter((column): column is NonNullable<typeof column> => column !== null)@@ -181,7 +185,11 @@ CREATE INDEX ON "${selectedSchema}"."${selectedEntity}" USING ${selectedIndexTypsameWidthAsTrigger><Command_Shadcn_>- <CommandInput_Shadcn_ placeholder="Find schema..." />+ <CommandInput_Shadcn_+ placeholder="Find table..."+ value={searchTerm}+ onValueChange={handleSearchChange}+ /><CommandList_Shadcn_><CommandEmpty_Shadcn_>No schemas found</CommandEmpty_Shadcn_><CommandGroup_Shadcn_>@@ -218,7 +226,7 @@ CREATE INDEX ON "${selectedSchema}"."${selectedEntity}" USING ${selectedIndexTypname="select-table"description={isSelectEntityDisabled &&- !isLoading &&+ !isLoadingEntities &&'Create a table in this schema via the Table or SQL editor first'}isReactForm={false}@@ -228,28 +236,27 @@ CREATE INDEX ON "${selectedSchema}"."${selectedEntity}" USING ${selectedIndexTypopen={tableDropdownOpen}onOpenChange={setTableDropdownOpen}>- <PopoverTrigger_Shadcn_ asChild disabled={isSelectEntityDisabled || isLoading}>- {isLoading ? (- <ShimmeringLoader className="h-[38px]" />- ) : (- <Button- type="default"- size="medium"- className={cn(- 'w-full [&>span]:w-full text-left',- selectedEntity === '' && 'text-foreground-lighter'- )}- iconRight={- <ChevronsUpDown className="text-foreground-muted" strokeWidth={2} size={14} />- }- >- {selectedEntity !== undefined && selectedEntity !== ''- ? selectedEntity- : isSelectEntityDisabled- ? 'No tables available in schema'- : 'Choose a table'}- </Button>- )}+ <PopoverTrigger_Shadcn_+ asChild+ disabled={isSelectEntityDisabled || isLoadingEntities}+ >+ <Button+ type="default"+ size="medium"+ className={cn(+ 'w-full [&>span]:w-full text-left',+ selectedEntity === '' && 'text-foreground-lighter'+ )}+ iconRight={+ <ChevronsUpDown className="text-foreground-muted" strokeWidth={2} size={14} />+ }+ >+ {selectedEntity !== undefined && selectedEntity !== ''+ ? selectedEntity+ : isSelectEntityDisabled+ ? 'No tables available in schema'+ : 'Choose a table'}+ </Button></PopoverTrigger_Shadcn_><PopoverContent_Shadcn_className="p-0"@@ -257,10 +264,25 @@ CREATE INDEX ON "${selectedSchema}"."${selectedEntity}" USING ${selectedIndexTypalign="start"sameWidthAsTrigger>- <Command_Shadcn_>- <CommandInput_Shadcn_ placeholder="Find table..." />+ {/* [Terry] shouldFilter context:+ https://github.com/pacocoursey/cmdk/issues/267#issuecomment-2252717107 */}+ <Command_Shadcn_ shouldFilter={false}>+ <CommandInput_Shadcn_+ placeholder="Find table..."+ value={searchTerm}+ onValueChange={handleSearchChange}+ /><CommandList_Shadcn_>- <CommandEmpty_Shadcn_>No tables found</CommandEmpty_Shadcn_>+ <CommandEmpty_Shadcn_>+ {isLoadingEntities ? (+ <div className="flex items-center gap-2 text-center justify-center">+ <Loader2 size={12} className="animate-spin" />+ Loading...+ </div>+ ) : (+ 'No tables found'+ )}+ </CommandEmpty_Shadcn_><CommandGroup_Shadcn_><ScrollArea className={(entityTypes || []).length > 7 ? 'h-[210px]' : ''}>{(entityTypes ?? []).map((entity) => (