11import { AppPathParams , AppTypeEnum } from "constants/applicationConstants" ;
2- import { Suspense , lazy , useCallback , useEffect , useMemo , useRef , useState } from "react" ;
2+ import { Suspense , lazy , useEffect , useMemo , useRef , useState } from "react" ;
33import { useDispatch , useSelector } from "react-redux" ;
44import { useParams } from "react-router" ;
55import { AppSummaryInfo , fetchApplicationInfo } from "redux/reduxActions/applicationActions" ;
6- import { fetchDataSourceByApp , fetchDataSourceTypes } from "redux/reduxActions/datasourceActions" ;
76import { getUser } from "redux/selectors/usersSelectors" ;
8- import { useUserViewMode } from "util/hooks" ;
97import "comps/uiCompRegistry" ;
10- import { showAppSnapshotSelector } from "redux/selectors/appSnapshotSelector" ;
118import { setShowAppSnapshot } from "redux/reduxActions/appSnapshotActions" ;
129import { fetchGroupsAction } from "redux/reduxActions/orgActions" ;
1310import { getFetchOrgGroupsFinished } from "redux/selectors/orgSelectors" ;
@@ -20,34 +17,24 @@ import {
2017 perfMark ,
2118} from "util/perfUtils" ;
2219import { useMount , useUnmount } from "react-use" ;
23- import { fetchQueryLibraryDropdown } from "../../redux/reduxActions/queryLibraryActions" ;
2420import { clearGlobalSettings , setGlobalSettings } from "comps/utils/globalSettings" ;
25- import { fetchFolderElements } from "redux/reduxActions/folderActions" ;
2621import { registryDataSourcePlugin } from "constants/queryConstants" ;
2722import { DatasourceApi } from "api/datasourceApi" ;
2823import { useRootCompInstance } from "./useRootCompInstance" ;
2924import EditorSkeletonView from "./editorSkeletonView" ;
30- import { ErrorBoundary , FallbackProps } from 'react-error-boundary' ;
25+ import { ErrorBoundary } from 'react-error-boundary' ;
3126import { ALL_APPLICATIONS_URL } from "@lowcoder-ee/constants/routesURL" ;
3227import history from "util/history" ;
3328import Flex from "antd/es/flex" ;
3429import React from "react" ;
3530
36- const AppSnapshot = lazy ( ( ) => {
37- return import ( "pages/editor/appSnapshot" )
38- . then ( moduleExports => ( { default : moduleExports . AppSnapshot } ) ) ;
39- } ) ;
40-
4131const AppEditorInternalView = lazy (
4232 ( ) => import ( "pages/editor/appEditorInternal" )
43- . then ( moduleExports => ( { default : moduleExports . AppEditorInternalView } ) )
33+ . then ( moduleExports => ( { default : moduleExports . AppEditorInternalView } ) )
4434) ;
4535
4636const AppEditor = React . memo ( ( ) => {
47- const showAppSnapshot = useSelector ( showAppSnapshotSelector ) ;
4837 const params = useParams < AppPathParams > ( ) ;
49- const isUserViewModeCheck = useUserViewMode ( ) ;
50- const isUserViewMode = params . viewMode ? isUserViewModeCheck : true ;
5138 const applicationId = params . applicationId || window . location . pathname . split ( "/" ) [ 2 ] ;
5239 const paramViewMode = params . viewMode || window . location . pathname . split ( "/" ) [ 3 ] ;
5340 const viewMode = ( paramViewMode === "view" || paramViewMode === "admin" ) ? "published" : paramViewMode === "view_marketplace" ? "view_marketplace" : "editing" ;
@@ -82,25 +69,8 @@ const AppEditor = React.memo(() => {
8269 appType : AppTypeEnum . Application ,
8370 } ) ;
8471
85- const readOnly = isUserViewMode ;
86- const compInstance = useRootCompInstance ( appInfo , readOnly , isDataSourcePluginRegistered ) ;
72+ const compInstance = useRootCompInstance ( appInfo , true , isDataSourcePluginRegistered ) ;
8773
88- // fetch dataSource and plugin
89- useEffect ( ( ) => {
90- if ( ! orgId || paramViewMode !== "edit" ) {
91- return ;
92- }
93- dispatch ( fetchDataSourceTypes ( { organizationId : orgId } ) ) ;
94- dispatch ( fetchFolderElements ( { } ) ) ;
95- } , [ dispatch , orgId , paramViewMode ] ) ;
96-
97- useEffect ( ( ) => {
98- if ( applicationId && paramViewMode === "edit" ) {
99- dispatch ( fetchDataSourceByApp ( { applicationId : applicationId } ) ) ;
100- dispatch ( fetchQueryLibraryDropdown ( ) ) ;
101- }
102- } , [ dispatch , applicationId , paramViewMode ] ) ;
103-
10474 const fetchJSDataSourceByApp = ( ) => {
10575 DatasourceApi . fetchJsDatasourceByApp ( applicationId ) . then ( ( res ) => {
10676 res . data . data . forEach ( ( i ) => {
@@ -148,8 +118,8 @@ const AppEditor = React.memo(() => {
148118 width : '400px' ,
149119 margin : '0 auto' ,
150120 } } >
151- < h4 style = { { margin : 0 } } > Something went wrong while displaying this webpage</ h4 >
152- < button onClick = { ( ) => history . push ( ALL_APPLICATIONS_URL ) } style = { { background : '#4965f2' , border : '1px solid #4965f2' , color : '#ffffff' , borderRadius :'6px' } } > Go to Apps</ button >
121+ < h4 style = { { margin : 0 } } > Something went wrong while displaying this webpage</ h4 >
122+ < button onClick = { ( ) => history . push ( ALL_APPLICATIONS_URL ) } style = { { background : '#4965f2' , border : '1px solid #4965f2' , color : '#ffffff' , borderRadius : '6px' } } > Go to Apps</ button >
153123 </ Flex >
154124 ) , [ ] ) ;
155125
@@ -161,34 +131,23 @@ const AppEditor = React.memo(() => {
161131 margin : '0 auto' ,
162132 } } >
163133 < h4 > { appError } </ h4 >
164- < button onClick = { ( ) => history . push ( ALL_APPLICATIONS_URL ) } style = { { background : '#4965f2' , border : '1px solid #4965f2' , color : '#ffffff' , borderRadius :'6px' } } > Back to Home</ button >
134+ < button onClick = { ( ) => history . push ( ALL_APPLICATIONS_URL ) } style = { { background : '#4965f2' , border : '1px solid #4965f2' , color : '#ffffff' , borderRadius : '6px' } } > Back to Home</ button >
165135 </ Flex >
166136 )
167137 }
168138
169139 return (
170140 < ErrorBoundary fallback = { fallbackUI } >
171- { showAppSnapshot ? (
172- < Suspense fallback = { < EditorSkeletonView /> } >
173- < AppSnapshot
174- currentAppInfo = { {
175- ...appInfo ,
176- dsl : compInstance . comp ?. toJsonValue ( ) || { } ,
177- } }
178- />
179- </ Suspense >
180- ) : (
181- < Suspense fallback = { < EditorSkeletonView /> } >
182- < AppEditorInternalView
183- appInfo = { appInfo }
184- readOnly = { readOnly }
185- loading = {
186- ! fetchOrgGroupsFinished || ! isDataSourcePluginRegistered || isCommonSettingsFetching
187- }
188- compInstance = { compInstance }
189- />
190- </ Suspense >
191- ) }
141+ < Suspense fallback = { < EditorSkeletonView /> } >
142+ < AppEditorInternalView
143+ appInfo = { appInfo }
144+ readOnly = { false }
145+ loading = {
146+ ! fetchOrgGroupsFinished || ! isDataSourcePluginRegistered || isCommonSettingsFetching
147+ }
148+ compInstance = { compInstance }
149+ />
150+ </ Suspense >
192151 </ ErrorBoundary >
193152 ) ;
194153} ) ;
0 commit comments