11import { 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" ;
33import { useDispatch , useSelector } from "react-redux" ;
44import { useParams } from "react-router" ;
55import { AppSummaryInfo , fetchApplicationInfo } from "redux/reduxActions/applicationActions" ;
@@ -30,6 +30,7 @@ import EditorSkeletonView from "./editorSkeletonView";
3030import { ErrorBoundary , FallbackProps } from 'react-error-boundary' ;
3131import { ALL_APPLICATIONS_URL } from "@lowcoder-ee/constants/routesURL" ;
3232import history from "util/history" ;
33+ import Flex from "antd/es/flex" ;
3334
3435const AppSnapshot = lazy ( ( ) => {
3536 return import ( "pages/editor/appSnapshot" )
@@ -56,6 +57,7 @@ export default function AppEditor() {
5657 const orgId = currentUser . currentOrgId ;
5758 const firstRendered = useRef ( false ) ;
5859 const [ isDataSourcePluginRegistered , setIsDataSourcePluginRegistered ] = useState ( false ) ;
60+ const [ appError , setAppError ] = useState ( '' ) ;
5961
6062 setGlobalSettings ( { applicationId, isViewMode : paramViewMode === "view" } ) ;
6163
@@ -132,15 +134,37 @@ export default function AppEditor() {
132134 setAppInfo ( info ) ;
133135 fetchJSDataSourceByApp ( ) ;
134136 } ,
137+ onError : ( errorMessage ) => {
138+ setAppError ( errorMessage ) ;
139+ }
135140 } )
136141 ) ;
137142 } , [ 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+
144168 return (
145169 < ErrorBoundary fallback = { fallbackUI } >
146170 { showAppSnapshot ? (
0 commit comments