Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b0821a6

Browse files
committed
remove unsed code
1 parent 9c709ba commit b0821a6

File tree

4 files changed

+31
-105
lines changed

4 files changed

+31
-105
lines changed

viewer/packages/lowcoder/src/app.tsx

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,26 @@
11
import { default as App } from "antd/es/app";
22
import { default as ConfigProvider } from "antd/es/config-provider";
33
import {
4-
ALL_APPLICATIONS_URL,
54
APP_EDITOR_URL,
6-
APPLICATION_VIEW_URL,
7-
BASE_URL,
8-
DATASOURCE_CREATE_URL,
9-
DATASOURCE_EDIT_URL,
10-
DATASOURCE_URL,
11-
QUERY_LIBRARY_URL,
12-
ADMIN_APP_URL,
135
} from "constants/routesURL";
146
import React from "react";
157
import { createRoot } from "react-dom/client";
168
import { Helmet } from "react-helmet";
179
import { connect, Provider } from "react-redux";
18-
import { Redirect, Router, Switch } from "react-router-dom";
10+
import { Router, Switch } from "react-router-dom";
1911
import type { AppState } from "redux/reducers";
20-
import { fetchConfigAction } from "redux/reduxActions/configActions";
2112
import { fetchUserAction } from "redux/reduxActions/userActions";
2213
import { reduxStore } from "redux/store/store";
23-
import { developEnv } from "util/envUtils";
2414
import history from "util/history";
2515
import LazyRoute from "components/LazyRoute";
2616
import { getAntdLocale } from "i18n/antdLocale";
2717
import { trans } from "i18n"; // language
2818
import { loadComps } from "comps";
2919
import { initApp } from "util/commonUtils";
30-
import { favicon } from "assets/images";
31-
import { hasQueryParam } from "util/urlUtils";
32-
import { isFetchUserFinished } from "redux/selectors/usersSelectors"; // getCurrentUser,
33-
import { getIsCommonSettingFetched } from "redux/selectors/commonSettingSelectors";
3420
import GlobalInstances from 'components/GlobalInstances';
3521
// import posthog from 'posthog-js'
36-
import { fetchHomeData } from "./redux/reduxActions/applicationActions";
3722

38-
const LazyInviteLanding = React.lazy(() => import("pages/common/inviteLanding"));
39-
const LazyComponentDoc = React.lazy(() => import("pages/ComponentDoc"));
40-
const LazyComponentPlayground = React.lazy(() => import("pages/ComponentPlayground"));
4123
const LazyAppEditor = React.lazy(() => import("pages/editor/AppEditor"));
42-
const LazyDebugComp = React.lazy(() => import("./debug"));
43-
const LazyDebugNewComp = React.lazy(() => import("./debugNew"));
4424

4525
const Wrapper = (props: { children: React.ReactNode, language: string }) => (
4626
<ConfigProvider
@@ -74,9 +54,6 @@ class AppIndex extends React.Component<AppIndexProps, any> {
7454
componentDidUpdate(prevProps: AppIndexProps) {
7555
}
7656
render() {
77-
const isTemplate = hasQueryParam('template');
78-
const pathname = history.location.pathname;
79-
8057
// we check if we are on the public cloud
8158
const isLowCoderDomain = window.location.hostname === 'app.lowcoder.cloud';
8259
const isLocalhost = window.location.hostname === 'localhost';
@@ -248,25 +225,6 @@ class AppIndex extends React.Component<AppIndexProps, any> {
248225
path={APP_EDITOR_URL}
249226
component={LazyAppEditor}
250227
/>
251-
<LazyRoute
252-
path={`/playground/:name/:dsl`}
253-
component={LazyComponentPlayground}
254-
/>
255-
{developEnv() && (
256-
<>
257-
<LazyRoute
258-
path="/debug_comp/:name"
259-
component={LazyDebugComp}
260-
/>
261-
<LazyRoute
262-
exact
263-
path="/debug_comp"
264-
component={LazyDebugComp}
265-
/>
266-
<LazyRoute path="/debug_editor" component={LazyAppEditor} />
267-
<LazyRoute path="/debug_new" component={LazyDebugNewComp} />
268-
</>
269-
)}
270228
</Switch>
271229
</Router>
272230
</Wrapper>

viewer/packages/lowcoder/src/comps/comps/rootComp.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { ThemeContext } from "comps/utils/themeContext";
1919
import { ModuleLayoutCompName } from "constants/compConstants";
2020
import { defaultTheme as localDefaultTheme } from "constants/themeConstants";
2121
import { ModuleLoading } from "components/ModuleLoading";
22-
import EditorSkeletonView from "pages/editor/editorSkeletonView";
2322
import { getGlobalSettings } from "comps/utils/globalSettings";
2423
import { getCurrentTheme } from "comps/utils/themeUtil";
2524
import { DataChangeResponderListComp } from "./dataChangeResponderComp";
@@ -34,6 +33,7 @@ import { ExternalEditorContext } from "util/context/ExternalEditorContext";
3433
import { useUserViewMode } from "util/hooks";
3534
import React from "react";
3635
import { isEqual } from "lodash";
36+
import EditorSkeletonView from "@lowcoder-ee/pages/editor/editorSkeletonView";
3737

3838
const EditorView = lazy(
3939
() => import("pages/editor/editorView"),
@@ -73,10 +73,10 @@ const RootView = React.memo((props: RootViewProps) => {
7373
previewTheme?.previewTheme ||
7474
selectedTheme?.theme ||
7575
localDefaultTheme;
76-
76+
7777
const themeId = selectedTheme ? selectedTheme.id : (
7878
previewTheme ? "preview-theme" : 'default-theme-id'
79-
);
79+
);
8080

8181
useEffect(() => {
8282
const newEditorState = new EditorState(comp, (changeEditorStateFn) => {
@@ -123,14 +123,22 @@ const RootView = React.memo((props: RootViewProps) => {
123123
return <ModuleLoading />;
124124
}
125125

126+
127+
128+
129+
130+
131+
132+
133+
126134
const SuspenseFallback = isModuleRoot ? <ModuleLoading /> : <EditorSkeletonView />;
127135

128136
if (!editorState) {
129137
return SuspenseFallback;
130138
}
131139

132140
return (
133-
<div {...divProps} style={{height: '100%'}}>
141+
<div {...divProps} style={{ height: '100%' }}>
134142
<PropertySectionContext.Provider value={propertySectionContextValue}>
135143
<ThemeContext.Provider value={themeContextValue}>
136144
<EditorContext.Provider value={editorState}>

viewer/packages/lowcoder/src/pages/editor/AppEditor.tsx

Lines changed: 17 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
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";
33
import { useDispatch, useSelector } from "react-redux";
44
import { useParams } from "react-router";
55
import { AppSummaryInfo, fetchApplicationInfo } from "redux/reduxActions/applicationActions";
6-
import { fetchDataSourceByApp, fetchDataSourceTypes } from "redux/reduxActions/datasourceActions";
76
import { getUser } from "redux/selectors/usersSelectors";
8-
import { useUserViewMode } from "util/hooks";
97
import "comps/uiCompRegistry";
10-
import { showAppSnapshotSelector } from "redux/selectors/appSnapshotSelector";
118
import { setShowAppSnapshot } from "redux/reduxActions/appSnapshotActions";
129
import { fetchGroupsAction } from "redux/reduxActions/orgActions";
1310
import { getFetchOrgGroupsFinished } from "redux/selectors/orgSelectors";
@@ -20,34 +17,24 @@ import {
2017
perfMark,
2118
} from "util/perfUtils";
2219
import { useMount, useUnmount } from "react-use";
23-
import { fetchQueryLibraryDropdown } from "../../redux/reduxActions/queryLibraryActions";
2420
import { clearGlobalSettings, setGlobalSettings } from "comps/utils/globalSettings";
25-
import { fetchFolderElements } from "redux/reduxActions/folderActions";
2621
import { registryDataSourcePlugin } from "constants/queryConstants";
2722
import { DatasourceApi } from "api/datasourceApi";
2823
import { useRootCompInstance } from "./useRootCompInstance";
2924
import EditorSkeletonView from "./editorSkeletonView";
30-
import {ErrorBoundary, FallbackProps} from 'react-error-boundary';
25+
import { ErrorBoundary } from 'react-error-boundary';
3126
import { ALL_APPLICATIONS_URL } from "@lowcoder-ee/constants/routesURL";
3227
import history from "util/history";
3328
import Flex from "antd/es/flex";
3429
import React from "react";
3530

36-
const AppSnapshot = lazy(() => {
37-
return import("pages/editor/appSnapshot")
38-
.then(moduleExports => ({default: moduleExports.AppSnapshot}));
39-
});
40-
4131
const AppEditorInternalView = lazy(
4232
() => import("pages/editor/appEditorInternal")
43-
.then(moduleExports => ({default: moduleExports.AppEditorInternalView}))
33+
.then(moduleExports => ({ default: moduleExports.AppEditorInternalView }))
4434
);
4535

4636
const 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
});

viewer/packages/lowcoder/src/pages/editor/appEditorInternal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ interface AppEditorInternalViewProps {
1515

1616
export const AppEditorInternalView = React.memo((props: AppEditorInternalViewProps) => {
1717
const { compInstance } = props;
18+
console.log("+++++++++++++++++++++++++++++++++++++++", props)
1819

1920
useEffect(() => {
2021
message.config({ top: 0 });

0 commit comments

Comments
 (0)