From 3a9a89840d03ea8f6cc15c71e6b0e15be64cd157 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Thu, 13 Jul 2023 17:44:21 -0300 Subject: [PATCH] Changed flowSettings to new type of popup --- .../components/menuBar/index.tsx | 37 ++++------------- .../src/modals/flowSettingsModal/index.tsx | 41 ++++++++----------- 2 files changed, 27 insertions(+), 51 deletions(-) diff --git a/src/frontend/src/components/headerComponent/components/menuBar/index.tsx b/src/frontend/src/components/headerComponent/components/menuBar/index.tsx index b362307e7..68047f352 100644 --- a/src/frontend/src/components/headerComponent/components/menuBar/index.tsx +++ b/src/frontend/src/components/headerComponent/components/menuBar/index.tsx @@ -6,8 +6,7 @@ import { Settings2, Undo, } from "lucide-react"; -import { useContext } from "react"; -import { PopUpContext } from "../../../../contexts/popUpContext"; +import { useContext, useState } from "react"; import { TabsContext } from "../../../../contexts/tabsContext"; import { DropdownMenu, @@ -26,8 +25,8 @@ import { Button } from "../../../ui/button"; export const MenuBar = ({ flows, tabId }) => { const { updateFlow, setTabId, addFlow } = useContext(TabsContext); const { setErrorData } = useContext(alertContext); - const { openPopUp } = useContext(PopUpContext); const { undo, redo } = useContext(undoRedoContext); + const [openSettings, setOpenSettings] = useState(false); const navigate = useNavigate(); @@ -69,15 +68,17 @@ export const MenuBar = ({ flows, tabId }) => { New + { - openPopUp(); + setOpenSettings(true); }} className="cursor-pointer" > Settings + { undo(); @@ -96,32 +97,12 @@ export const MenuBar = ({ flows, tabId }) => { Redo - {/* */} - {/* Projects */} - {/* { - setTabId(value); - }} - > - {flows.map((flow, idx) => { - return ( - - - {flow.name} - - - ); - })} - */} + ); diff --git a/src/frontend/src/modals/flowSettingsModal/index.tsx b/src/frontend/src/modals/flowSettingsModal/index.tsx index db53a2fe4..f36f05c37 100644 --- a/src/frontend/src/modals/flowSettingsModal/index.tsx +++ b/src/frontend/src/modals/flowSettingsModal/index.tsx @@ -2,16 +2,18 @@ import { Settings2 } from "lucide-react"; import { useContext, useRef, useState } from "react"; import EditFlowSettings from "../../components/EditFlowSettingsComponent"; import { Button } from "../../components/ui/button"; -import { DialogTitle } from "../../components/ui/dialog"; import { SETTINGS_DIALOG_SUBTITLE } from "../../constants"; import { alertContext } from "../../contexts/alertContext"; -import { PopUpContext } from "../../contexts/popUpContext"; import { TabsContext } from "../../contexts/tabsContext"; import BaseModal from "../baseModal"; -export default function FlowSettingsModal() { - const [open, setOpen] = useState(true); - const { closePopUp } = useContext(PopUpContext); +export default function FlowSettingsModal({ + open, + setOpen, +}: { + open: boolean; + setOpen: (open: boolean) => void; +}) { const { setErrorData, setSuccessData } = useContext(alertContext); const ref = useRef(); const { flows, tabId, updateFlow, setTabsState, saveFlow } = @@ -21,33 +23,26 @@ export default function FlowSettingsModal() { const [description, setDescription] = useState( flows.find((f) => f.id === tabId).description ); - function setModalOpen(x: boolean) { - setOpen(x); - if (x === false) { - setTimeout(() => { - closePopUp(); - }, 300); - } - } function handleClick() { let savedFlow = flows.find((f) => f.id === tabId); savedFlow.name = name; savedFlow.description = description; saveFlow(savedFlow); setSuccessData({ title: "Changes saved successfully" }); - closePopUp(); + setOpen(false); } return ( - + + + <> + - - Settings - + Settings +