From ec0af06573e9296fa5df72bae0e5f13a0b87bbd1 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Tue, 23 Apr 2024 09:26:15 -0300 Subject: [PATCH] Add playground button to flow cards in MainPage (#1752) * Add playground button to flow cards in MainPage * Add IOModal component for playground functionality * Update playground button styling not working yet --- .../src/components/cardComponent/index.tsx | 3 ++ .../MainPage/components/components/index.tsx | 40 ++++++++++++++++--- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/frontend/src/components/cardComponent/index.tsx b/src/frontend/src/components/cardComponent/index.tsx index 2ec60e0a2..f9eef310e 100644 --- a/src/frontend/src/components/cardComponent/index.tsx +++ b/src/frontend/src/components/cardComponent/index.tsx @@ -25,11 +25,13 @@ export default function CollectionCardComponent({ disabled = false, button, onDelete, + playground }: { data: storeComponent; authorized?: boolean; disabled?: boolean; button?: JSX.Element; + playground?:JSX.Element; onDelete?: () => void; }) { const addFlow = useFlowsManagerStore((state) => state.addFlow); @@ -345,6 +347,7 @@ export default function CollectionCardComponent({ )} {button && button} + {playground && playground} diff --git a/src/frontend/src/pages/MainPage/components/components/index.tsx b/src/frontend/src/pages/MainPage/components/components/index.tsx index 65189fa8a..ba5879747 100644 --- a/src/frontend/src/pages/MainPage/components/components/index.tsx +++ b/src/frontend/src/pages/MainPage/components/components/index.tsx @@ -14,6 +14,7 @@ import { import useAlertStore from "../../../../stores/alertStore"; import useFlowsManagerStore from "../../../../stores/flowsManagerStore"; import { FlowType } from "../../../../types/flow"; +import IOModal from "../../../../modals/IOModal"; export default function ComponentsComponent({ is_component = true, @@ -21,6 +22,7 @@ export default function ComponentsComponent({ is_component?: boolean; }) { const addFlow = useFlowsManagerStore((state) => state.addFlow); + const setCurrentFlowId = useFlowsManagerStore((state) => state.setCurrentFlowId); const uploadFlow = useFlowsManagerStore((state) => state.uploadFlow); const removeFlow = useFlowsManagerStore((state) => state.removeFlow); const isLoading = useFlowsManagerStore((state) => state.isLoading); @@ -31,6 +33,7 @@ export default function ComponentsComponent({ const [pageSize, setPageSize] = useState(20); const [pageIndex, setPageIndex] = useState(1); const [loadingScreen, setLoadingScreen] = useState(true); + const [openPlayground, setOpenPlayground] = useState(false); const navigate = useNavigate(); @@ -75,9 +78,8 @@ export default function ComponentsComponent({ }) .then(() => { setSuccessData({ - title: `${ - is_component ? "Component" : "Flow" - } uploaded successfully`, + title: `${is_component ? "Component" : "Flow" + } uploaded successfully`, }); }) .catch((error) => { @@ -142,9 +144,8 @@ export default function ComponentsComponent({ onDelete={() => { removeFlow(item.id); setSuccessData({ - title: `${ - item.is_component ? "Component" : "Flow" - } deleted successfully!`, + title: `${item.is_component ? "Component" : "Flow" + } deleted successfully!`, }); resetFilter(); }} @@ -174,6 +175,33 @@ export default function ComponentsComponent({ <> ) } + playground={ + !is_component ? ( + + + + ) : ( + <> + ) + } /> )) ) : (