first implementation, working but not stable
This commit is contained in:
parent
ec0af06573
commit
bb6ad3939b
3 changed files with 49 additions and 41 deletions
|
|
@ -18,6 +18,8 @@ import {
|
||||||
CardHeader,
|
CardHeader,
|
||||||
CardTitle,
|
CardTitle,
|
||||||
} from "../ui/card";
|
} from "../ui/card";
|
||||||
|
import IOModal from "../../modals/IOModal";
|
||||||
|
import useFlowStore from "../../stores/flowStore";
|
||||||
|
|
||||||
export default function CollectionCardComponent({
|
export default function CollectionCardComponent({
|
||||||
data,
|
data,
|
||||||
|
|
@ -31,7 +33,7 @@ export default function CollectionCardComponent({
|
||||||
authorized?: boolean;
|
authorized?: boolean;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
button?: JSX.Element;
|
button?: JSX.Element;
|
||||||
playground?:JSX.Element;
|
playground?: boolean;
|
||||||
onDelete?: () => void;
|
onDelete?: () => void;
|
||||||
}) {
|
}) {
|
||||||
const addFlow = useFlowsManagerStore((state) => state.addFlow);
|
const addFlow = useFlowsManagerStore((state) => state.addFlow);
|
||||||
|
|
@ -48,9 +50,24 @@ export default function CollectionCardComponent({
|
||||||
const [downloads_count, setDownloads_count] = useState(
|
const [downloads_count, setDownloads_count] = useState(
|
||||||
data?.downloads_count ?? 0
|
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";
|
const name = data.is_component ? "Component" : "Flow";
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (currentFlowId && playground) {
|
||||||
|
setNodes(currentFlow?.data?.nodes ?? []);
|
||||||
|
setEdges(currentFlow?.data?.edges ?? []);
|
||||||
|
}
|
||||||
|
}, [currentFlowId]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data) {
|
if (data) {
|
||||||
setLiked_by_user(data?.liked_by_user ?? false);
|
setLiked_by_user(data?.liked_by_user ?? false);
|
||||||
|
|
@ -69,8 +86,7 @@ export default function CollectionCardComponent({
|
||||||
addFlow(true, newFlow)
|
addFlow(true, newFlow)
|
||||||
.then((id) => {
|
.then((id) => {
|
||||||
setSuccessData({
|
setSuccessData({
|
||||||
title: `${name} ${
|
title: `${name} ${isStore ? "Downloaded" : "Installed"
|
||||||
isStore ? "Downloaded" : "Installed"
|
|
||||||
} Successfully.`,
|
} Successfully.`,
|
||||||
});
|
});
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
|
@ -78,8 +94,7 @@ export default function CollectionCardComponent({
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
setErrorData({
|
setErrorData({
|
||||||
title: `Error ${
|
title: `Error ${isStore ? "downloading" : "installing"
|
||||||
isStore ? "downloading" : "installing"
|
|
||||||
} the ${name}`,
|
} the ${name}`,
|
||||||
list: [error["response"]["data"]["detail"]],
|
list: [error["response"]["data"]["detail"]],
|
||||||
});
|
});
|
||||||
|
|
@ -347,7 +362,30 @@ export default function CollectionCardComponent({
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{button && button}
|
{button && button}
|
||||||
{playground && playground}
|
{playground &&
|
||||||
|
<Button
|
||||||
|
tabIndex={-1}
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
className="whitespace-nowrap "
|
||||||
|
data-testid={
|
||||||
|
"playground-flow-button-" + data.id
|
||||||
|
}
|
||||||
|
onClick={() => {
|
||||||
|
setCurrentFlowId(data.id);
|
||||||
|
setOpenPlayground(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<IconComponent
|
||||||
|
name="ExternalLink"
|
||||||
|
className="main-page-nav-button select-none"
|
||||||
|
/>
|
||||||
|
Playground
|
||||||
|
{openPlayground && < IOModal open={openPlayground} setOpen={setOpenPlayground}>
|
||||||
|
<></>
|
||||||
|
</IOModal>}
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</CardFooter>
|
</CardFooter>
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,7 @@ export default function IOModal({
|
||||||
const isBuilding = useFlowStore((state) => state.isBuilding);
|
const isBuilding = useFlowStore((state) => state.isBuilding);
|
||||||
const currentFlow = useFlowsManagerStore((state) => state.currentFlow);
|
const currentFlow = useFlowsManagerStore((state) => state.currentFlow);
|
||||||
const setNode = useFlowStore((state) => state.setNode);
|
const setNode = useFlowStore((state) => state.setNode);
|
||||||
|
console.log(nodes)
|
||||||
|
|
||||||
async function updateVertices() {
|
async function updateVertices() {
|
||||||
return updateVerticesOrder(currentFlow!.id, null);
|
return updateVerticesOrder(currentFlow!.id, null);
|
||||||
|
|
|
||||||
|
|
@ -14,15 +14,12 @@ import {
|
||||||
import useAlertStore from "../../../../stores/alertStore";
|
import useAlertStore from "../../../../stores/alertStore";
|
||||||
import useFlowsManagerStore from "../../../../stores/flowsManagerStore";
|
import useFlowsManagerStore from "../../../../stores/flowsManagerStore";
|
||||||
import { FlowType } from "../../../../types/flow";
|
import { FlowType } from "../../../../types/flow";
|
||||||
import IOModal from "../../../../modals/IOModal";
|
|
||||||
|
|
||||||
export default function ComponentsComponent({
|
export default function ComponentsComponent({
|
||||||
is_component = true,
|
is_component = true,
|
||||||
}: {
|
}: {
|
||||||
is_component?: boolean;
|
is_component?: boolean;
|
||||||
}) {
|
}) {
|
||||||
const addFlow = useFlowsManagerStore((state) => state.addFlow);
|
const addFlow = useFlowsManagerStore((state) => state.addFlow);
|
||||||
const setCurrentFlowId = useFlowsManagerStore((state) => state.setCurrentFlowId);
|
|
||||||
const uploadFlow = useFlowsManagerStore((state) => state.uploadFlow);
|
const uploadFlow = useFlowsManagerStore((state) => state.uploadFlow);
|
||||||
const removeFlow = useFlowsManagerStore((state) => state.removeFlow);
|
const removeFlow = useFlowsManagerStore((state) => state.removeFlow);
|
||||||
const isLoading = useFlowsManagerStore((state) => state.isLoading);
|
const isLoading = useFlowsManagerStore((state) => state.isLoading);
|
||||||
|
|
@ -33,8 +30,6 @@ export default function ComponentsComponent({
|
||||||
const [pageSize, setPageSize] = useState(20);
|
const [pageSize, setPageSize] = useState(20);
|
||||||
const [pageIndex, setPageIndex] = useState(1);
|
const [pageIndex, setPageIndex] = useState(1);
|
||||||
const [loadingScreen, setLoadingScreen] = useState(true);
|
const [loadingScreen, setLoadingScreen] = useState(true);
|
||||||
const [openPlayground, setOpenPlayground] = useState(false);
|
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -175,33 +170,7 @@ export default function ComponentsComponent({
|
||||||
<></>
|
<></>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
playground={
|
playground={!is_component}
|
||||||
!is_component ? (
|
|
||||||
<IOModal open={openPlayground} setOpen={setOpenPlayground}>
|
|
||||||
<Button
|
|
||||||
tabIndex={-1}
|
|
||||||
variant="outline"
|
|
||||||
size="sm"
|
|
||||||
className="whitespace-nowrap "
|
|
||||||
data-testid={
|
|
||||||
"playground-flow-button-" + item.id + "-" + idx
|
|
||||||
}
|
|
||||||
onClick={() => {
|
|
||||||
setCurrentFlowId(item.id);
|
|
||||||
setOpenPlayground(true);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<IconComponent
|
|
||||||
name="ExternalLink"
|
|
||||||
className="main-page-nav-button select-none"
|
|
||||||
/>
|
|
||||||
Playground
|
|
||||||
</Button>
|
|
||||||
</IOModal>
|
|
||||||
) : (
|
|
||||||
<></>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
) : (
|
) : (
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue