1
1
import { 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" ;
3
3
import { useDispatch , useSelector } from "react-redux" ;
4
4
import { useParams } from "react-router" ;
5
5
import { AppSummaryInfo , fetchApplicationInfo } from "redux/reduxActions/applicationActions" ;
6
- import { fetchDataSourceByApp , fetchDataSourceTypes } from "redux/reduxActions/datasourceActions" ;
7
6
import { getUser } from "redux/selectors/usersSelectors" ;
8
- import { useUserViewMode } from "util/hooks" ;
9
7
import "comps/uiCompRegistry" ;
10
- import { showAppSnapshotSelector } from "redux/selectors/appSnapshotSelector" ;
11
8
import { setShowAppSnapshot } from "redux/reduxActions/appSnapshotActions" ;
12
9
import { fetchGroupsAction } from "redux/reduxActions/orgActions" ;
13
10
import { getFetchOrgGroupsFinished } from "redux/selectors/orgSelectors" ;
@@ -20,34 +17,24 @@ import {
20
17
perfMark ,
21
18
} from "util/perfUtils" ;
22
19
import { useMount , useUnmount } from "react-use" ;
23
- import { fetchQueryLibraryDropdown } from "../../redux/reduxActions/queryLibraryActions" ;
24
20
import { clearGlobalSettings , setGlobalSettings } from "comps/utils/globalSettings" ;
25
- import { fetchFolderElements } from "redux/reduxActions/folderActions" ;
26
21
import { registryDataSourcePlugin } from "constants/queryConstants" ;
27
22
import { DatasourceApi } from "api/datasourceApi" ;
28
23
import { useRootCompInstance } from "./useRootCompInstance" ;
29
24
import EditorSkeletonView from "./editorSkeletonView" ;
30
- import { ErrorBoundary , FallbackProps } from 'react-error-boundary' ;
25
+ import { ErrorBoundary } from 'react-error-boundary' ;
31
26
import { ALL_APPLICATIONS_URL } from "@lowcoder-ee/constants/routesURL" ;
32
27
import history from "util/history" ;
33
28
import Flex from "antd/es/flex" ;
34
29
import React from "react" ;
35
30
36
- const AppSnapshot = lazy ( ( ) => {
37
- return import ( "pages/editor/appSnapshot" )
38
- . then ( moduleExports => ( { default : moduleExports . AppSnapshot } ) ) ;
39
- } ) ;
40
-
41
31
const AppEditorInternalView = lazy (
42
32
( ) => import ( "pages/editor/appEditorInternal" )
43
- . then ( moduleExports => ( { default : moduleExports . AppEditorInternalView } ) )
33
+ . then ( moduleExports => ( { default : moduleExports . AppEditorInternalView } ) )
44
34
) ;
45
35
46
36
const AppEditor = React . memo ( ( ) => {
47
- const showAppSnapshot = useSelector ( showAppSnapshotSelector ) ;
48
37
const params = useParams < AppPathParams > ( ) ;
49
- const isUserViewModeCheck = useUserViewMode ( ) ;
50
- const isUserViewMode = params . viewMode ? isUserViewModeCheck : true ;
51
38
const applicationId = params . applicationId || window . location . pathname . split ( "/" ) [ 2 ] ;
52
39
const paramViewMode = params . viewMode || window . location . pathname . split ( "/" ) [ 3 ] ;
53
40
const viewMode = ( paramViewMode === "view" || paramViewMode === "admin" ) ? "published" : paramViewMode === "view_marketplace" ? "view_marketplace" : "editing" ;
@@ -82,25 +69,8 @@ const AppEditor = React.memo(() => {
82
69
appType : AppTypeEnum . Application ,
83
70
} ) ;
84
71
85
- const readOnly = isUserViewMode ;
86
- const compInstance = useRootCompInstance ( appInfo , readOnly , isDataSourcePluginRegistered ) ;
72
+ const compInstance = useRootCompInstance ( appInfo , true , isDataSourcePluginRegistered ) ;
87
73
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
-
104
74
const fetchJSDataSourceByApp = ( ) => {
105
75
DatasourceApi . fetchJsDatasourceByApp ( applicationId ) . then ( ( res ) => {
106
76
res . data . data . forEach ( ( i ) => {
@@ -148,8 +118,8 @@ const AppEditor = React.memo(() => {
148
118
width : '400px' ,
149
119
margin : '0 auto' ,
150
120
} } >
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 >
153
123
</ Flex >
154
124
) , [ ] ) ;
155
125
@@ -161,34 +131,23 @@ const AppEditor = React.memo(() => {
161
131
margin : '0 auto' ,
162
132
} } >
163
133
< 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 >
165
135
</ Flex >
166
136
)
167
137
}
168
138
169
139
return (
170
140
< 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 >
192
151
</ ErrorBoundary >
193
152
) ;
194
153
} ) ;
0 commit comments