Validation based on base class done
This commit is contained in:
parent
173781ce4c
commit
761cac606a
4 changed files with 47 additions and 30 deletions
|
|
@ -23,7 +23,7 @@ export default function ChatInputNode({ data }) {
|
|||
<Handle
|
||||
type="target"
|
||||
position={Position.Right}
|
||||
id='str'
|
||||
id={'str|str|'+data.id}
|
||||
isValidConnection={(connection) => isValidConnection(data,connection)}
|
||||
className="-mr-1 bg-transparent border-solid border-l-8 border-l-blue-600 border-y-transparent border-y-8 border-r-0 rounded-none"
|
||||
></Handle>
|
||||
|
|
|
|||
|
|
@ -38,37 +38,50 @@ export default function GenericNode({ data }) {
|
|||
<div className="w-full text-gray-500 px-5 text-sm">
|
||||
{data.node.description}
|
||||
</div>
|
||||
<div className="px-5 py-2 mt-2 text-center">Inputs:</div>
|
||||
|
||||
<>
|
||||
{Object.keys(data.node.template).map((t, idx) => (
|
||||
<ParameterComponent
|
||||
key={idx}
|
||||
data={data}
|
||||
color={
|
||||
nodeColors[
|
||||
data.types[data.node.template[t].type] ??
|
||||
data.node.template[t].type
|
||||
] ?? "gray"
|
||||
}
|
||||
title={snakeToNormalCase(t)}
|
||||
tooltipTitle={
|
||||
t +
|
||||
": " +
|
||||
data.node.template[t].type +
|
||||
(data.node.template[t].list ? " list" : "") +
|
||||
(data.node.template[t].required ? " (required)" : "")
|
||||
}
|
||||
id={data.node.template[t].type + "|" + t + "|" + data.id}
|
||||
left={true}
|
||||
/>
|
||||
))}
|
||||
{Object.keys(data.node.template)
|
||||
.filter((t) => t.charAt(0) !== "_")
|
||||
.map((t, idx) => (
|
||||
<>
|
||||
{idx === 0 ? (
|
||||
<div className="px-5 py-2 mt-2 text-center">Inputs:</div>
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
{data.node.template[t].show ? (
|
||||
<ParameterComponent
|
||||
key={idx}
|
||||
data={data}
|
||||
color={
|
||||
nodeColors[data.types[data.node.template[t].type]] ??
|
||||
"black"
|
||||
}
|
||||
title={
|
||||
snakeToNormalCase(t) +
|
||||
(data.node.template[t].required ? " (required)" : "")
|
||||
}
|
||||
tooltipTitle={
|
||||
"Type: " +
|
||||
data.node.template[t].type +
|
||||
(data.node.template[t].list ? " list" : "") +
|
||||
(data.node.template[t].required ? " (required)" : "")
|
||||
}
|
||||
id={data.node.template[t].type + "|" + t + "|" + data.id}
|
||||
left={true}
|
||||
/>
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
</>
|
||||
))}
|
||||
<div className="px-5 py-2 mt-2 text-center">Output:</div>
|
||||
<ParameterComponent
|
||||
data={data}
|
||||
color={nodeColors[data.type]}
|
||||
title={data.name}
|
||||
tooltipTitle={"Output: " + data.name}
|
||||
id={data.name}
|
||||
title={data.name + " | " + data.node.base_class}
|
||||
tooltipTitle={"Type: str"}
|
||||
id={data.name + "|" + data.node.base_class + "|" + data.id}
|
||||
left={false}
|
||||
/>
|
||||
</>
|
||||
|
|
|
|||
|
|
@ -10,13 +10,16 @@ export default function ExtraSidebar() {
|
|||
const types = Object.keys(data).reduce((acc, curr) => {
|
||||
Object.keys(data[curr]).forEach((c) => {
|
||||
acc[c] = curr;
|
||||
acc[data[curr][c].base_class] = curr;
|
||||
});
|
||||
console.log(acc);
|
||||
return acc;
|
||||
}, {str: 'elements', bool: 'elements'});
|
||||
|
||||
useEffect(() => {
|
||||
getAll().then((d) => {
|
||||
setData(d.data);
|
||||
console.log(d.data);
|
||||
});
|
||||
}, []);
|
||||
|
||||
|
|
|
|||
|
|
@ -305,6 +305,7 @@ export function toFirstUpperCase(str: string) {
|
|||
}
|
||||
|
||||
export function snakeToNormalCase(str: string) {
|
||||
console.log(str);
|
||||
return str
|
||||
.split("_")
|
||||
.map((word, index) => {
|
||||
|
|
@ -334,9 +335,9 @@ export function isValidConnection(
|
|||
{ source, target, sourceHandle, targetHandle }
|
||||
) {
|
||||
if (
|
||||
targetHandle === sourceHandle.split("|")[0] ||
|
||||
sourceHandle.split("|")[0] === "str" ||
|
||||
data.types[targetHandle] === sourceHandle.split("|")[0]
|
||||
targetHandle.split('|')[0] === sourceHandle.split("|")[0] ||
|
||||
targetHandle.split('|')[1] === sourceHandle.split("|")[0] ||
|
||||
sourceHandle.split("|")[0] === "str"
|
||||
) {
|
||||
let sourceNode = data.reactFlowInstance.getNode(source).data.node;
|
||||
if (!sourceNode) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue