11import * as React from "react" ;
2- import { useCallback , useState } from "react" ;
2+ import { useCallback , useMemo , useState } from "react" ;
33import { Method } from "../../model-editor/method" ;
44import { ModeledMethod } from "../../model-editor/modeled-method" ;
55import { styled } from "styled-components" ;
66import { MethodModelingInputs } from "./MethodModelingInputs" ;
77import { VSCodeButton } from "@vscode/webview-ui-toolkit/react" ;
88import { Codicon } from "../common" ;
9+ import { validateModeledMethods } from "../../model-editor/shared/validation" ;
10+ import { ModeledMethodAlert } from "./ModeledMethodAlert" ;
911
1012export type MultipleModeledMethodsPanelProps = {
1113 method : Method ;
@@ -19,9 +21,14 @@ const Container = styled.div`
1921 gap: 0.25rem;
2022
2123 padding-bottom: 0.5rem;
24+ border-top: 0.05rem solid var(--vscode-panelSection-border);
2225 border-bottom: 0.05rem solid var(--vscode-panelSection-border);
2326` ;
2427
28+ const AlertContainer = styled . div `
29+ margin-top: 0.5rem;
30+ ` ;
31+
2532const Footer = styled . div `
2633 display: flex;
2734 flex-direction: row;
@@ -47,8 +54,24 @@ export const MultipleModeledMethodsPanel = ({
4754 setSelectedIndex ( ( previousIndex ) => previousIndex + 1 ) ;
4855 } , [ ] ) ;
4956
57+ const validationErrors = useMemo (
58+ ( ) => validateModeledMethods ( modeledMethods ) ,
59+ [ modeledMethods ] ,
60+ ) ;
61+
5062 return (
5163 < Container >
64+ { validationErrors . length > 0 && (
65+ < AlertContainer >
66+ { validationErrors . map ( ( error , index ) => (
67+ < ModeledMethodAlert
68+ key = { index }
69+ error = { error }
70+ setSelectedIndex = { setSelectedIndex }
71+ />
72+ ) ) }
73+ </ AlertContainer >
74+ ) }
5275 { modeledMethods . length > 0 ? (
5376 < MethodModelingInputs
5477 method = { method }
0 commit comments