Skip to content

Commit b85f013

Browse files
handle routes based on orgDev
1 parent 56396f4 commit b85f013

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

client/packages/lowcoder/src/app.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import { getBrandingConfig } from "./redux/selectors/configSelectors";
5555
import { buildMaterialPreviewURL } from "./util/materialUtils";
5656
import GlobalInstances from 'components/GlobalInstances';
5757
import posthog from 'posthog-js'
58+
import { fetchHomeData } from "./redux/reduxActions/applicationActions";
5859

5960
const LazyUserAuthComp = React.lazy(() => import("pages/userAuth"));
6061
const LazyInviteLanding = React.lazy(() => import("pages/common/inviteLanding"));
@@ -82,9 +83,12 @@ type AppIndexProps = {
8283
isFetchUserFinished: boolean;
8384
getIsCommonSettingFetched: boolean;
8485
currentOrgId?: string;
86+
currentUserId: string;
8587
orgDev: boolean;
8688
defaultHomePage: string | null | undefined;
89+
fetchHomeDataFinished: boolean;
8790
fetchConfig: (orgId?: string) => void;
91+
fetchHomeData: () => void;
8892
getCurrentUser: () => void;
8993
favicon: string;
9094
brandName: string;
@@ -94,6 +98,7 @@ type AppIndexProps = {
9498
class AppIndex extends React.Component<AppIndexProps, any> {
9599
componentDidMount() {
96100
this.props.getCurrentUser();
101+
this.props.fetchHomeData();
97102
}
98103

99104
componentDidUpdate(prevProps: AppIndexProps) {
@@ -102,6 +107,7 @@ class AppIndex extends React.Component<AppIndexProps, any> {
102107
this.props.currentOrgId !== ''
103108
) {
104109
this.props.fetchConfig(this.props.currentOrgId);
110+
this.props.fetchHomeData();
105111
}
106112
}
107113
render() {
@@ -117,16 +123,14 @@ class AppIndex extends React.Component<AppIndexProps, any> {
117123
}
118124

119125
// make sure all users in this app have checked login info
120-
if (!this.props.isFetchUserFinished) {
126+
if (!this.props.isFetchUserFinished || (this.props.currentUserId && !this.props.fetchHomeDataFinished)) {
121127
const hideLoadingHeader = isTemplate || isAuthUnRequired(pathname);
122128
return <ProductLoading hideHeader={hideLoadingHeader} />;
123129
}
124130

125131
// persisting the language in local storage
126132
localStorage.setItem('lowcoder_uiLanguage', this.props.uiLanguage);
127133

128-
console.log('Props: ', this.props);
129-
130134
return (
131135
<Wrapper language={this.props.uiLanguage}>
132136
<Helmet>
@@ -276,8 +280,8 @@ class AppIndex extends React.Component<AppIndexProps, any> {
276280
<SystemWarning />
277281
<Router history={history}>
278282
<Switch>
279-
{this.props.isFetchUserFinished && !this.props.orgDev ? (
280-
this.props.getIsCommonSettingFetched && this.props.defaultHomePage !== undefined ? (
283+
{this.props.isFetchUserFinished && this.props.defaultHomePage? (
284+
!this.props.orgDev ? (
281285
<Redirect exact from={BASE_URL} to={APPLICATION_VIEW_URL(this.props.defaultHomePage || "", "view")}/>
282286
) : (
283287
<Redirect exact from={BASE_URL} to={ORG_HOME_URL} />
@@ -374,8 +378,10 @@ const mapStateToProps = (state: AppState) => ({
374378
isFetchUserFinished: isFetchUserFinished(state),
375379
getIsCommonSettingFetched: getIsCommonSettingFetched(state),
376380
orgDev: state.ui.users.user.orgDev,
381+
currentUserId: state.ui.users.currentUser.id,
377382
currentOrgId: state.ui.users.user.currentOrgId,
378383
defaultHomePage: state.ui.application.homeOrg?.commonSettings.defaultHomePage,
384+
fetchHomeDataFinished: Boolean(state.ui.application.homeOrg?.commonSettings),
379385
favicon: getBrandingConfig(state)?.favicon
380386
? buildMaterialPreviewURL(getBrandingConfig(state)?.favicon!)
381387
: favicon,
@@ -388,6 +394,7 @@ const mapDispatchToProps = (dispatch: any) => ({
388394
dispatch(fetchUserAction());
389395
},
390396
fetchConfig: (orgId?: string) => dispatch(fetchConfigAction(orgId)),
397+
fetchHomeData: () => dispatch(fetchHomeData({}))
391398
});
392399

393400
const AppIndexWithProps = connect(mapStateToProps, mapDispatchToProps)(AppIndex);

client/packages/lowcoder/src/pages/ApplicationV2/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,9 @@ export default function ApplicationHome() {
267267

268268
const isOrgAdmin = org?.createdBy == user.id ? true : false;
269269

270-
useEffect(() => {
271-
dispatch(fetchHomeData({}));
272-
}, [user.currentOrgId]);
270+
// useEffect(() => {
271+
// dispatch(fetchHomeData({}));
272+
// }, [user.currentOrgId]);
273273

274274
useEffect(() => {
275275
if (!org) {

0 commit comments

Comments
 (0)