chore: fix the eslint issues

This commit is contained in:
Björn Otgaar
2026-01-08 11:33:10 +01:00
parent a4428c0d67
commit e6f29a0f6b
4 changed files with 41 additions and 29 deletions

View File

@@ -1,4 +1,4 @@
import { GoalReduce, type GoalNode } from "../nodes/GoalNode" import { GoalReduce } from "../nodes/GoalNode"
import { type Node } from "@xyflow/react" import { type Node } from "@xyflow/react"
export type Plan = { export type Plan = {
@@ -35,6 +35,8 @@ export function PlanReduce(_nodes: Node[], plan?: Plan, ) {
// Extract the wanted information from a plan element. // Extract the wanted information from a plan element.
function StepReduce(planElement: PlanElement, _nodes: Node[]) : Record<string, unknown> { function StepReduce(planElement: PlanElement, _nodes: Node[]) : Record<string, unknown> {
// We have different types of plan elements, requiring differnt types of output // We have different types of plan elements, requiring differnt types of output
const nodes = _nodes
const thisNode = _nodes.find((x) => x.id === planElement.id)
switch (planElement.type) { switch (planElement.type) {
case ("speech"): case ("speech"):
return { return {
@@ -55,8 +57,6 @@ function StepReduce(planElement: PlanElement, _nodes: Node[]) : Record<string, u
goal: planElement.goal, goal: planElement.goal,
} }
case ("goal"): case ("goal"):
const nodes = _nodes
const thisNode = _nodes.find((x) => x.id === planElement.id)
return thisNode ? GoalReduce(thisNode, nodes) : {} return thisNode ? GoalReduce(thisNode, nodes) : {}
} }
} }
@@ -95,27 +95,3 @@ export function GetActionValue(action: Action) {
default: default:
} }
} }
/**
* Inserts a goal into a plan
* @param plan: plan to insert goal into
* @param goalNode: the goal node to insert into the plan.
* @returns: a new plan with the goal inside.
*/
export function insertGoalInPlan(plan: Plan, goalNode: GoalNode): Plan {
const planElement : Goal = {
id: goalNode.id,
type: "goal",
}
return {
...plan,
steps: [...plan.steps, planElement],
}
}
export function deleteGoalInPlanByID(plan: Plan, goalID: string): Plan {
return {...plan,
steps: plan.steps.filter((x) => x.id !== goalID)
}
}

View File

@@ -0,0 +1,34 @@
// This file is to avoid sharing both functions and components which eslint dislikes. :)
import type { GoalNode } from "../nodes/GoalNode"
import type { Goal, Plan } from "./Plan"
/**
* Inserts a goal into a plan
* @param plan: plan to insert goal into
* @param goalNode: the goal node to insert into the plan.
* @returns: a new plan with the goal inside.
*/
export function insertGoalInPlan(plan: Plan, goalNode: GoalNode): Plan {
const planElement : Goal = {
id: goalNode.id,
type: "goal",
}
return {
...plan,
steps: [...plan.steps, planElement],
}
}
/**
* Deletes a goal from a plan
* @param plan: plan to delete goal from
* @param goalID: the goal node to delete.
* @returns: a new plan with the goal removed.
*/
export function deleteGoalInPlanByID(plan: Plan, goalID: string): Plan {
return {...plan,
steps: plan.steps.filter((x) => x.id !== goalID)
}
}

View File

@@ -9,10 +9,11 @@ import { TextField } from '../../../../components/TextField';
import {MultiConnectionHandle} from "../components/RuleBasedHandle.tsx"; import {MultiConnectionHandle} from "../components/RuleBasedHandle.tsx";
import {allowOnlyConnectionsFromHandle, allowOnlyConnectionsFromType} from "../HandleRules.ts"; import {allowOnlyConnectionsFromHandle, allowOnlyConnectionsFromType} from "../HandleRules.ts";
import useFlowStore from '../VisProgStores'; import useFlowStore from '../VisProgStores';
import { deleteGoalInPlanByID, DoesPlanIterate, insertGoalInPlan, PlanReduce, type Plan, type PlanElement } from '../components/Plan'; import {DoesPlanIterate, PlanReduce, type Plan } from '../components/Plan';
import PlanEditorDialog from '../components/PlanEditor'; import PlanEditorDialog from '../components/PlanEditor';
import { MultilineTextField } from '../../../../components/MultilineTextField'; import { MultilineTextField } from '../../../../components/MultilineTextField';
import { defaultPlan } from '../components/Plan.default.ts'; import { defaultPlan } from '../components/Plan.default.ts';
import { deleteGoalInPlanByID, insertGoalInPlan } from '../components/PlanEditingFunctions.tsx';
/** /**
* The default data dot a phase node * The default data dot a phase node

View File

@@ -10,11 +10,12 @@ import styles from '../../VisProg.module.css';
import {MultiConnectionHandle, SingleConnectionHandle} from "../components/RuleBasedHandle.tsx"; import {MultiConnectionHandle, SingleConnectionHandle} from "../components/RuleBasedHandle.tsx";
import {allowOnlyConnectionsFromHandle, allowOnlyConnectionsFromType} from "../HandleRules.ts"; import {allowOnlyConnectionsFromHandle, allowOnlyConnectionsFromType} from "../HandleRules.ts";
import useFlowStore from '../VisProgStores'; import useFlowStore from '../VisProgStores';
import { deleteGoalInPlanByID, insertGoalInPlan, PlanReduce, type Plan } from '../components/Plan'; import {PlanReduce, type Plan } from '../components/Plan';
import PlanEditorDialog from '../components/PlanEditor'; import PlanEditorDialog from '../components/PlanEditor';
import { BasicBeliefReduce } from './BasicBeliefNode'; import { BasicBeliefReduce } from './BasicBeliefNode';
import type { GoalNode } from './GoalNode.tsx'; import type { GoalNode } from './GoalNode.tsx';
import { defaultPlan } from '../components/Plan.default.ts'; import { defaultPlan } from '../components/Plan.default.ts';
import { deleteGoalInPlanByID, insertGoalInPlan } from '../components/PlanEditingFunctions.tsx';
/** /**
* The default data structure for a Trigger node * The default data structure for a Trigger node