mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-29 19:06:24 +02:00
feat: implement search functionality in connector popup
- Added a search input in the ConnectorDialogHeader to filter active connectors based on user input. - Enhanced the ActiveConnectorsTab to filter displayed connectors and document types according to the search query. - Introduced a clear search button for improved user experience when managing connectors.
This commit is contained in:
parent
afe4254f74
commit
aa96e08231
3 changed files with 35 additions and 5 deletions
|
|
@ -292,6 +292,7 @@ export const ConnectorIndicator: FC = () => {
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
|
|
||||||
<ActiveConnectorsTab
|
<ActiveConnectorsTab
|
||||||
|
searchQuery={searchQuery}
|
||||||
hasSources={hasSources}
|
hasSources={hasSources}
|
||||||
totalSourceCount={totalSourceCount}
|
totalSourceCount={totalSourceCount}
|
||||||
activeDocumentTypes={activeDocumentTypes}
|
activeDocumentTypes={activeDocumentTypes}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { Search } from "lucide-react";
|
import { Search, X } from "lucide-react";
|
||||||
import type { FC } from "react";
|
import type { FC } from "react";
|
||||||
import { DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
import { DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
||||||
import { TabsList, TabsTrigger } from "@/components/ui/tabs";
|
import { TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||||
|
|
@ -67,10 +67,23 @@ export const ConnectorDialogHeader: FC<ConnectorDialogHeaderProps> = ({
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Search"
|
placeholder="Search"
|
||||||
className="w-full bg-slate-400/5 dark:bg-white/5 hover:bg-slate-400/10 dark:hover:bg-white/10 focus:bg-slate-400/10 dark:focus:bg-white/10 border border-border rounded-xl pl-9 pr-4 py-2 text-sm transition-all outline-none placeholder:text-muted-foreground/50"
|
className={cn(
|
||||||
|
"w-full bg-slate-400/5 dark:bg-white/5 hover:bg-slate-400/10 dark:hover:bg-white/10 focus:bg-slate-400/10 dark:focus:bg-white/10 border border-border rounded-xl pl-9 py-2 text-sm transition-all outline-none placeholder:text-muted-foreground/50",
|
||||||
|
searchQuery ? "pr-9" : "pr-4"
|
||||||
|
)}
|
||||||
value={searchQuery}
|
value={searchQuery}
|
||||||
onChange={(e) => onSearchChange(e.target.value)}
|
onChange={(e) => onSearchChange(e.target.value)}
|
||||||
/>
|
/>
|
||||||
|
{searchQuery && (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => onSearchChange("")}
|
||||||
|
className="absolute right-3 top-1/2 -translate-y-1/2 size-4 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 transition-colors"
|
||||||
|
aria-label="Clear search"
|
||||||
|
>
|
||||||
|
<X className="size-4" />
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ import { getDocumentCountForConnector } from "../utils/connector-document-mappin
|
||||||
import { TabsContent } from "@/components/ui/tabs";
|
import { TabsContent } from "@/components/ui/tabs";
|
||||||
|
|
||||||
interface ActiveConnectorsTabProps {
|
interface ActiveConnectorsTabProps {
|
||||||
|
searchQuery: string;
|
||||||
hasSources: boolean;
|
hasSources: boolean;
|
||||||
totalSourceCount: number;
|
totalSourceCount: number;
|
||||||
activeDocumentTypes: Array<[string, number]>;
|
activeDocumentTypes: Array<[string, number]>;
|
||||||
|
|
@ -26,6 +27,7 @@ interface ActiveConnectorsTabProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ActiveConnectorsTab: FC<ActiveConnectorsTabProps> = ({
|
export const ActiveConnectorsTab: FC<ActiveConnectorsTabProps> = ({
|
||||||
|
searchQuery,
|
||||||
hasSources,
|
hasSources,
|
||||||
activeDocumentTypes,
|
activeDocumentTypes,
|
||||||
connectors,
|
connectors,
|
||||||
|
|
@ -74,20 +76,34 @@ export const ActiveConnectorsTab: FC<ActiveConnectorsTabProps> = ({
|
||||||
type: docType,
|
type: docType,
|
||||||
count,
|
count,
|
||||||
label: getDocumentTypeLabel(docType),
|
label: getDocumentTypeLabel(docType),
|
||||||
}));
|
}))
|
||||||
|
.filter((doc) => {
|
||||||
|
if (!searchQuery) return true;
|
||||||
|
return doc.label.toLowerCase().includes(searchQuery.toLowerCase());
|
||||||
|
});
|
||||||
|
|
||||||
|
// Filter connectors based on search query
|
||||||
|
const filteredConnectors = connectors.filter((connector) => {
|
||||||
|
if (!searchQuery) return true;
|
||||||
|
const searchLower = searchQuery.toLowerCase();
|
||||||
|
return (
|
||||||
|
connector.name.toLowerCase().includes(searchLower) ||
|
||||||
|
connector.connector_type.toLowerCase().includes(searchLower)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TabsContent value="active" className="m-0">
|
<TabsContent value="active" className="m-0">
|
||||||
{hasSources ? (
|
{hasSources ? (
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
{/* Active Connectors Section */}
|
{/* Active Connectors Section */}
|
||||||
{connectors.length > 0 && (
|
{filteredConnectors.length > 0 && (
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<h3 className="text-sm font-semibold text-muted-foreground">Active Connectors</h3>
|
<h3 className="text-sm font-semibold text-muted-foreground">Active Connectors</h3>
|
||||||
</div>
|
</div>
|
||||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
|
<div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
|
||||||
{connectors.map((connector) => {
|
{filteredConnectors.map((connector) => {
|
||||||
const isIndexing = indexingConnectorIds.has(connector.id);
|
const isIndexing = indexingConnectorIds.has(connector.id);
|
||||||
const activeTask = logsSummary?.active_tasks?.find(
|
const activeTask = logsSummary?.active_tasks?.find(
|
||||||
(task: LogActiveTask) => task.connector_id === connector.id
|
(task: LogActiveTask) => task.connector_id === connector.id
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue