fix(GenericNode/index.tsx): import alertContext from correct file path to fix compilation error
feat(alertContext.tsx): add modalContextOpen state and setModalContextOpen function to manage modal context open state fix(genericModal/index.tsx): add useEffect to update modalContextOpen state when modalOpen prop changes feat(typesContext/index.ts): add modalContextOpen state and setModalContextOpen function to typesContext
This commit is contained in:
parent
8e4c701ff3
commit
c6eb90c00c
5 changed files with 22 additions and 4 deletions
|
|
@ -7,13 +7,18 @@ import InputComponent from "../../components/inputComponent";
|
||||||
import { Textarea } from "../../components/ui/textarea";
|
import { Textarea } from "../../components/ui/textarea";
|
||||||
import { priorityFields } from "../../constants/constants";
|
import { priorityFields } from "../../constants/constants";
|
||||||
import { useSSE } from "../../contexts/SSEContext";
|
import { useSSE } from "../../contexts/SSEContext";
|
||||||
|
import { alertContext } from "../../contexts/alertContext";
|
||||||
import { FlowsContext } from "../../contexts/flowsContext";
|
import { FlowsContext } from "../../contexts/flowsContext";
|
||||||
import { typesContext } from "../../contexts/typesContext";
|
import { typesContext } from "../../contexts/typesContext";
|
||||||
import { undoRedoContext } from "../../contexts/undoRedoContext";
|
import { undoRedoContext } from "../../contexts/undoRedoContext";
|
||||||
import NodeToolbarComponent from "../../pages/FlowPage/components/nodeToolbarComponent";
|
import NodeToolbarComponent from "../../pages/FlowPage/components/nodeToolbarComponent";
|
||||||
import { validationStatusType } from "../../types/components";
|
import { validationStatusType } from "../../types/components";
|
||||||
import { NodeDataType } from "../../types/flow";
|
import { NodeDataType } from "../../types/flow";
|
||||||
import { handleKeyDown, scapedJSONStringfy } from "../../utils/reactflowUtils";
|
import {
|
||||||
|
cleanEdges,
|
||||||
|
handleKeyDown,
|
||||||
|
scapedJSONStringfy,
|
||||||
|
} from "../../utils/reactflowUtils";
|
||||||
import { nodeColors, nodeIconsLucide } from "../../utils/styleUtils";
|
import { nodeColors, nodeIconsLucide } from "../../utils/styleUtils";
|
||||||
import { classNames, getFieldTitle } from "../../utils/utils";
|
import { classNames, getFieldTitle } from "../../utils/utils";
|
||||||
import ParameterComponent from "./components/parameterComponent";
|
import ParameterComponent from "./components/parameterComponent";
|
||||||
|
|
@ -45,6 +50,7 @@ export default function GenericNode({
|
||||||
useState<validationStatusType | null>(null);
|
useState<validationStatusType | null>(null);
|
||||||
const [handles, setHandles] = useState<boolean[] | []>([]);
|
const [handles, setHandles] = useState<boolean[] | []>([]);
|
||||||
let numberOfInputs: boolean[] = [];
|
let numberOfInputs: boolean[] = [];
|
||||||
|
const { modalContextOpen } = useContext(alertContext);
|
||||||
|
|
||||||
const { takeSnapshot } = useContext(undoRedoContext);
|
const { takeSnapshot } = useContext(undoRedoContext);
|
||||||
|
|
||||||
|
|
@ -83,7 +89,7 @@ export default function GenericNode({
|
||||||
|
|
||||||
// State for outline color
|
// State for outline color
|
||||||
const { sseData, isBuilding } = useSSE();
|
const { sseData, isBuilding } = useSSE();
|
||||||
/* useEffect(() => {
|
useEffect(() => {
|
||||||
let flow = flows.find((flow) => flow.id === tabId);
|
let flow = flows.find((flow) => flow.id === tabId);
|
||||||
if (reactFlowInstance && flow && flow.data) {
|
if (reactFlowInstance && flow && flow.data) {
|
||||||
cleanEdges({
|
cleanEdges({
|
||||||
|
|
@ -99,7 +105,7 @@ export default function GenericNode({
|
||||||
updateFlow(flow);
|
updateFlow(flow);
|
||||||
}
|
}
|
||||||
countHandles();
|
countHandles();
|
||||||
}, [data]); */
|
}, [modalContextOpen]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setNodeDescription(data.node!.description);
|
setNodeDescription(data.node!.description);
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,8 @@ const initialValue: alertContextType = {
|
||||||
pushNotificationList: () => {},
|
pushNotificationList: () => {},
|
||||||
clearNotificationList: () => {},
|
clearNotificationList: () => {},
|
||||||
removeFromNotificationList: () => {},
|
removeFromNotificationList: () => {},
|
||||||
|
modalContextOpen: false,
|
||||||
|
setModalContextOpen: (open: boolean) => {},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const alertContext = createContext<alertContextType>(initialValue);
|
export const alertContext = createContext<alertContextType>(initialValue);
|
||||||
|
|
@ -49,6 +51,7 @@ export function AlertProvider({ children }: { children: ReactNode }) {
|
||||||
const [notificationCenter, setNotificationCenter] = useState(false);
|
const [notificationCenter, setNotificationCenter] = useState(false);
|
||||||
const [notificationList, setNotificationList] = useState<AlertItemType[]>([]);
|
const [notificationList, setNotificationList] = useState<AlertItemType[]>([]);
|
||||||
const [isTweakPage, setIsTweakPage] = useState<boolean>(false);
|
const [isTweakPage, setIsTweakPage] = useState<boolean>(false);
|
||||||
|
const [modalContextOpen, setModalContextOpen] = useState<boolean>(false);
|
||||||
const pushNotificationList = (notification: AlertItemType) => {
|
const pushNotificationList = (notification: AlertItemType) => {
|
||||||
setNotificationList((old) => {
|
setNotificationList((old) => {
|
||||||
let newNotificationList = _.cloneDeep(old);
|
let newNotificationList = _.cloneDeep(old);
|
||||||
|
|
@ -141,6 +144,8 @@ export function AlertProvider({ children }: { children: ReactNode }) {
|
||||||
setSuccessData,
|
setSuccessData,
|
||||||
successOpen,
|
successOpen,
|
||||||
setSuccessOpen,
|
setSuccessOpen,
|
||||||
|
modalContextOpen,
|
||||||
|
setModalContextOpen,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ export default function GenericModal({
|
||||||
const [inputValue, setInputValue] = useState(value);
|
const [inputValue, setInputValue] = useState(value);
|
||||||
const [isEdit, setIsEdit] = useState(true);
|
const [isEdit, setIsEdit] = useState(true);
|
||||||
const [wordsHighlight, setWordsHighlight] = useState<string[]>([]);
|
const [wordsHighlight, setWordsHighlight] = useState<string[]>([]);
|
||||||
const { setErrorData, setSuccessData, setNoticeData } =
|
const { setErrorData, setSuccessData, setNoticeData, setModalContextOpen } =
|
||||||
useContext(alertContext);
|
useContext(alertContext);
|
||||||
const ref = useRef();
|
const ref = useRef();
|
||||||
const divRef = useRef(null);
|
const divRef = useRef(null);
|
||||||
|
|
@ -160,6 +160,10 @@ export default function GenericModal({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setModalContextOpen(modalOpen);
|
||||||
|
}, [modalOpen]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BaseModal
|
<BaseModal
|
||||||
onChangeOpenModal={(open) => {}}
|
onChangeOpenModal={(open) => {}}
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ export type ParameterComponentType = {
|
||||||
proxy?: { field: string; id: string };
|
proxy?: { field: string; id: string };
|
||||||
showNode?: boolean;
|
showNode?: boolean;
|
||||||
index?: string;
|
index?: string;
|
||||||
|
onCloseModal?: (close: boolean) => void;
|
||||||
};
|
};
|
||||||
export type InputListComponentType = {
|
export type InputListComponentType = {
|
||||||
value: string[];
|
value: string[];
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,8 @@ export type alertContextType = {
|
||||||
removeFromNotificationList: (index: string) => void;
|
removeFromNotificationList: (index: string) => void;
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
setLoading: (newState: boolean) => void;
|
setLoading: (newState: boolean) => void;
|
||||||
|
modalContextOpen: boolean | null;
|
||||||
|
setModalContextOpen: (newState: boolean) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type darkContextType = {
|
export type darkContextType = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue