Fixed bug on opening new flow
This commit is contained in:
parent
303f8c38ee
commit
2ea282eda9
2 changed files with 12 additions and 43 deletions
|
|
@ -3,7 +3,6 @@ import "ace-builds/src-noconflict/mode-python";
|
||||||
import "ace-builds/src-noconflict/theme-github";
|
import "ace-builds/src-noconflict/theme-github";
|
||||||
import "ace-builds/src-noconflict/theme-twilight";
|
import "ace-builds/src-noconflict/theme-twilight";
|
||||||
import { ReactNode, useContext, useEffect, useRef, useState } from "react";
|
import { ReactNode, useContext, useEffect, useRef, useState } from "react";
|
||||||
import { PopUpContext } from "../../contexts/popUpContext";
|
|
||||||
// import "ace-builds/webpack-resolver";
|
// import "ace-builds/webpack-resolver";
|
||||||
import { Check, Clipboard, Code2 } from "lucide-react";
|
import { Check, Clipboard, Code2 } from "lucide-react";
|
||||||
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
|
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
|
||||||
|
|
@ -41,7 +40,6 @@ import {
|
||||||
getPythonApiCode,
|
getPythonApiCode,
|
||||||
getPythonCode,
|
getPythonCode,
|
||||||
} from "../../constants";
|
} from "../../constants";
|
||||||
import { darkContext } from "../../contexts/darkContext";
|
|
||||||
import { TabsContext } from "../../contexts/tabsContext";
|
import { TabsContext } from "../../contexts/tabsContext";
|
||||||
import { FlowType } from "../../types/flow/index";
|
import { FlowType } from "../../types/flow/index";
|
||||||
import { buildTweaks, classNames } from "../../utils";
|
import { buildTweaks, classNames } from "../../utils";
|
||||||
|
|
@ -54,12 +52,8 @@ export default function ApiModal({
|
||||||
flow: FlowType;
|
flow: FlowType;
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
}) {
|
}) {
|
||||||
const [open, setOpen] = useState(true);
|
|
||||||
const { dark } = useContext(darkContext);
|
|
||||||
const { closePopUp, closeEdit, setCloseEdit } = useContext(PopUpContext);
|
|
||||||
const [activeTab, setActiveTab] = useState("0");
|
const [activeTab, setActiveTab] = useState("0");
|
||||||
const [isCopied, setIsCopied] = useState<Boolean>(false);
|
const [isCopied, setIsCopied] = useState<Boolean>(false);
|
||||||
const [enabled, setEnabled] = useState(null);
|
|
||||||
const [openAccordion, setOpenAccordion] = useState([]);
|
const [openAccordion, setOpenAccordion] = useState([]);
|
||||||
const tweak = useRef([]);
|
const tweak = useRef([]);
|
||||||
const tweaksList = useRef([]);
|
const tweaksList = useRef([]);
|
||||||
|
|
@ -103,22 +97,6 @@ export default function ApiModal({
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (closeEdit !== "") {
|
|
||||||
tweak.current = getTweak;
|
|
||||||
if (tweak.current.length > 0) {
|
|
||||||
setActiveTab("3");
|
|
||||||
openAccordions();
|
|
||||||
} else {
|
|
||||||
startTweaks();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (tweak?.current) {
|
|
||||||
startTweaks();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, [closeEdit]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
filterNodes();
|
filterNodes();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
@ -132,20 +110,6 @@ export default function ApiModal({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function setModalOpen(x: boolean) {
|
|
||||||
setOpen(x);
|
|
||||||
if (x === false) {
|
|
||||||
setCloseEdit("");
|
|
||||||
setTweak([]);
|
|
||||||
closePopUp();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function startTweaks() {
|
|
||||||
const t = buildTweaks(flow);
|
|
||||||
tweak?.current?.push(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
function filterNodes() {
|
function filterNodes() {
|
||||||
let arrNodesWithValues = [];
|
let arrNodesWithValues = [];
|
||||||
|
|
||||||
|
|
@ -493,7 +457,6 @@ export default function ApiModal({
|
||||||
t.data.node.template[
|
t.data.node.template[
|
||||||
n
|
n
|
||||||
].value = e;
|
].value = e;
|
||||||
setEnabled(e);
|
|
||||||
buildTweakObject(
|
buildTweakObject(
|
||||||
t["data"]["id"],
|
t["data"]["id"],
|
||||||
e,
|
e,
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ export default function ExtraSidebar() {
|
||||||
return ret;
|
return ret;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
const flow = flows.find((f) => f.id === tabId);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="side-bar-arrangement">
|
<div className="side-bar-arrangement">
|
||||||
|
|
@ -83,18 +84,23 @@ export default function ExtraSidebar() {
|
||||||
</ExportModal>
|
</ExportModal>
|
||||||
</ShadTooltip>
|
</ShadTooltip>
|
||||||
<ShadTooltip content="Code" side="top">
|
<ShadTooltip content="Code" side="top">
|
||||||
<ApiModal flow={flows.find((f) => f.id === tabId)}>
|
{flow && flow.data && (
|
||||||
|
<ApiModal flow={flow}>
|
||||||
<button className={classNames("extra-side-bar-buttons")}>
|
<button className={classNames("extra-side-bar-buttons")}>
|
||||||
<Code2 strokeWidth={1.5} className="side-bar-button-size"></Code2>
|
<Code2
|
||||||
|
strokeWidth={1.5}
|
||||||
|
className="side-bar-button-size"
|
||||||
|
></Code2>
|
||||||
</button>
|
</button>
|
||||||
</ApiModal>
|
</ApiModal>
|
||||||
|
)}
|
||||||
</ShadTooltip>
|
</ShadTooltip>
|
||||||
|
|
||||||
<ShadTooltip content="Save" side="top">
|
<ShadTooltip content="Save" side="top">
|
||||||
<button
|
<button
|
||||||
className="extra-side-bar-buttons"
|
className="extra-side-bar-buttons"
|
||||||
onClick={(event) => {
|
onClick={(event) => {
|
||||||
saveFlow(flows.find((f) => f.id === tabId));
|
saveFlow(flow);
|
||||||
setSuccessData({ title: "Changes saved successfully" });
|
setSuccessData({ title: "Changes saved successfully" });
|
||||||
}}
|
}}
|
||||||
disabled={!isPending}
|
disabled={!isPending}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue