From 0af77d086a05d584df5dcd02bcb817f8a6911ddd Mon Sep 17 00:00:00 2001 From: Robert Date: Thu, 19 Oct 2023 12:52:45 +0100 Subject: [PATCH] Display validation errors in model editor --- .../src/view/model-editor/MethodRow.tsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/extensions/ql-vscode/src/view/model-editor/MethodRow.tsx b/extensions/ql-vscode/src/view/model-editor/MethodRow.tsx index a304920cc..13c50fdcd 100644 --- a/extensions/ql-vscode/src/view/model-editor/MethodRow.tsx +++ b/extensions/ql-vscode/src/view/model-editor/MethodRow.tsx @@ -31,6 +31,8 @@ import { ModelEditorViewState } from "../../model-editor/shared/view-state"; import { Codicon } from "../common"; import { canAddNewModeledMethod } from "../../model-editor/shared/multiple-modeled-methods"; import { DataGridCell, DataGridRow } from "../common/DataGrid"; +import { validateModeledMethods } from "../../model-editor/shared/validation"; +import { ModeledMethodAlert } from "../method-modeling/ModeledMethodAlert"; const ApiOrMethodRow = styled.div` min-height: calc(var(--input-height) * 1px); @@ -111,6 +113,11 @@ const ModelableMethodRow = forwardRef( [modeledMethodsProp, method, viewState], ); + const validationErrors = useMemo( + () => validateModeledMethods(modeledMethods), + [modeledMethods], + ); + const modeledMethodChangedHandlers = useMemo( () => modeledMethods.map((_, index) => (modeledMethod: ModeledMethod) => { @@ -163,7 +170,9 @@ const ModelableMethodRow = forwardRef( ref={ref} focused={revealedMethodSignature === method.signature} > - + @@ -256,6 +265,11 @@ const ModelableMethodRow = forwardRef( )} ))} + {validationErrors.map((error, index) => ( + + + + ))} )}