From 2a723f01a3fdf4d8f1d3cd0e17e39531dbfa1b63 Mon Sep 17 00:00:00 2001 From: wangsijie Date: Fri, 30 Dec 2022 15:43:42 +0800 Subject: [PATCH] fix(console): add json validator to connector config (#2774) --- .../components/CodeEditor/index.module.scss | 6 ++ .../src/components/CodeEditor/index.tsx | 91 ++++++++++--------- .../components/ConnectorForm/index.tsx | 14 ++- packages/console/src/utilities/validator.ts | 10 ++ 4 files changed, 76 insertions(+), 45 deletions(-) diff --git a/packages/console/src/components/CodeEditor/index.module.scss b/packages/console/src/components/CodeEditor/index.module.scss index d4579a524..181cfd2c5 100644 --- a/packages/console/src/components/CodeEditor/index.module.scss +++ b/packages/console/src/components/CodeEditor/index.module.scss @@ -57,3 +57,9 @@ } } } + +.errorMessage { + font: var(--font-body-medium); + color: var(--color-error); + margin-top: _.unit(1); +} diff --git a/packages/console/src/components/CodeEditor/index.tsx b/packages/console/src/components/CodeEditor/index.tsx index 8f40238ca..86e27ef76 100644 --- a/packages/console/src/components/CodeEditor/index.tsx +++ b/packages/console/src/components/CodeEditor/index.tsx @@ -14,6 +14,8 @@ type Props = { value?: string; onChange?: (value: string) => void; tabSize?: number; + hasError?: boolean; + errorMessage?: string; }; const CodeEditor = ({ @@ -23,6 +25,8 @@ const CodeEditor = ({ value = '', onChange, tabSize = 2, + hasError, + errorMessage, }: Props) => { const textareaRef = useRef(null); @@ -49,49 +53,52 @@ const CodeEditor = ({ }; return ( -
- -
- {/* SyntaxHighlighter is a readonly component, so a transparent