diff --git a/src/frontend/src/App.tsx b/src/frontend/src/App.tsx index 7f15c8fe8..b900a698b 100644 --- a/src/frontend/src/App.tsx +++ b/src/frontend/src/App.tsx @@ -15,7 +15,6 @@ import { FETCH_ERROR_DESCRIPION, FETCH_ERROR_MESSAGE, } from "./constants/constants"; -import { alertContext } from "./contexts/alertContext"; import { locationContext } from "./contexts/locationContext"; import { typesContext } from "./contexts/typesContext"; import Router from "./routes"; diff --git a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx index 3d2fe05b8..49a339a35 100644 --- a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx @@ -26,7 +26,6 @@ import { LANGFLOW_SUPPORTED_TYPES, TOOLTIP_EMPTY, } from "../../../../constants/constants"; -import { alertContext } from "../../../../contexts/alertContext"; import { FlowsContext } from "../../../../contexts/flowsContext"; import { typesContext } from "../../../../contexts/typesContext"; import { undoRedoContext } from "../../../../contexts/undoRedoContext"; diff --git a/src/frontend/src/alerts/alertDropDown/index.tsx b/src/frontend/src/alerts/alertDropDown/index.tsx index 7fc68dbe1..f4b6a3eb1 100644 --- a/src/frontend/src/alerts/alertDropDown/index.tsx +++ b/src/frontend/src/alerts/alertDropDown/index.tsx @@ -5,7 +5,6 @@ import { PopoverContent, PopoverTrigger, } from "../../components/ui/popover"; -import { alertContext } from "../../contexts/alertContext"; import { AlertDropdownType } from "../../types/alerts"; import SingleAlert from "./components/singleAlertComponent"; import useAlertStore from "../../stores/alertStore"; diff --git a/src/frontend/src/components/cardComponent/index.tsx b/src/frontend/src/components/cardComponent/index.tsx index d67e68a02..c4abc93ac 100644 --- a/src/frontend/src/components/cardComponent/index.tsx +++ b/src/frontend/src/components/cardComponent/index.tsx @@ -1,5 +1,4 @@ import { useContext, useEffect, useState } from "react"; -import { alertContext } from "../../contexts/alertContext"; import { FlowsContext } from "../../contexts/flowsContext"; import { getComponent, postLikeComponent } from "../../controllers/API"; import DeleteConfirmationModal from "../../modals/DeleteConfirmationModal"; diff --git a/src/frontend/src/components/chatComponent/buildTrigger/index.tsx b/src/frontend/src/components/chatComponent/buildTrigger/index.tsx index 705babf83..78ed618ba 100644 --- a/src/frontend/src/components/chatComponent/buildTrigger/index.tsx +++ b/src/frontend/src/components/chatComponent/buildTrigger/index.tsx @@ -2,7 +2,6 @@ import { Transition } from "@headlessui/react"; import { useContext, useState } from "react"; import Loading from "../../../components/ui/loading"; import { useSSE } from "../../../contexts/SSEContext"; -import { alertContext } from "../../../contexts/alertContext"; import { postBuildInit } from "../../../controllers/API"; import { FlowType } from "../../../types/flow"; diff --git a/src/frontend/src/components/chatComponent/chatTrigger/index.tsx b/src/frontend/src/components/chatComponent/chatTrigger/index.tsx index 4d76c6179..93a90b3ec 100644 --- a/src/frontend/src/components/chatComponent/chatTrigger/index.tsx +++ b/src/frontend/src/components/chatComponent/chatTrigger/index.tsx @@ -7,7 +7,6 @@ import { FLOW_NOT_BUILT_DESCRIPTION, FLOW_NOT_BUILT_TITLE, } from "../../../constants/constants"; -import { alertContext } from "../../../contexts/alertContext"; import { chatTriggerPropType } from "../../../types/components"; import IconComponent from "../../genericIconComponent"; import useAlertStore from "../../../stores/alertStore"; diff --git a/src/frontend/src/components/headerComponent/components/menuBar/index.tsx b/src/frontend/src/components/headerComponent/components/menuBar/index.tsx index ef7a3ceec..32530ebda 100644 --- a/src/frontend/src/components/headerComponent/components/menuBar/index.tsx +++ b/src/frontend/src/components/headerComponent/components/menuBar/index.tsx @@ -9,7 +9,6 @@ import { } from "../../../ui/dropdown-menu"; import { useNavigate } from "react-router-dom"; -import { alertContext } from "../../../../contexts/alertContext"; import { undoRedoContext } from "../../../../contexts/undoRedoContext"; import FlowSettingsModal from "../../../../modals/flowSettingsModal"; import { menuBarPropsType } from "../../../../types/components"; diff --git a/src/frontend/src/components/headerComponent/index.tsx b/src/frontend/src/components/headerComponent/index.tsx index 4070225b7..05532137b 100644 --- a/src/frontend/src/components/headerComponent/index.tsx +++ b/src/frontend/src/components/headerComponent/index.tsx @@ -3,7 +3,6 @@ import { FaDiscord, FaGithub, FaTwitter } from "react-icons/fa"; import { Link, useLocation, useNavigate } from "react-router-dom"; import AlertDropdown from "../../alerts/alertDropDown"; import { USER_PROJECTS_HEADER } from "../../constants/constants"; -import { alertContext } from "../../contexts/alertContext"; import { AuthContext } from "../../contexts/authContext"; import { FlowsContext } from "../../contexts/flowsContext"; diff --git a/src/frontend/src/components/inputFileComponent/index.tsx b/src/frontend/src/components/inputFileComponent/index.tsx index 9e589ca8b..f7b707d7c 100644 --- a/src/frontend/src/components/inputFileComponent/index.tsx +++ b/src/frontend/src/components/inputFileComponent/index.tsx @@ -1,5 +1,4 @@ import { useContext, useEffect, useState } from "react"; -import { alertContext } from "../../contexts/alertContext"; import { FlowsContext } from "../../contexts/flowsContext"; import { uploadFile } from "../../controllers/API"; import { FileComponentType } from "../../types/components"; diff --git a/src/frontend/src/contexts/alertContext.tsx b/src/frontend/src/contexts/alertContext.tsx deleted file mode 100644 index 171177d5b..000000000 --- a/src/frontend/src/contexts/alertContext.tsx +++ /dev/null @@ -1,153 +0,0 @@ -import { createContext, ReactNode, useState } from "react"; -import { AlertItemType } from "../types/alerts"; -import { alertContextType } from "../types/typesContext"; - -import _ from "lodash"; - -//initial values to alertContextType -const initialValue: alertContextType = { - errorData: { title: "", list: [] }, - setErrorData: () => {}, - loading: true, - setLoading: () => {}, - errorOpen: false, - setErrorOpen: () => {}, - noticeData: { title: "", link: "" }, - setNoticeData: () => {}, - noticeOpen: false, - setNoticeOpen: () => {}, - successData: { title: "" }, - setSuccessData: () => {}, - successOpen: false, - setSuccessOpen: () => {}, - notificationCenter: false, - setNotificationCenter: () => {}, - notificationList: [], - pushNotificationList: () => {}, - clearNotificationList: () => {}, - removeFromNotificationList: () => {}, - modalContextOpen: false, - setModalContextOpen: (open: boolean) => {}, -}; - -export const alertContext = createContext(initialValue); - -export function AlertProvider({ children }: { children: ReactNode }) { - const [errorData, setErrorDataState] = useState<{ - title: string; - list?: Array; - }>({ title: "", list: [] }); - const [errorOpen, setErrorOpen] = useState(false); - const [loading, setLoading] = useState(true); - const [noticeData, setNoticeDataState] = useState<{ - title: string; - link?: string; - }>({ title: "", link: "" }); - const [noticeOpen, setNoticeOpen] = useState(false); - const [successData, setSuccessDataState] = useState<{ title: string }>({ - title: "", - }); - const [successOpen, setSuccessOpen] = useState(false); - const [notificationCenter, setNotificationCenter] = useState(false); - const [notificationList, setNotificationList] = useState([]); - const [modalContextOpen, setModalContextOpen] = useState(false); - const pushNotificationList = (notification: AlertItemType) => { - setNotificationList((old) => { - let newNotificationList = _.cloneDeep(old); - newNotificationList.unshift(notification); - return newNotificationList; - }); - }; - /** - * Sets the error data state, opens the error dialog and pushes the new error notification to the notification list - * @param newState An object containing the new error data, including title and optional list of error messages - */ - function setErrorData(newState: { title: string; list?: Array }) { - if (newState.title && newState.title !== "") { - setErrorDataState(newState); - setErrorOpen(true); - setNotificationCenter(true); - pushNotificationList({ - type: "error", - title: newState.title, - list: newState.list, - id: _.uniqueId(), - }); - } - } - /** - * Sets the state of the notice data and opens the notice modal, also adds a new notice to the notification center if the title is defined. - * @param newState An object containing the title of the notice and optionally a link. - */ - function setNoticeData(newState: { title: string; link?: string }) { - if (newState.title && newState.title !== "") { - setNoticeDataState(newState); - setNoticeOpen(true); - // Add new notice to notification center - setNotificationCenter(true); - pushNotificationList({ - type: "notice", - title: newState.title, - link: newState.link, - id: _.uniqueId(), - }); - } - } - /** - * Update the success data state and show a success alert notification. - * @param newState - A state object with a "title" property to set in the success data state. - */ - function setSuccessData(newState: { title: string }) { - // If the new state has a "title" property, add a new success notification to the list - if (newState.title && newState.title !== "") { - setSuccessDataState(newState); // update the success data state with the provided new state - setSuccessOpen(true); // open the success alert - setNotificationCenter(true); // show the notification center - pushNotificationList({ - // add the new notification to the list - type: "success", - title: newState.title, - id: _.uniqueId(), - }); - } - } - function clearNotificationList() { - setNotificationList([]); - } - function removeFromNotificationList(index: string) { - // set the notification list to a new array that filters out the alert with the matching id - setNotificationList((prevAlertsList) => - prevAlertsList.filter((alert) => alert.id !== index) - ); - } - return ( - - {children} - - ); -} diff --git a/src/frontend/src/contexts/authContext.tsx b/src/frontend/src/contexts/authContext.tsx index e69e021d2..39555dbaa 100644 --- a/src/frontend/src/contexts/authContext.tsx +++ b/src/frontend/src/contexts/authContext.tsx @@ -3,7 +3,6 @@ import Cookies from "universal-cookie"; import { autoLogin as autoLoginApi, getLoggedUser } from "../controllers/API"; import { Users } from "../types/api"; import { AuthContextType } from "../types/contexts/auth"; -import { alertContext } from "./alertContext"; import useAlertStore from "../stores/alertStore"; const initialValue: AuthContextType = { diff --git a/src/frontend/src/contexts/flowsContext.tsx b/src/frontend/src/contexts/flowsContext.tsx index 9891d7833..cad78795a 100644 --- a/src/frontend/src/contexts/flowsContext.tsx +++ b/src/frontend/src/contexts/flowsContext.tsx @@ -58,7 +58,6 @@ import { getRandomDescription, getRandomName, } from "../utils/utils"; -import { alertContext } from "./alertContext"; import { AuthContext } from "./authContext"; import { typesContext } from "./typesContext"; import useFlowStore from "../stores/flowStore"; diff --git a/src/frontend/src/contexts/typesContext.tsx b/src/frontend/src/contexts/typesContext.tsx index a4a9e2965..83e6ec5fa 100644 --- a/src/frontend/src/contexts/typesContext.tsx +++ b/src/frontend/src/contexts/typesContext.tsx @@ -10,7 +10,6 @@ import { ReactFlowInstance } from "reactflow"; import { getAll, getHealth } from "../controllers/API"; import { APIKindType } from "../types/api"; import { typesContextType } from "../types/typesContext"; -import { alertContext } from "./alertContext"; import { AuthContext } from "./authContext"; import useAlertStore from "../stores/alertStore"; diff --git a/src/frontend/src/modals/EditNodeModal/index.tsx b/src/frontend/src/modals/EditNodeModal/index.tsx index ff899158a..a82d9e0b1 100644 --- a/src/frontend/src/modals/EditNodeModal/index.tsx +++ b/src/frontend/src/modals/EditNodeModal/index.tsx @@ -28,7 +28,6 @@ import { LANGFLOW_SUPPORTED_TYPES, limitScrollFieldsModal, } from "../../constants/constants"; -import { alertContext } from "../../contexts/alertContext"; import { NodeDataType } from "../../types/flow"; import { convertObjToArray, diff --git a/src/frontend/src/modals/SecretKeyModal/index.tsx b/src/frontend/src/modals/SecretKeyModal/index.tsx index f9b6d9732..bf147d624 100644 --- a/src/frontend/src/modals/SecretKeyModal/index.tsx +++ b/src/frontend/src/modals/SecretKeyModal/index.tsx @@ -3,7 +3,6 @@ import { useContext, useEffect, useRef, useState } from "react"; import IconComponent from "../../components/genericIconComponent"; import { Button } from "../../components/ui/button"; import { Input } from "../../components/ui/input"; -import { alertContext } from "../../contexts/alertContext"; import { createApiKey } from "../../controllers/API"; import { ApiKeyType } from "../../types/components"; import { nodeIconsLucide } from "../../utils/styleUtils"; diff --git a/src/frontend/src/modals/StoreApiKeyModal/index.tsx b/src/frontend/src/modals/StoreApiKeyModal/index.tsx index 2dbc2ff4b..b9347fc0e 100644 --- a/src/frontend/src/modals/StoreApiKeyModal/index.tsx +++ b/src/frontend/src/modals/StoreApiKeyModal/index.tsx @@ -3,7 +3,6 @@ import { useContext, useState } from "react"; import IconComponent from "../../components/genericIconComponent"; import { Button } from "../../components/ui/button"; import { Input } from "../../components/ui/input"; -import { alertContext } from "../../contexts/alertContext"; import { AuthContext } from "../../contexts/authContext"; import { addApiKeyStore } from "../../controllers/API"; import { useStoreStore } from "../../stores/storeStore"; diff --git a/src/frontend/src/modals/codeAreaModal/index.tsx b/src/frontend/src/modals/codeAreaModal/index.tsx index df33e54b5..fbbbd2676 100644 --- a/src/frontend/src/modals/codeAreaModal/index.tsx +++ b/src/frontend/src/modals/codeAreaModal/index.tsx @@ -10,7 +10,6 @@ import IconComponent from "../../components/genericIconComponent"; import { Button } from "../../components/ui/button"; import { Input } from "../../components/ui/input"; import { CODE_PROMPT_DIALOG_SUBTITLE } from "../../constants/constants"; -import { alertContext } from "../../contexts/alertContext"; import { postCustomComponent, postValidateCode } from "../../controllers/API"; import { useDarkStore } from "../../stores/darkStore"; import { codeAreaModalPropsType } from "../../types/components"; diff --git a/src/frontend/src/modals/exportModal/index.tsx b/src/frontend/src/modals/exportModal/index.tsx index 180e3db8b..243865b77 100644 --- a/src/frontend/src/modals/exportModal/index.tsx +++ b/src/frontend/src/modals/exportModal/index.tsx @@ -4,7 +4,6 @@ import IconComponent from "../../components/genericIconComponent"; import { Button } from "../../components/ui/button"; import { Checkbox } from "../../components/ui/checkbox"; import { EXPORT_DIALOG_SUBTITLE } from "../../constants/constants"; -import { alertContext } from "../../contexts/alertContext"; import { FlowsContext } from "../../contexts/flowsContext"; import { removeApiKeys } from "../../utils/reactflowUtils"; import BaseModal from "../baseModal"; diff --git a/src/frontend/src/modals/formModal/index.tsx b/src/frontend/src/modals/formModal/index.tsx index 6ac62689a..ae895846f 100644 --- a/src/frontend/src/modals/formModal/index.tsx +++ b/src/frontend/src/modals/formModal/index.tsx @@ -1,5 +1,4 @@ import { useContext, useEffect, useRef, useState } from "react"; -import { alertContext } from "../../contexts/alertContext"; import { sendAllProps } from "../../types/api"; import { ChatMessageType } from "../../types/chat"; import { FlowType } from "../../types/flow"; diff --git a/src/frontend/src/modals/genericModal/index.tsx b/src/frontend/src/modals/genericModal/index.tsx index f57ffef4d..6557b0d06 100644 --- a/src/frontend/src/modals/genericModal/index.tsx +++ b/src/frontend/src/modals/genericModal/index.tsx @@ -13,7 +13,6 @@ import { regexHighlight, } from "../../constants/constants"; import { TypeModal } from "../../constants/enums"; -import { alertContext } from "../../contexts/alertContext"; import { postValidatePrompt } from "../../controllers/API"; import { genericModalPropsType } from "../../types/components"; import { handleKeyDown } from "../../utils/reactflowUtils"; diff --git a/src/frontend/src/modals/shareModal/index.tsx b/src/frontend/src/modals/shareModal/index.tsx index ad75bc142..3c5494016 100644 --- a/src/frontend/src/modals/shareModal/index.tsx +++ b/src/frontend/src/modals/shareModal/index.tsx @@ -5,7 +5,6 @@ import IconComponent from "../../components/genericIconComponent"; import { TagsSelector } from "../../components/tagsSelectorComponent"; import { Button } from "../../components/ui/button"; import { Checkbox } from "../../components/ui/checkbox"; -import { alertContext } from "../../contexts/alertContext"; import { FlowsContext } from "../../contexts/flowsContext"; import { getStoreComponents, diff --git a/src/frontend/src/pages/AdminPage/LoginPage/index.tsx b/src/frontend/src/pages/AdminPage/LoginPage/index.tsx index d2a077771..78781c2c8 100644 --- a/src/frontend/src/pages/AdminPage/LoginPage/index.tsx +++ b/src/frontend/src/pages/AdminPage/LoginPage/index.tsx @@ -3,7 +3,6 @@ import { useNavigate } from "react-router-dom"; import { Button } from "../../../components/ui/button"; import { Input } from "../../../components/ui/input"; import { CONTROL_LOGIN_STATE } from "../../../constants/constants"; -import { alertContext } from "../../../contexts/alertContext"; import { AuthContext } from "../../../contexts/authContext"; import { getLoggedUser, onLogin } from "../../../controllers/API"; import { LoginType } from "../../../types/api"; diff --git a/src/frontend/src/pages/AdminPage/index.tsx b/src/frontend/src/pages/AdminPage/index.tsx index fa59e29bc..145341ab9 100644 --- a/src/frontend/src/pages/AdminPage/index.tsx +++ b/src/frontend/src/pages/AdminPage/index.tsx @@ -20,7 +20,6 @@ import { ADMIN_HEADER_DESCRIPTION, ADMIN_HEADER_TITLE, } from "../../constants/constants"; -import { alertContext } from "../../contexts/alertContext"; import { AuthContext } from "../../contexts/authContext"; import { FlowsContext } from "../../contexts/flowsContext"; import { diff --git a/src/frontend/src/pages/ApiKeysPage/index.tsx b/src/frontend/src/pages/ApiKeysPage/index.tsx index 09d402711..69b7ccc5b 100644 --- a/src/frontend/src/pages/ApiKeysPage/index.tsx +++ b/src/frontend/src/pages/ApiKeysPage/index.tsx @@ -10,7 +10,6 @@ import { TableHeader, TableRow, } from "../../components/ui/table"; -import { alertContext } from "../../contexts/alertContext"; import { AuthContext } from "../../contexts/authContext"; import { deleteApiKey, getApiKey } from "../../controllers/API"; import ConfirmationModal from "../../modals/ConfirmationModal"; diff --git a/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx b/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx index a8a5787e8..0d2d95b98 100644 --- a/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx +++ b/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx @@ -4,7 +4,6 @@ import ShadTooltip from "../../../../components/ShadTooltipComponent"; import IconComponent from "../../../../components/genericIconComponent"; import { Input } from "../../../../components/ui/input"; import { Separator } from "../../../../components/ui/separator"; -import { alertContext } from "../../../../contexts/alertContext"; import { FlowsContext } from "../../../../contexts/flowsContext"; import { typesContext } from "../../../../contexts/typesContext"; import ApiModal from "../../../../modals/ApiModal"; diff --git a/src/frontend/src/pages/ProfileSettingsPage/index.tsx b/src/frontend/src/pages/ProfileSettingsPage/index.tsx index 90c762eea..3d040ea28 100644 --- a/src/frontend/src/pages/ProfileSettingsPage/index.tsx +++ b/src/frontend/src/pages/ProfileSettingsPage/index.tsx @@ -7,7 +7,6 @@ import Header from "../../components/headerComponent"; import InputComponent from "../../components/inputComponent"; import { Button } from "../../components/ui/button"; import { CONTROL_PATCH_USER_STATE } from "../../constants/constants"; -import { alertContext } from "../../contexts/alertContext"; import { AuthContext } from "../../contexts/authContext"; import { FlowsContext } from "../../contexts/flowsContext"; import { resetPassword, updateUser } from "../../controllers/API"; diff --git a/src/frontend/src/pages/StorePage/index.tsx b/src/frontend/src/pages/StorePage/index.tsx index 5b07461f9..91d9cde18 100644 --- a/src/frontend/src/pages/StorePage/index.tsx +++ b/src/frontend/src/pages/StorePage/index.tsx @@ -20,7 +20,6 @@ import { SelectTrigger, SelectValue, } from "../../components/ui/select"; -import { alertContext } from "../../contexts/alertContext"; import { AuthContext } from "../../contexts/authContext"; import { FlowsContext } from "../../contexts/flowsContext"; import { diff --git a/src/frontend/src/pages/signUpPage/index.tsx b/src/frontend/src/pages/signUpPage/index.tsx index 93900f15d..ba309a37b 100644 --- a/src/frontend/src/pages/signUpPage/index.tsx +++ b/src/frontend/src/pages/signUpPage/index.tsx @@ -8,7 +8,6 @@ import { CONTROL_INPUT_STATE, SIGN_UP_SUCCESS, } from "../../constants/constants"; -import { alertContext } from "../../contexts/alertContext"; import { addUser } from "../../controllers/API"; import { UserInputType,