(props: {
open: boolean;
groups: readonly ToolkitConnectionGroup[];
configuredConnections: readonly ConfiguredConnectionView[];
hiddenPersonalConnectionCount: number;
integrations: readonly Integration[];
integrationPlugins: readonly IntegrationPlugin[];
showOwnerLabels: boolean;
onOpenChange: (open: boolean) => void;
onAddPatterns: (patterns: readonly string[]) => Promise<void> | void;
onRemoveConnection: (connectionId: string) => Promise<void> | void;
})
| 760 | } |
| 761 | |
| 762 | function AddConnectionDialog(props: { |
| 763 | open: boolean; |
| 764 | groups: readonly ToolkitConnectionGroup[]; |
| 765 | configuredConnections: readonly ConfiguredConnectionView[]; |
| 766 | hiddenPersonalConnectionCount: number; |
| 767 | integrations: readonly Integration[]; |
| 768 | integrationPlugins: readonly IntegrationPlugin[]; |
| 769 | showOwnerLabels: boolean; |
| 770 | onOpenChange: (open: boolean) => void; |
| 771 | onAddPatterns: (patterns: readonly string[]) => Promise<void> | void; |
| 772 | onRemoveConnection: (connectionId: string) => Promise<void> | void; |
| 773 | }) { |
| 774 | const searchId = useId(); |
| 775 | const [query, setQuery] = useState(""); |
| 776 | const trimmedQuery = query.trim().toLowerCase(); |
| 777 | const filteredGroups = useMemo(() => { |
| 778 | if (!trimmedQuery) return props.groups; |
| 779 | return props.groups.filter((group) => { |
| 780 | const corpus = [ |
| 781 | connectionTitle(group), |
| 782 | ...group.patterns, |
| 783 | ownerLabel(group.owner), |
| 784 | ...group.tools.flatMap((tool) => [tool.name, tool.description ?? ""]), |
| 785 | ] |
| 786 | .join(" ") |
| 787 | .toLowerCase(); |
| 788 | return corpus.includes(trimmedQuery); |
| 789 | }); |
| 790 | }, [props.groups, trimmedQuery]); |
| 791 | |
| 792 | const addConnection = async (patterns: readonly string[]) => { |
| 793 | await props.onAddPatterns(patterns); |
| 794 | }; |
| 795 | |
| 796 | const removeConnection = async (connectionId: string) => { |
| 797 | await props.onRemoveConnection(connectionId); |
| 798 | }; |
| 799 | |
| 800 | return ( |
| 801 | <Dialog |
| 802 | open={props.open} |
| 803 | onOpenChange={(nextOpen) => { |
| 804 | props.onOpenChange(nextOpen); |
| 805 | if (!nextOpen) { |
| 806 | setQuery(""); |
| 807 | } |
| 808 | }} |
| 809 | > |
| 810 | <DialogContent |
| 811 | className="gap-0 overflow-hidden rounded-md border-border/80 bg-card p-0 shadow-2xl" |
| 812 | style={{ |
| 813 | width: "min(36rem, calc(100vw - 2rem))", |
| 814 | maxWidth: "min(36rem, calc(100vw - 2rem))", |
| 815 | maxHeight: "min(42rem, calc(100vh - 4rem))", |
| 816 | }} |
| 817 | > |
| 818 | <DialogHeader className="border-b border-border/60 px-5 py-4"> |
| 819 | <div className="flex items-start gap-3"> |
nothing calls this directly
no test coverage detected