From 55fa4f3a8b49bee742c8c23f556321df5a92d7cb Mon Sep 17 00:00:00 2001 From: Pim Hutting Date: Fri, 30 Jan 2026 12:42:24 +0100 Subject: [PATCH 1/2] chore: removed critical norm from UI --- .../visualProgrammingUI/nodes/NormNode.tsx | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/pages/VisProgPage/visualProgrammingUI/nodes/NormNode.tsx b/src/pages/VisProgPage/visualProgrammingUI/nodes/NormNode.tsx index 1b4d200..86f05b8 100644 --- a/src/pages/VisProgPage/visualProgrammingUI/nodes/NormNode.tsx +++ b/src/pages/VisProgPage/visualProgrammingUI/nodes/NormNode.tsx @@ -1,6 +1,8 @@ // This program has been developed by students from the bachelor Computer Science at Utrecht // University within the Software Project course. // © Copyright Utrecht University (Department of Information and Computing Sciences) +import { useEffect } from "react"; +import type { EditorWarning } from "../components/EditorWarnings.tsx"; import { type NodeProps, Position, @@ -39,7 +41,7 @@ export type NormNode = Node */ export default function NormNode(props: NodeProps) { const data = props.data; - const {updateNodeData} = useFlowStore(); + const {updateNodeData, registerWarning, unregisterWarning} = useFlowStore(); const text_input_id = `norm_${props.id}_text_input`; const checkbox_id = `goal_${props.id}_checkbox`; @@ -51,6 +53,22 @@ export default function NormNode(props: NodeProps) { const setCritical = (value: boolean) => { updateNodeData(props.id, {...data, critical: value}); } + useEffect(() => { + const normText = data.norm || ""; + + const startsWithNumberWarning: EditorWarning = { + scope: { id: props.id }, + type: 'ELEMENT_STARTS_WITH_NUMBER', + severity: 'ERROR', + description: "Norms are not allowed to start with a number." + }; + + if (/^\d/.test(normText)) { + registerWarning(startsWithNumberWarning); + } else { + unregisterWarning(props.id, 'ELEMENT_STARTS_WITH_NUMBER'); + } + }, [data.norm, props.id, registerWarning, unregisterWarning]); return <> @@ -64,7 +82,10 @@ export default function NormNode(props: NodeProps) { placeholder={"Pepper should ..."} /> -
+ {/*There is no backend implementation yet of how critical norms would + be treated differently than normal norms. The commented code below shows + how you could add the UI side, if you wish to implement */} + {/*
) { checked={data.critical || false} onChange={(e) => setCritical(e.target.checked)} /> -
+
*/} {data.condition && (
-- 2.49.1 From 72993b75768456f469d4d4b3c07956a6473e3f82 Mon Sep 17 00:00:00 2001 From: Pim Hutting Date: Fri, 30 Jan 2026 12:54:26 +0100 Subject: [PATCH 2/2] chore: removed critical norm from UI --- .../VisProgPage/visualProgrammingUI/nodes/NormNode.tsx | 10 ++++++---- .../visualProgrammingUI/nodes/NormNode.test.tsx | 5 +---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/pages/VisProgPage/visualProgrammingUI/nodes/NormNode.tsx b/src/pages/VisProgPage/visualProgrammingUI/nodes/NormNode.tsx index 86f05b8..5832401 100644 --- a/src/pages/VisProgPage/visualProgrammingUI/nodes/NormNode.tsx +++ b/src/pages/VisProgPage/visualProgrammingUI/nodes/NormNode.tsx @@ -49,10 +49,12 @@ export default function NormNode(props: NodeProps) { const setValue = (value: string) => { updateNodeData(props.id, {norm: value}); } - - const setCritical = (value: boolean) => { - updateNodeData(props.id, {...data, critical: value}); - } + //this function is commented out, because of lack of backend implementation. + //If you wish to set critical norms, in the UI side, you can uncomment and use this function. + + // const setCritical = (value: boolean) => { + // updateNodeData(props.id, {...data, critical: value}); + // } useEffect(() => { const normText = data.norm || ""; diff --git a/test/pages/visProgPage/visualProgrammingUI/nodes/NormNode.test.tsx b/test/pages/visProgPage/visualProgrammingUI/nodes/NormNode.test.tsx index 935ea55..bba51a6 100644 --- a/test/pages/visProgPage/visualProgrammingUI/nodes/NormNode.test.tsx +++ b/test/pages/visProgPage/visualProgrammingUI/nodes/NormNode.test.tsx @@ -699,15 +699,12 @@ describe('NormNode', () => { /> ); - const checkbox = screen.getByLabelText('Critical:'); - await user.click(checkbox); - await waitFor(() => { const state = useFlowStore.getState(); expect(state.nodes).toHaveLength(1); expect(state.nodes[0].id).toBe('norm-1'); expect(state.nodes[0].data.norm).toBe(''); - expect(state.nodes[0].data.critical).toBe(true); + }); }); -- 2.49.1