diff --git a/src/frontend/src/pages/MainPage/components/cardComponent/index.tsx b/src/frontend/src/components/cardComponent/index.tsx similarity index 69% rename from src/frontend/src/pages/MainPage/components/cardComponent/index.tsx rename to src/frontend/src/components/cardComponent/index.tsx index 88dad5ff1..5688eefaa 100644 --- a/src/frontend/src/pages/MainPage/components/cardComponent/index.tsx +++ b/src/frontend/src/components/cardComponent/index.tsx @@ -1,13 +1,13 @@ import { Trash2, ExternalLink } from "lucide-react"; import { useContext } from "react"; import { Link } from "react-router-dom"; -import { TabsContext } from "../../../../contexts/tabsContext"; -import { FlowType } from "../../../../types/flow"; -import { gradients } from "../../../../utils"; -import { CardTitle, CardDescription, CardFooter, Card, CardHeader } from "../../../../components/ui/card"; -import { Button } from "../../../../components/ui/button"; +import { TabsContext } from "../../contexts/tabsContext"; +import { FlowType } from "../../types/flow"; +import { gradients } from "../../utils"; +import { CardTitle, CardDescription, CardFooter, Card, CardHeader } from "../ui/card"; -export const CardComponent = ({ flow, id }: { flow: FlowType; id: string }) => { + +export const CardComponent = ({ flow, id, onDelete, button }: { flow: FlowType; id: string, onDelete?: () => void, button?: JSX.Element }) => { const { removeFlow } = useContext(TabsContext); return ( @@ -26,13 +26,13 @@ export const CardComponent = ({ flow, id }: { flow: FlowType; id: string }) => { {flow.name} + {onDelete && + }
@@ -53,17 +53,10 @@ export const CardComponent = ({ flow, id }: { flow: FlowType; id: string }) => {  OpenAI+ */}
- - - + {button && + button + } + diff --git a/src/frontend/src/pages/CommunityPage/components/cardComponent/index.tsx b/src/frontend/src/pages/CommunityPage/components/cardComponent/index.tsx deleted file mode 100644 index 9985ea956..000000000 --- a/src/frontend/src/pages/CommunityPage/components/cardComponent/index.tsx +++ /dev/null @@ -1,70 +0,0 @@ -import { GitFork } from "lucide-react"; -import { useContext } from "react"; -import { useNavigate } from "react-router-dom"; -import { TabsContext } from "../../../../contexts/tabsContext"; -import { FlowType } from "../../../../types/flow"; -import { gradients } from "../../../../utils"; -import { - CardTitle, - CardDescription, - CardFooter, - Card, - CardHeader, -} from "../../../../components/ui/card"; -import { Button } from "../../../../components/ui/button"; - -export const CardComponent = ({ flow, id }: { flow: FlowType; id: string }) => { - const { addFlow } = useContext(TabsContext); - const navigate = useNavigate(); - - return ( - - - -
- - {flow.name} -
-
- -
- {flow.description} - {/* {flow.description} */} -
-
-
- - -
-
- {/* Agent - -
- -
-  OpenAI+ -
*/} -
- -
-
-
- ); -}; diff --git a/src/frontend/src/pages/CommunityPage/index.tsx b/src/frontend/src/pages/CommunityPage/index.tsx index 92e5e253c..6b8322531 100644 --- a/src/frontend/src/pages/CommunityPage/index.tsx +++ b/src/frontend/src/pages/CommunityPage/index.tsx @@ -18,6 +18,7 @@ import { Plus, Home, Users2, + GitFork, } from "lucide-react"; import { TabsContext } from "../../contexts/tabsContext"; import AlertDropdown from "../../alerts/alertDropDown"; @@ -37,7 +38,8 @@ import { } from "../../controllers/API"; import { MenuBar } from "../../components/headerComponent/components/menuBar"; import { FlowType } from "../../types/flow"; -import { CardComponent } from "./components/cardComponent"; +import { CardComponent } from "../../components/cardComponent"; +import { useNavigate } from "react-router-dom"; export default function CommunityPage() { const { flows, setTabId, downloadFlows, uploadFlows, addFlow } = useContext(TabsContext); @@ -61,6 +63,7 @@ export default function CommunityPage() { }) ); } + const navigate = useNavigate(); useEffect(() => { handleExamples(); @@ -87,7 +90,19 @@ export default function CommunityPage() {
{!loadingExamples && examples.map((flow, idx) => ( - + { + addFlow(flow, true).then((id) => { + navigate("/flow/" + id); + }); + }} + > + + Fork Example + }/> ))}
diff --git a/src/frontend/src/pages/MainPage/index.tsx b/src/frontend/src/pages/MainPage/index.tsx index 98d8c1a0d..ea064dadf 100644 --- a/src/frontend/src/pages/MainPage/index.tsx +++ b/src/frontend/src/pages/MainPage/index.tsx @@ -1,11 +1,11 @@ import { useContext, useEffect } from "react"; -import { Download, Upload, Plus, Home } from "lucide-react"; +import { Download, Upload, Plus, Home, ExternalLink } from "lucide-react"; import { TabsContext } from "../../contexts/tabsContext"; import { Button } from "../../components/ui/button"; -import { CardComponent } from "./components/cardComponent"; -import { useNavigate } from "react-router-dom"; +import { Link, useNavigate } from "react-router-dom"; +import { CardComponent } from "../../components/cardComponent"; export default function HomePage() { - const { flows, setTabId, downloadFlows, uploadFlows, addFlow } = + const { flows, setTabId, downloadFlows, uploadFlows, addFlow, removeFlow } = useContext(TabsContext); useEffect(() => { setTabId(""); @@ -50,13 +50,32 @@ export default function HomePage() { - + Manage your personal projects. Download or upload your complete project collection.
{flows.map((flow, idx) => ( - + + + + } + onDelete={() => { + removeFlow(flow.id); + }} + /> ))}