-
-
- {icon}
-
+
+
+
+
+
+ {title}
+
+
+
{title}
+ {/*
+ {deactivate ? "Coming soon" : description}
+ */}
-
{title}
-
-
{title}
- {deactivate? "Coming soon":description}
-
-
+
);
}
diff --git a/src/frontend/src/modals/importModal/index.tsx b/src/frontend/src/modals/importModal/index.tsx
index c471f3955..3d22b0ee7 100644
--- a/src/frontend/src/modals/importModal/index.tsx
+++ b/src/frontend/src/modals/importModal/index.tsx
@@ -3,19 +3,30 @@ import {
XMarkIcon,
ArrowDownTrayIcon,
DocumentDuplicateIcon,
- ComputerDesktopIcon,
+ ComputerDesktopIcon,
ArrowUpTrayIcon,
+ ArrowLeftIcon,
} from "@heroicons/react/24/outline";
import { Fragment, useContext, useRef, useState } from "react";
import { PopUpContext } from "../../contexts/popUpContext";
import { TabsContext } from "../../contexts/tabsContext";
import ButtonBox from "./buttonBox";
+import { getExamples } from "../../controllers/API";
+import { error } from "console";
+import { alertContext } from "../../contexts/alertContext";
+import LoadingComponent from "../../components/loadingComponent";
+import { FlowType } from "../../types/flow";
+import { classNames } from "../../utils";
export default function ImportModal() {
const [open, setOpen] = useState(true);
+ const { setErrorData } = useContext(alertContext);
const { closePopUp } = useContext(PopUpContext);
const ref = useRef();
- const {uploadFlow} = useContext(TabsContext)
+ const [showExamples, setShowExamples] = useState(false);
+ const [loadingExamples, setLoadingExamples] = useState(false);
+ const [examples, setExamples] = useState
([]);
+ const { uploadFlow, addFlow } = useContext(TabsContext);
function setModalOpen(x: boolean) {
setOpen(x);
if (x === false) {
@@ -24,6 +35,22 @@ export default function ImportModal() {
}, 300);
}
}
+
+ function handleExamples() {
+ setLoadingExamples(true);
+ getExamples()
+ .then((result) => {
+ setLoadingExamples(false);
+ setExamples(result);
+ })
+ .catch((error) =>
+ setErrorData({
+ title: "there was an error loading examples, please try again",
+ list: [error.message],
+ })
+ );
+ }
+
return (
@@ -81,36 +143,81 @@ export default function ImportModal() {
as="h3"
className="text-lg font-medium dark:text-white leading-10 text-gray-900"
>
- Import from
+ {showExamples ?"Select an example":"Import from"}
-
-
-
- }
- onClick={() => console.log("sdsds")}
- textColor="text-slate-400"
- title="Examples"
- >
-
- }
- onClick={() => {uploadFlow();setModalOpen(false)}}
- textColor="text-blue-500"
- title="Local file"
- >
-
+
+ {!showExamples && (
+
+
+ }
+ onClick={() => {
+ setShowExamples(true);
+ handleExamples();
+ }}
+ textColor="text-emerald-400"
+ title="Examples"
+ >
+
+ }
+ onClick={() => {
+ uploadFlow();
+ setModalOpen(false);
+ }}
+ textColor="text-blue-500"
+ title="Local file"
+ >
+
+ )}
+ {showExamples && loadingExamples && (
+
+
+
+ )}
+ {showExamples &&
+ !loadingExamples &&
+ examples.map((example, index) => {
+ return (
+
+ {" "}
+
+ }
+ onClick={() => {
+ addFlow(example);
+ setModalOpen(false);
+ }}
+ textColor="text-emerald-400"
+ title={example.name}
+ >
+
+ );
+ })}
-
diff --git a/src/frontend/src/pages/FlowPage/components/tabComponent/index.tsx b/src/frontend/src/pages/FlowPage/components/tabComponent/index.tsx
index ca21a0a43..a8d098c32 100644
--- a/src/frontend/src/pages/FlowPage/components/tabComponent/index.tsx
+++ b/src/frontend/src/pages/FlowPage/components/tabComponent/index.tsx
@@ -18,7 +18,8 @@ export default function TabComponent({ selected, flow, onClick }:{flow:FlowType,
className="dark:text-white flex justify-between select-none truncate w-44 items-center px-4 my-1.5 border-x border-x-gray-300 dark:border-x-gray-600 -ml-px"
onClick={onClick}
>
- {flow.name}
+
{flow.name}
+