feat: added warning for missing plan in goal
ref: N25B-450
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
import {
|
import {
|
||||||
type NodeProps,
|
type NodeProps,
|
||||||
Position,
|
Position,
|
||||||
type Node,
|
type Node
|
||||||
} from '@xyflow/react';
|
} from '@xyflow/react';
|
||||||
|
import {useEffect} from "react";
|
||||||
|
import type {EditorWarning} from "../components/EditorWarnings.tsx";
|
||||||
import { Toolbar } from '../components/NodeComponents';
|
import { Toolbar } from '../components/NodeComponents';
|
||||||
import styles from '../../VisProg.module.css';
|
import styles from '../../VisProg.module.css';
|
||||||
import { TextField } from '../../../../components/TextField';
|
import { TextField } from '../../../../components/TextField';
|
||||||
@@ -44,7 +46,7 @@ export type GoalNode = Node<GoalNodeData>
|
|||||||
* @returns React.JSX.Element
|
* @returns React.JSX.Element
|
||||||
*/
|
*/
|
||||||
export default function GoalNode({id, data}: NodeProps<GoalNode>) {
|
export default function GoalNode({id, data}: NodeProps<GoalNode>) {
|
||||||
const {updateNodeData} = useFlowStore();
|
const {updateNodeData, registerWarning, unregisterWarning} = useFlowStore();
|
||||||
const _nodes = useFlowStore().nodes;
|
const _nodes = useFlowStore().nodes;
|
||||||
|
|
||||||
const text_input_id = `goal_${id}_text_input`;
|
const text_input_id = `goal_${id}_text_input`;
|
||||||
@@ -64,6 +66,24 @@ export default function GoalNode({id, data}: NodeProps<GoalNode>) {
|
|||||||
updateNodeData(id, {...data, can_fail: value});
|
updateNodeData(id, {...data, can_fail: value});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const noPlanWarning : EditorWarning = {
|
||||||
|
scope: {
|
||||||
|
id: id,
|
||||||
|
handleId: undefined
|
||||||
|
},
|
||||||
|
type: 'PLAN_IS_UNDEFINED',
|
||||||
|
severity: 'ERROR',
|
||||||
|
description: "This triggerNode is missing a plan, please make sure to create a plan by using the create plan button"
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!data.plan){
|
||||||
|
registerWarning(noPlanWarning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
unregisterWarning(id, noPlanWarning.type);
|
||||||
|
},[data.plan, id, registerWarning, unregisterWarning])
|
||||||
return <>
|
return <>
|
||||||
<Toolbar nodeId={id} allowDelete={true}/>
|
<Toolbar nodeId={id} allowDelete={true}/>
|
||||||
<div className={`${styles.defaultNode} ${styles.nodeGoal} flex-col gap-sm`}>
|
<div className={`${styles.defaultNode} ${styles.nodeGoal} flex-col gap-sm`}>
|
||||||
|
|||||||
Reference in New Issue
Block a user