chore: fix eslints and spelling

This commit is contained in:
Björn Otgaar
2025-11-18 18:49:11 +01:00
parent bb4e9d0b26
commit bd7620a182
2 changed files with 9 additions and 46 deletions

View File

@@ -6,7 +6,7 @@ import {
} from '@xyflow/react';
import { Toolbar } from '../components/NodeComponents';
import styles from '../../VisProg.module.css';
import { NodeDefaults, NodeReduces, NodesInPhase, NodeTypes } from '../NodeRegistry';
import { NodeReduces, NodesInPhase, NodeTypes } from '../NodeRegistry';
import useFlowStore from '../VisProgStores';
import { TextField } from '../../../../components/TextField';
@@ -62,6 +62,7 @@ export default function PhaseNode(props: NodeProps<Node>) {
);
};
/**
* Reduces each phase, including its children down into its relevant data.
* @param props: The Node Properties of this node.
@@ -69,66 +70,28 @@ export default function PhaseNode(props: NodeProps<Node>) {
export function PhaseReduce(node: Node, nodes: Node[]) {
const thisnode = node as PhaseNode;
const data = thisnode.data as PhaseNodeData;
const reducableChildren = Object.entries(NodeDefaults)
.filter(([, data]) => data.hasReduce)
.map(([type]) => (
type
));
let childrenData: unknown = ""
if (data.children != undefined) {
childrenData = data.children.map((childId) => {
// Reduce each of this phases' children.
const child = nodes.find((node) => node.id == childId);
// Make sure that we reduce only valid children nodes.
if (child == undefined || child.type == undefined || !reducableChildren.includes(child.type)) return ''
const reducer = NodeReduces[child.type as keyof typeof NodeReduces]
if (!reducer) {
console.warn(`No reducer found for node type ${child.type}`);
return null;
}
return reducer(child, nodes);
})}
return {
id: thisnode.id,
name: data.label as string,
children: childrenData,
}
}
/**
* Reduces each phase, including its children down into its relevant data.
* @param props: The Node Properties of this node.
*/
export function PhaseReduce2(node: Node, nodes: Node[]) {
const thisnode = node as PhaseNode;
const data = thisnode.data as PhaseNodeData;
// node typings that are not in phase
let nodesNotInPhase: string[] = Object.entries(NodesInPhase)
const nodesNotInPhase: string[] = Object.entries(NodesInPhase)
.filter(([, f]) => !f())
.map(([t]) => t);
// node typings that then are in phase
let nodesInPhase: string[] = Object.entries(NodeTypes)
const nodesInPhase: string[] = Object.entries(NodeTypes)
.filter(([t]) => !nodesNotInPhase.includes(t))
.map(([t]) => t);
// children nodes
let childrenNodes = nodes.filter((node) => data.children.includes(node.id));
const childrenNodes = nodes.filter((node) => data.children.includes(node.id));
// Build the result object
let result: Record<string, unknown> = {
const result: Record<string, unknown> = {
id: thisnode.id,
label: data.label,
};
nodesInPhase.forEach((type) => {
let typedChildren = childrenNodes.filter((child) => child.type == type);
const typedChildren = childrenNodes.filter((child) => child.type == type);
const reducer = NodeReduces[type as keyof typeof NodeReduces];
if (!reducer) {
console.warn(`No reducer found for node type ${type}`);