diff --git a/rnd/autogpt_builder/package.json b/rnd/autogpt_builder/package.json index a5cfe138a..3159cce93 100644 --- a/rnd/autogpt_builder/package.json +++ b/rnd/autogpt_builder/package.json @@ -17,6 +17,7 @@ "@radix-ui/react-icons": "^1.3.0", "@radix-ui/react-label": "^2.1.0", "@radix-ui/react-popover": "^1.1.1", + "@radix-ui/react-scroll-area": "^1.1.0", "@radix-ui/react-separator": "^1.1.0", "@radix-ui/react-slot": "^1.1.0", "@radix-ui/react-switch": "^1.1.0", diff --git a/rnd/autogpt_builder/src/components/edit/control/BlocksControl.tsx b/rnd/autogpt_builder/src/components/edit/control/BlocksControl.tsx new file mode 100644 index 000000000..8e61f0cb9 --- /dev/null +++ b/rnd/autogpt_builder/src/components/edit/control/BlocksControl.tsx @@ -0,0 +1,83 @@ +import React, { useState } from "react"; +import { Card, CardContent, CardHeader } from "@/components/ui/card"; +import { Label } from "@/components/ui/label"; +import { Button } from "@/components/ui/button"; +import { ToyBrick } from "lucide-react"; +import { Input } from "@/components/ui/input"; +import { ScrollArea } from "@/components/ui/scroll-area"; +import { beautifyString } from "@/lib/utils"; +import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; +import { Block } from '@/lib/autogpt-server-api'; +import { PlusIcon } from "@radix-ui/react-icons"; + +interface BlocksControlProps { + blocks: Block[]; + addBlock: (id: string, name: string) => void; +} + +/** + * A React functional component that displays a control for managing blocks. + * + * @component + * @param {Object} BlocksControlProps - The properties for the BlocksControl component. + * @param {Block[]} BlocksControlProps.blocks - An array of blocks to be displayed and filtered. + * @param {(id: string, name: string) => void} BlocksControlProps.addBlock - A function to call when a block is added. + * @returns The rendered BlocksControl component. + */ +export const BlocksControl: React.FC = ({ blocks, addBlock }) => { + const [searchQuery, setSearchQuery] = useState(''); + + const filteredBlocks = blocks.filter((block: Block) => + block.name.toLowerCase().includes(searchQuery.toLowerCase()) + ); + + return ( + + + + + + + +
+ +
+ setSearchQuery(e.target.value)} + /> +
+ + + {filteredBlocks.map((block) => ( + +
+
+ {beautifyString(block.name)} +
+
+ +
+
+
+ ))} +
+
+
+
+
+ ); +}; \ No newline at end of file diff --git a/rnd/autogpt_builder/src/components/edit/control/SaveControl.tsx b/rnd/autogpt_builder/src/components/edit/control/SaveControl.tsx index cbc72b948..8bd440673 100644 --- a/rnd/autogpt_builder/src/components/edit/control/SaveControl.tsx +++ b/rnd/autogpt_builder/src/components/edit/control/SaveControl.tsx @@ -55,7 +55,7 @@ export const SaveControl= ({ - +