diff --git a/src/frontend/src/pages/MainPage/components/menuBar/index.tsx b/src/frontend/src/pages/MainPage/components/menuBar/index.tsx
new file mode 100644
index 000000000..b87ff556a
--- /dev/null
+++ b/src/frontend/src/pages/MainPage/components/menuBar/index.tsx
@@ -0,0 +1,157 @@
+import React, { useContext } from "react";
+import { TabsContext } from "../../../../contexts/tabsContext";
+import { PopUpContext } from "../../../../contexts/popUpContext";
+import {
+ Menubar,
+ MenubarContent,
+ MenubarItem,
+ MenubarMenu,
+ MenubarTrigger,
+ MenubarRadioGroup,
+ MenubarRadioItem,
+} from "../../../../components/ui/menubar";
+import {
+ ArrowUpTrayIcon,
+ ArrowDownTrayIcon,
+ CodeBracketSquareIcon,
+ CloudArrowUpIcon,
+ PencilSquareIcon,
+ PlusIcon,
+} from "@heroicons/react/24/outline";
+import RenameLabel from "../../../../components/ui/rename-label";
+import _ from "lodash";
+import ImportModal from "../../../../modals/importModal";
+import ExportModal from "../../../../modals/exportModal";
+import ApiModal from "../../../../modals/ApiModal";
+import { alertContext } from "../../../../contexts/alertContext";
+import { updateFlowInDatabase } from "../../../../controllers/API";
+
+const MenuBar = ({ activeTab, setRename, rename, flows, tabIndex }) => {
+ const { updateFlow, setTabIndex, addFlow } = useContext(TabsContext);
+ const { setErrorData } = useContext(alertContext);
+ const { openPopUp } = useContext(PopUpContext);
+
+ function handleSaveFlow(flow) {
+ try {
+ updateFlowInDatabase(flow);
+ // updateFlowStyleInDataBase(flow);
+ } catch (err) {
+ setErrorData(err);
+ }
+ }
+
+ function handleAddFlow() {
+ try {
+ addFlow();
+ // saveFlowStyleInDataBase();
+ } catch (err) {
+ setErrorData(err);
+ }
+ }
+
+ return (
+
+
⛓️
+ {activeTab === "myflow" && (
+
+
+
+
+
+ {
+ if (value !== "") {
+ let newFlow = _.cloneDeep(flows[tabIndex]);
+ newFlow.name = value;
+ updateFlow(newFlow);
+ }
+ }}
+ rename={rename}
+ setRename={setRename}
+ />
+
+
+
+ {
+ openPopUp();
+ }}
+ >
+
+ Import
+
+ {
+ openPopUp();
+ }}
+ >
+
+ Export
+
+ {
+ openPopUp();
+ }}
+ >
+
+ Code
+
+
+
+
+ Edit
+
+ {
+ handleSaveFlow(flows[tabIndex]);
+ }}
+ >
+
+ Save
+
+ {
+ setRename(true);
+ }}
+ >
+
+ Rename
+
+
+
+
+ Flows
+
+ {
+ setTabIndex(parseInt(value));
+ }}
+ >
+ {flows.map((flow, idx) => {
+ return (
+
+ {flow.name}
+
+ );
+ })}
+
+ {
+ handleAddFlow();
+ }}
+ >
+
+ Add Flow
+
+
+
+
+
+ )}
+
+ );
+};
+
+export default MenuBar;
diff --git a/src/frontend/src/pages/MainPage/index.tsx b/src/frontend/src/pages/MainPage/index.tsx
index d5b351ca5..aa3df49a7 100644
--- a/src/frontend/src/pages/MainPage/index.tsx
+++ b/src/frontend/src/pages/MainPage/index.tsx
@@ -15,61 +15,14 @@ import { alertContext } from "../../contexts/alertContext";
import { darkContext } from "../../contexts/darkContext";
import { PopUpContext } from "../../contexts/popUpContext";
import { typesContext } from "../../contexts/typesContext";
-import {
- ArrowDownTrayIcon,
- ArrowTopRightOnSquareIcon,
- ArrowUpTrayIcon,
- ChevronDownIcon,
- CodeBracketSquareIcon,
- GlobeAltIcon,
- PencilSquareIcon,
- CloudArrowUpIcon,
- PlusCircleIcon,
- PlusIcon,
- PlusSmallIcon,
- TrashIcon,
-} from "@heroicons/react/24/outline";
-import {
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuLabel,
- DropdownMenuRadioGroup,
- DropdownMenuRadioItem,
- DropdownMenuSeparator,
- DropdownMenuTrigger,
-} from "../../components/ui/dropdown-menu";
-import ImportModal from "../../modals/importModal";
-import ExportModal from "../../modals/exportModal";
-import ApiModal from "../../modals/ApiModal";
-import { Separator } from "../../components/ui/separator";
import { Button } from "../../components/ui/button";
import { FaGithub } from "react-icons/fa";
-import {
- Card,
- CardContent,
- CardDescription,
- CardFooter,
- CardHeader,
- CardTitle,
-} from "../../components/ui/card";
-import RenameLabel from "../../components/ui/rename-label";
-import _ from "lodash";
-import { Badge } from "../../components/ui/badge";
-import { OpenAiIcon } from "../../icons/OpenAi";
-import { Menu } from "@mui/material";
-import {
- Menubar,
- MenubarContent,
- MenubarItem,
- MenubarMenu,
- MenubarRadioGroup,
- MenubarRadioItem,
- MenubarTrigger,
-} from "../../components/ui/menubar";
-import { updateFlowInDatabase } from "../../controllers/API";
-import { CardComponent } from "../../components/cardComponent";
+import _ from "lodash";
+
+import { updateFlowInDatabase } from "../../controllers/API";
+import { CardComponent } from "./components/cardComponent";
+import { MenuBar } from "./components/menuBar";
export default function HomePage() {
const {
flows,
@@ -81,7 +34,6 @@ export default function HomePage() {
downloadFlow,
} = useContext(TabsContext);
const { openPopUp } = useContext(PopUpContext);
- const { updateFlow } = useContext(TabsContext);
const { templates } = useContext(typesContext);
const AlertWidth = 384;
const { dark, setDark } = useContext(darkContext);
@@ -96,25 +48,6 @@ export default function HomePage() {
}
}, [addFlow, flows.length, templates]);
- function handleAddFlow() {
- try {
- addFlow();
- // saveFlowStyleInDataBase();
- } catch (err) {
- setErrorData(err);
- }
- }
-
- function handleSave(flow) {
- // Put your save logic here.
- try {
- updateFlowInDatabase(flow);
- // updateFlowStyleInDataBase(flow);
- } catch (err) {
- setErrorData(err);
- }
- }
-
return (
flows.length !== 0 && (
-
-
⛓️
- {activeTab === "myflow" && (
-
-
-
-
-
- {
- if (value !== "") {
- let newFlow = _.cloneDeep(flows[tabIndex]);
- newFlow.name = value;
- updateFlow(newFlow);
- }
- }}
- rename={rename}
- setRename={setRename}
- />
-
-
-
- {
- openPopUp();
- }}
- >
-
- Import
-
- {
- openPopUp();
- }}
- >
-
- Export
-
- {
- openPopUp(
-
- );
- }}
- >
-
- Code
-
-
-
-
- Edit
-
-
-
- Save
-
- {
- setRename(true);
- }}
- >
-
- Rename
-
-
-
-
- Flows
-
- {
- setTabIndex(parseInt(value));
- }}
- >
- {flows.map((flow, idx) => {
- return (
-
- {flow.name}
-
- );
- })}
-
- {
- handleAddFlow();
- }}
- >
-
- Add Flow
-
-
-
-
-
- )}
-
+
Explore
My Flows
@@ -260,10 +102,9 @@ export default function HomePage() {
className="text-gray-600 hover:text-gray-500 dark:text-gray-300 dark:hover:text-gray-200 relative"
onClick={(event: React.MouseEvent
) => {
setNotificationCenter(false);
- const top = (event.target as Element).getBoundingClientRect()
- .top;
- const left = (event.target as Element).getBoundingClientRect()
- .left;
+ const { top, left } = (
+ event.target as Element
+ ).getBoundingClientRect();
openPopUp(
<>