diff --git a/src/frontend/src/components/cardComponent/index.tsx b/src/frontend/src/components/cardComponent/index.tsx
index f9eef310e..21701f459 100644
--- a/src/frontend/src/components/cardComponent/index.tsx
+++ b/src/frontend/src/components/cardComponent/index.tsx
@@ -18,6 +18,8 @@ import {
CardHeader,
CardTitle,
} from "../ui/card";
+import IOModal from "../../modals/IOModal";
+import useFlowStore from "../../stores/flowStore";
export default function CollectionCardComponent({
data,
@@ -31,7 +33,7 @@ export default function CollectionCardComponent({
authorized?: boolean;
disabled?: boolean;
button?: JSX.Element;
- playground?:JSX.Element;
+ playground?: boolean;
onDelete?: () => void;
}) {
const addFlow = useFlowsManagerStore((state) => state.addFlow);
@@ -48,9 +50,24 @@ export default function CollectionCardComponent({
const [downloads_count, setDownloads_count] = useState(
data?.downloads_count ?? 0
);
+ const currentFlow = useFlowsManagerStore((state) => state.currentFlow);
+ const currentFlowId = useFlowsManagerStore((state) => state.currentFlowId);
+ const setNodes = useFlowStore((state) => state.setNodes);
+ const setEdges = useFlowStore((state) => state.setEdges);
+ const [openPlayground, setOpenPlayground] = useState(false);
+ const setCurrentFlowId = useFlowsManagerStore((state) => state.setCurrentFlowId);
+
+
const name = data.is_component ? "Component" : "Flow";
+ useEffect(() => {
+ if (currentFlowId && playground) {
+ setNodes(currentFlow?.data?.nodes ?? []);
+ setEdges(currentFlow?.data?.edges ?? []);
+ }
+ }, [currentFlowId]);
+
useEffect(() => {
if (data) {
setLiked_by_user(data?.liked_by_user ?? false);
@@ -69,18 +86,16 @@ export default function CollectionCardComponent({
addFlow(true, newFlow)
.then((id) => {
setSuccessData({
- title: `${name} ${
- isStore ? "Downloaded" : "Installed"
- } Successfully.`,
+ title: `${name} ${isStore ? "Downloaded" : "Installed"
+ } Successfully.`,
});
setLoading(false);
})
.catch((error) => {
setLoading(false);
setErrorData({
- title: `Error ${
- isStore ? "downloading" : "installing"
- } the ${name}`,
+ title: `Error ${isStore ? "downloading" : "installing"
+ } the ${name}`,
list: [error["response"]["data"]["detail"]],
});
});
@@ -347,10 +362,33 @@ export default function CollectionCardComponent({
)}
{button && button}
- {playground && playground}
+ {playground &&
+
+ }
-
+
);
}
diff --git a/src/frontend/src/modals/IOModal/index.tsx b/src/frontend/src/modals/IOModal/index.tsx
index c81aecc35..c59368fe5 100644
--- a/src/frontend/src/modals/IOModal/index.tsx
+++ b/src/frontend/src/modals/IOModal/index.tsx
@@ -78,6 +78,7 @@ export default function IOModal({
const isBuilding = useFlowStore((state) => state.isBuilding);
const currentFlow = useFlowsManagerStore((state) => state.currentFlow);
const setNode = useFlowStore((state) => state.setNode);
+ console.log(nodes)
async function updateVertices() {
return updateVerticesOrder(currentFlow!.id, null);
diff --git a/src/frontend/src/pages/MainPage/components/components/index.tsx b/src/frontend/src/pages/MainPage/components/components/index.tsx
index ba5879747..55bc6a511 100644
--- a/src/frontend/src/pages/MainPage/components/components/index.tsx
+++ b/src/frontend/src/pages/MainPage/components/components/index.tsx
@@ -14,15 +14,12 @@ 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,
}: {
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);
@@ -33,8 +30,6 @@ 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();
useEffect(() => {
@@ -175,33 +170,7 @@ export default function ComponentsComponent({
<>>
)
}
- playground={
- !is_component ? (
-
-
-
- ) : (
- <>>
- )
- }
+ playground={!is_component}
/>
))
) : (