9
9
formMessageTypes ,
10
10
pluginUiMessageTypes ,
11
11
} from '@cloudquery/plugin-config-ui-connector' ;
12
- import Button from '@mui/material/Button' ;
13
12
import Stack from '@mui/material/Stack' ;
14
13
import Typography from '@mui/material/Typography' ;
15
14
@@ -61,50 +60,8 @@ export function CloudAppMock({
61
60
} : CloudAppMockProps ) {
62
61
const [ testConnectionValues , setTestConnectionValues ] = useState < Record < string , any > > ( ) ;
63
62
const [ submitValues , setSubmitValues ] = useState < Record < string , any > > ( ) ;
64
- const [ errors , setErrors ] = useState < string > ( '' ) ;
65
63
const searchParams = useMemo ( ( ) => new URLSearchParams ( window . location . search ) , [ ] ) ;
66
64
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
-
108
65
useEffect ( ( ) => {
109
66
formMessageHandler . sendMessage ( 'init' , {
110
67
initialValues : initialValues
@@ -244,18 +201,6 @@ export function CloudAppMock({
244
201
>
245
202
{ children }
246
203
</ 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 >
259
204
< Stack
260
205
sx = { {
261
206
padding : 2 ,
@@ -273,8 +218,6 @@ export function CloudAppMock({
273
218
< pre style = { { wordBreak : 'break-all' , whiteSpace : 'break-spaces' } } >
274
219
{ JSON . stringify ( submitValues , null , 2 ) || '-' }
275
220
</ pre >
276
- < div > Errors:</ div >
277
- < pre style = { { wordBreak : 'break-all' , whiteSpace : 'break-spaces' } } > { errors || '-' } </ pre >
278
221
</ Stack >
279
222
</ >
280
223
) ;
0 commit comments