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