99 formMessageTypes ,
1010 pluginUiMessageTypes ,
1111} from '@cloudquery/plugin-config-ui-connector' ;
12- import Button from '@mui/material/Button' ;
1312import Stack from '@mui/material/Stack' ;
1413import Typography from '@mui/material/Typography' ;
1514
@@ -61,50 +60,8 @@ export function CloudAppMock({
6160} : CloudAppMockProps ) {
6261 const [ testConnectionValues , setTestConnectionValues ] = useState < Record < string , any > > ( ) ;
6362 const [ submitValues , setSubmitValues ] = useState < Record < string , any > > ( ) ;
64- const [ errors , setErrors ] = useState < string > ( '' ) ;
6563 const searchParams = useMemo ( ( ) => new URLSearchParams ( window . location . search ) , [ ] ) ;
6664
67- const handleSubmit = async ( ) => {
68- formMessageHandler . sendMessage ( 'validate' ) ;
69- let unsubscribeValidationPassed : ( ( ) => void ) | undefined ;
70- let unsubscribeValidationFailed : ( ( ) => void ) | undefined ;
71-
72- formMessageHandler . sendMessage ( 'is_busy' , {
73- status : true ,
74- } ) ;
75-
76- try {
77- const values = await new Promise ( ( resolve , reject ) => {
78- unsubscribeValidationPassed = formMessageHandler . subscribeToMessageOnce (
79- 'validation_passed' ,
80- ( { values } ) => {
81- resolve ( values ) ;
82- } ,
83- ) ;
84- unsubscribeValidationFailed = formMessageHandler . subscribeToMessageOnce (
85- 'validation_failed' ,
86- ( { errors } ) => reject ( errors ) ,
87- ) ;
88- } ) . finally ( ( ) => {
89- unsubscribeValidationPassed ?.( ) ;
90- unsubscribeValidationFailed ?.( ) ;
91- } ) ;
92-
93- setErrors ( '' ) ;
94- setSubmitValues ( values as Record < string , any > ) ;
95- } catch ( error ) {
96- unsubscribeValidationPassed ?.( ) ;
97- unsubscribeValidationFailed ?.( ) ;
98-
99- setSubmitValues ( undefined ) ;
100- setErrors ( JSON . stringify ( error , null , 2 ) ) ;
101- }
102-
103- formMessageHandler . sendMessage ( 'is_busy' , {
104- status : false ,
105- } ) ;
106- } ;
107-
10865 useEffect ( ( ) => {
10966 formMessageHandler . sendMessage ( 'init' , {
11067 initialValues : initialValues
@@ -244,18 +201,6 @@ export function CloudAppMock({
244201 >
245202 { children }
246203 </ Stack >
247- < Stack
248- direction = "row"
249- spacing = { 2 }
250- sx = { {
251- justifyContent : 'flex-end' ,
252- padding : 2 ,
253- } }
254- >
255- < Button onClick = { handleSubmit } variant = "contained" >
256- Submit
257- </ Button >
258- </ Stack >
259204 < Stack
260205 sx = { {
261206 padding : 2 ,
@@ -273,8 +218,6 @@ export function CloudAppMock({
273218 < pre style = { { wordBreak : 'break-all' , whiteSpace : 'break-spaces' } } >
274219 { JSON . stringify ( submitValues , null , 2 ) || '-' }
275220 </ pre >
276- < div > Errors:</ div >
277- < pre style = { { wordBreak : 'break-all' , whiteSpace : 'break-spaces' } } > { errors || '-' } </ pre >
278221 </ Stack >
279222 </ >
280223 ) ;
0 commit comments