1
1
import { AppPathParams , AppTypeEnum } from "constants/applicationConstants" ;
2
- import { Suspense , lazy , useEffect , useRef , useState } from "react" ;
2
+ import { Suspense , lazy , useCallback , useEffect , useMemo , useRef , useState } from "react" ;
3
3
import { useDispatch , useSelector } from "react-redux" ;
4
4
import { useParams } from "react-router" ;
5
5
import { AppSummaryInfo , fetchApplicationInfo } from "redux/reduxActions/applicationActions" ;
@@ -30,6 +30,7 @@ import EditorSkeletonView from "./editorSkeletonView";
30
30
import { ErrorBoundary , FallbackProps } from 'react-error-boundary' ;
31
31
import { ALL_APPLICATIONS_URL } from "@lowcoder-ee/constants/routesURL" ;
32
32
import history from "util/history" ;
33
+ import Flex from "antd/es/flex" ;
33
34
34
35
const AppSnapshot = lazy ( ( ) => {
35
36
return import ( "pages/editor/appSnapshot" )
@@ -56,6 +57,7 @@ export default function AppEditor() {
56
57
const orgId = currentUser . currentOrgId ;
57
58
const firstRendered = useRef ( false ) ;
58
59
const [ isDataSourcePluginRegistered , setIsDataSourcePluginRegistered ] = useState ( false ) ;
60
+ const [ appError , setAppError ] = useState ( '' ) ;
59
61
60
62
setGlobalSettings ( { applicationId, isViewMode : paramViewMode === "view" } ) ;
61
63
@@ -132,15 +134,37 @@ export default function AppEditor() {
132
134
setAppInfo ( info ) ;
133
135
fetchJSDataSourceByApp ( ) ;
134
136
} ,
137
+ onError : ( errorMessage ) => {
138
+ setAppError ( errorMessage ) ;
139
+ }
135
140
} )
136
141
) ;
137
142
} , [ viewMode , applicationId , dispatch ] ) ;
138
- const fallbackUI = (
139
- < div style = { { display :'flex' , height :'100%' , width :'100%' , alignItems :'center' , justifyContent :'center' , gap :'8px' , marginTop :'10px' } } >
140
- < p style = { { margin :0 } } > Something went wrong while displaying this webpage</ p >
141
- < button onClick = { ( ) => history . push ( ALL_APPLICATIONS_URL ) } style = { { background : '#4965f2' , border : '1px solid #4965f2' , color : '#ffffff' , borderRadius :'6px' } } > Go to Apps</ button >
142
- </ div >
143
- ) ;
143
+
144
+ const fallbackUI = useMemo ( ( ) => (
145
+ < Flex align = "center" justify = "center" vertical style = { {
146
+ height : '300px' ,
147
+ width : '400px' ,
148
+ margin : '0 auto' ,
149
+ } } >
150
+ < h4 style = { { margin : 0 } } > Something went wrong while displaying this webpage</ h4 >
151
+ < button onClick = { ( ) => history . push ( ALL_APPLICATIONS_URL ) } style = { { background : '#4965f2' , border : '1px solid #4965f2' , color : '#ffffff' , borderRadius :'6px' } } > Go to Apps</ button >
152
+ </ Flex >
153
+ ) , [ ] ) ;
154
+
155
+ if ( Boolean ( appError ) ) {
156
+ return (
157
+ < Flex align = "center" justify = "center" vertical style = { {
158
+ height : '300px' ,
159
+ width : '400px' ,
160
+ margin : '0 auto' ,
161
+ } } >
162
+ < h4 > { appError } </ h4 >
163
+ < button onClick = { ( ) => history . push ( ALL_APPLICATIONS_URL ) } style = { { background : '#4965f2' , border : '1px solid #4965f2' , color : '#ffffff' , borderRadius :'6px' } } > Back to Home</ button >
164
+ </ Flex >
165
+ )
166
+ }
167
+
144
168
return (
145
169
< ErrorBoundary fallback = { fallbackUI } >
146
170
{ showAppSnapshot ? (
0 commit comments