formatting

This commit is contained in:
Cristhian Zanforlin Lousa 2023-06-28 14:20:53 -03:00
commit 1251cf70a9

View file

@ -92,8 +92,6 @@ export default function ApiModal({ flow }: { flow: FlowType }) {
} }
}, [closeEdit]); }, [closeEdit]);
const pythonApiCode = getPythonApiCode(flow, tweak.current); const pythonApiCode = getPythonApiCode(flow, tweak.current);
const curl_code = getCurlCode(flow, tweak.current); const curl_code = getCurlCode(flow, tweak.current);
const pythonCode = getPythonCode(flow, tweak.current); const pythonCode = getPythonCode(flow, tweak.current);
@ -101,43 +99,32 @@ export default function ApiModal({ flow }: { flow: FlowType }) {
useEffect(() => { useEffect(() => {
filterNodes(); filterNodes();
}, []);
}, [])
function filterNodes() { function filterNodes() {
let arrNodesWithValues = []; let arrNodesWithValues = [];
flow["data"]["nodes"].forEach(t => { flow["data"]["nodes"].forEach((t) => {
Object.keys(t["data"]["node"]["template"])
Object.keys(t['data']['node']['template']).filter( .filter(
(n) => (n) =>
n.charAt(0) !== "_" && n.charAt(0) !== "_" &&
t.data.node.template[n].show && t.data.node.template[n].show &&
(t.data.node.template[n].type === (t.data.node.template[n].type === "str" ||
"str" || t.data.node.template[n].type === "bool" ||
t.data.node.template[n].type === t.data.node.template[n].type === "float" ||
"bool" || t.data.node.template[n].type === "code" ||
t.data.node.template[n].type === t.data.node.template[n].type === "prompt" ||
"float" || t.data.node.template[n].type === "file" ||
t.data.node.template[n].type === t.data.node.template[n].type === "int")
"code" ||
t.data.node.template[n].type ===
"prompt" ||
t.data.node.template[n].type ===
"file" ||
t.data.node.template[n].type ===
"int")
) )
.map((n, i) => { .map((n, i) => {
arrNodesWithValues.push(t['id']) arrNodesWithValues.push(t["id"]);
}) });
});
})
tweaksList.current = arrNodesWithValues.filter((value, index, self) => { tweaksList.current = arrNodesWithValues.filter((value, index, self) => {
return self.indexOf(value) === index; return self.indexOf(value) === index;
}); });
} }
const tabs = [ const tabs = [
@ -337,12 +324,7 @@ export default function ApiModal({ flow }: { flow: FlowType }) {
> >
{flow["data"]["nodes"].map((t: any, index) => ( {flow["data"]["nodes"].map((t: any, index) => (
<div className="px-3" key={index}> <div className="px-3" key={index}>
{( {tweaksList.current.includes(t["data"]["id"]) && (
tweaksList.current.includes(t["data"]["id"]) &&
<AccordionComponent <AccordionComponent
trigger={t["data"]["id"]} trigger={t["data"]["id"]}
open={openAccordion} open={openAccordion}
@ -393,8 +375,8 @@ export default function ApiModal({ flow }: { flow: FlowType }) {
</TableCell> </TableCell>
<TableCell className="p-0 text-center text-gray-900 text-xs dark:text-gray-300"> <TableCell className="p-0 text-center text-gray-900 text-xs dark:text-gray-300">
<div className="w-[250px] m-auto"> <div className="w-[250px] m-auto">
{t.data.node.template[n].type === {t.data.node.template[n]
"str" && .type === "str" &&
!t.data.node.template[n] !t.data.node.template[n]
.options ? ( .options ? (
<div className="mx-auto"> <div className="mx-auto">
@ -404,22 +386,24 @@ export default function ApiModal({ flow }: { flow: FlowType }) {
editNode={true} editNode={true}
disabled={false} disabled={false}
value={ value={
!t.data.node.template[n] !t.data.node.template[
.value || n
t.data.node.template[n] ].value ||
.value === "" t.data.node.template[
n
].value === ""
? [""] ? [""]
: t.data.node : t.data.node
.template[n].value .template[n]
.value
} }
onChange={(k) => {}} onChange={(k) => {}}
onAddInput={(k) => { onAddInput={(k) => {
buildTweakObject( buildTweakObject(
t["data"]["id"], t["data"]["id"],
k, k,
t.data.node.template[ t.data.node
n .template[n]
]
); );
}} }}
/> />
@ -428,8 +412,9 @@ export default function ApiModal({ flow }: { flow: FlowType }) {
<ShadTooltip <ShadTooltip
delayDuration={1000} delayDuration={1000}
content={buildContent( content={buildContent(
t.data.node.template[n] t.data.node.template[
.value n
].value
)} )}
> >
<div> <div>
@ -460,22 +445,25 @@ export default function ApiModal({ flow }: { flow: FlowType }) {
editNode={true} editNode={true}
disabled={false} disabled={false}
password={ password={
t.data.node.template[n] t.data.node.template[
.password ?? false n
].password ?? false
} }
value={getValue( value={getValue(
t.data.node.template[n] t.data.node.template[
.value, n
].value,
t.data, t.data,
t.data.node.template[n] t.data.node.template[
n
]
)} )}
onChange={(k) => { onChange={(k) => {
buildTweakObject( buildTweakObject(
t["data"]["id"], t["data"]["id"],
k, k,
t.data.node.template[ t.data.node
n .template[n]
]
); );
}} }}
/> />
@ -498,7 +486,9 @@ export default function ApiModal({ flow }: { flow: FlowType }) {
buildTweakObject( buildTweakObject(
t["data"]["id"], t["data"]["id"],
e, e,
t.data.node.template[n] t.data.node.template[
n
]
); );
}} }}
size="small" size="small"
@ -523,17 +513,22 @@ export default function ApiModal({ flow }: { flow: FlowType }) {
editNode={true} editNode={true}
disabled={false} disabled={false}
value={ value={
t.data.node.template[n] t.data.node.template[
.value ?? "" n
].value ?? ""
} }
onChange={(k: any) => {}} onChange={(
k: any
) => {}}
fileTypes={ fileTypes={
t.data.node.template[n] t.data.node.template[
.fileTypes n
].fileTypes
} }
suffixes={ suffixes={
t.data.node.template[n] t.data.node.template[
.suffixes n
].suffixes
} }
onFileChange={( onFileChange={(
k: any k: any
@ -557,7 +552,9 @@ export default function ApiModal({ flow }: { flow: FlowType }) {
buildTweakObject( buildTweakObject(
t["data"]["id"], t["data"]["id"],
k, k,
t.data.node.template[n] t.data.node.template[
n
]
); );
}} }}
/> />
@ -578,7 +575,9 @@ export default function ApiModal({ flow }: { flow: FlowType }) {
buildTweakObject( buildTweakObject(
t["data"]["id"], t["data"]["id"],
k, k,
t.data.node.template[n] t.data.node.template[
n
]
); );
}} }}
value={getValue( value={getValue(
@ -605,7 +604,9 @@ export default function ApiModal({ flow }: { flow: FlowType }) {
buildTweakObject( buildTweakObject(
t["data"]["id"], t["data"]["id"],
k, k,
t.data.node.template[n] t.data.node.template[
n
]
); );
}} }}
/> />
@ -628,18 +629,20 @@ export default function ApiModal({ flow }: { flow: FlowType }) {
editNode={true} editNode={true}
disabled={false} disabled={false}
value={getValue( value={getValue(
t.data.node.template[n] t.data.node.template[
.value, n
].value,
t.data, t.data,
t.data.node.template[n] t.data.node.template[
n
]
)} )}
onChange={(k) => { onChange={(k) => {
buildTweakObject( buildTweakObject(
t["data"]["id"], t["data"]["id"],
k, k,
t.data.node.template[ t.data.node
n .template[n]
]
); );
}} }}
/> />
@ -663,18 +666,20 @@ export default function ApiModal({ flow }: { flow: FlowType }) {
disabled={false} disabled={false}
editNode={true} editNode={true}
value={getValue( value={getValue(
t.data.node.template[n] t.data.node.template[
.value, n
].value,
t.data, t.data,
t.data.node.template[n] t.data.node.template[
n
]
)} )}
onChange={(k) => { onChange={(k) => {
buildTweakObject( buildTweakObject(
t["data"]["id"], t["data"]["id"],
k, k,
t.data.node.template[ t.data.node
n .template[n]
]
); );
}} }}
/> />
@ -697,13 +702,13 @@ export default function ApiModal({ flow }: { flow: FlowType }) {
</AccordionComponent> </AccordionComponent>
)} )}
{( {tweaksList.current.length === 0 && (
tweaksList.current.length === 0 &&
<> <>
<div className="pt-3">No tweaks are available for this flow.</div> <div className="pt-3">
No tweaks are available for this flow.
</div>
</> </>
)} )}
</div> </div>
))} ))}