File tree Expand file tree Collapse file tree 8 files changed +56
-6
lines changed
json-table-schema-visualizer/src/components/Messages Expand file tree Collapse file tree 8 files changed +56
-6
lines changed Original file line number Diff line number Diff line change 2727 "outFiles" : [
2828 " ${workspaceFolder}/packages/dbml-vs-code-extension/dist/extension/*.js"
2929 ],
30- "preLaunchTask" : " yarn : build"
30+ "preLaunchTask" : " npm : build"
3131 },
3232 {
3333 "name" : " Preview Prisma Extension" ,
3939 "outFiles" : [
4040 " ${workspaceFolder}/packages/prisma-vs-code-extension/dist/extension/*.js"
4141 ],
42- "preLaunchTask" : " yarn : build:prisma"
42+ "preLaunchTask" : " npm : build:prisma"
4343 }
4444 ]
4545}
Original file line number Diff line number Diff line change 4545 "cwd" : " ${workspaceFolder}/packages/dbml-vs-code-extension"
4646 }
4747 },
48-
49- // prisma
5048 {
5149 "type" : " npm" ,
5250 "script" : " build:prisma" ,
5856 "options" : {
5957 "cwd" : " ${workspaceFolder}/packages/prisma-vs-code-extension"
6058 }
59+ },
60+ {
61+ "type" : " npm" ,
62+ "script" : " build" ,
63+ "path" : " packages/dbml-vs-code-extension" ,
64+ "group" : " build" ,
65+ "problemMatcher" : [],
66+ "label" : " npm: build - packages/dbml-vs-code-extension" ,
67+ "detail" : " npx vite build && yarn run generate:css"
6168 }
6269 ]
6370}
Original file line number Diff line number Diff line change @@ -12,5 +12,6 @@ export interface WebviewPostMessage {
1212export interface SetSchemaCommandPayload {
1313 type : string ;
1414 payload : JSONTableSchema ;
15+ message ?: string ;
1516 key : string ;
1617}
Original file line number Diff line number Diff line change @@ -176,7 +176,15 @@ export class MainPanel {
176176 MainPanel . diagnosticCollection . clear ( ) ;
177177 } catch ( error ) {
178178 console . error ( JSON . stringify ( error ) ) ;
179+
179180 if ( error instanceof DiagnosticError ) {
181+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
182+ this . currentPanel ?. _panel . webview . postMessage ( {
183+ type : "setSchemaErrorMessage" ,
184+ message : `${ error . message } \n Line : ${ error . location . start . line } :${ error . location . start . column } ` ,
185+ key : document . uri . toString ( ) ,
186+ } ) ;
187+
180188 MainPanel . diagnosticCollection . set ( document . uri , [
181189 new Diagnostic (
182190 new Range (
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import DiagramViewer from "json-table-schema-visualizer/src/components/DiagramVi
22import { useCreateTheme } from "json-table-schema-visualizer/src/hooks/theme" ;
33import ThemeProvider from "json-table-schema-visualizer/src/providers/ThemeProvider" ;
44import NoSchemaMessage from "json-table-schema-visualizer/src/components/Messages/NoSchemaMessage" ;
5+ import ErrorMessage from "json-table-schema-visualizer/src/components/Messages/ErrorMessage" ;
56import { type Theme } from "json-table-schema-visualizer/src/types/theme" ;
67import ScrollDirectionProvider from "json-table-schema-visualizer/src/providers/ScrollDirectionProvider" ;
78
@@ -16,7 +17,11 @@ const App = () => {
1617 const { setTheme, theme, themeColors } = useCreateTheme (
1718 window . EXTENSION_DEFAULT_CONFIG ?. theme ,
1819 ) ;
19- const { schema, key } = useSchema ( ) ;
20+ const { schema, key, schemaErrorMessage } = useSchema ( ) ;
21+
22+ if ( schemaErrorMessage !== null && schema === null ) {
23+ return < ErrorMessage message = { schemaErrorMessage } /> ;
24+ }
2025
2126 if ( schema === null ) {
2227 return < NoSchemaMessage /> ;
Original file line number Diff line number Diff line change @@ -9,12 +9,26 @@ import { type SetSchemaCommandPayload } from "../../extension/types/webviewComma
99export const useSchema = ( ) : {
1010 schema : JSONTableSchema | null ;
1111 key : string | null ;
12+ schemaErrorMessage : string | null ;
1213} => {
14+ const [ schemaErrorMessage , setSchemaErrorMessage ] = useState < string | null > (
15+ null ,
16+ ) ;
1317 const [ schema , setSchema ] = useState < JSONTableSchema | null > ( null ) ;
1418 const [ schemaKey , setSchemaKey ] = useState < string | null > ( null ) ;
1519
1620 const updater = ( e : MessageEvent ) : void => {
1721 const message = e . data as SetSchemaCommandPayload ;
22+
23+ if (
24+ message . type === "setSchemaErrorMessage" &&
25+ typeof message . message === "string"
26+ ) {
27+ setSchemaErrorMessage ( message . message ) ;
28+
29+ return ;
30+ }
31+
1832 if (
1933 ! ( message . type === "setSchema" && typeof message . payload === "object" )
2034 ) {
@@ -35,6 +49,7 @@ export const useSchema = (): {
3549 }
3650
3751 setSchema ( message . payload ) ;
52+ setSchemaErrorMessage ( null ) ;
3853 } ;
3954
4055 useEffect ( ( ) => {
@@ -47,5 +62,5 @@ export const useSchema = (): {
4762 } ;
4863 } , [ ] ) ;
4964
50- return { schema, key : schemaKey } ;
65+ return { schema, key : schemaKey , schemaErrorMessage } ;
5166} ;
Original file line number Diff line number Diff line change 1+ import MessageWrapper from "./MessageWrapper" ;
2+
3+ interface ErrorMessageProps {
4+ message : string ;
5+ }
6+ const ErrorMessage = ( { message } : ErrorMessageProps ) => {
7+ return (
8+ < MessageWrapper >
9+ < p > { message } </ p >
10+ </ MessageWrapper >
11+ ) ;
12+ } ;
13+
14+ export default ErrorMessage ;
You can’t perform that action at this time.
0 commit comments