Skip to content

Commit f9e311b

Browse files
fetch branding inside EnterpriseContext
1 parent dbdd13f commit f9e311b

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

client/packages/lowcoder/src/app.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ import GlobalInstances from 'components/GlobalInstances';
6060
import { fetchHomeData, fetchServerSettingsAction } from "./redux/reduxActions/applicationActions";
6161
import { getNpmPackageMeta } from "./comps/utils/remote";
6262
import { packageMetaReadyAction, setLowcoderCompsLoading } from "./redux/reduxActions/npmPluginActions";
63-
import { fetchBrandingSetting } from "./redux/reduxActions/enterpriseActions";
6463
import { EnterpriseProvider } from "./util/context/EnterpriseContext";
6564
import { SimpleSubscriptionContextProvider } from "./util/context/SimpleSubscriptionContext";
6665
import { getBrandingSetting } from "./redux/selectors/enterpriseSelectors";
@@ -137,7 +136,6 @@ type AppIndexProps = {
137136
defaultHomePage: string | null | undefined;
138137
fetchHomeDataFinished: boolean;
139138
fetchConfig: (orgId?: string) => void;
140-
fetchBrandingSetting: (orgId?: string) => void;
141139
fetchHomeData: (currentUserAnonymous?: boolean | undefined) => void;
142140
fetchLowcoderCompVersions: () => void;
143141
getCurrentUser: () => void;
@@ -167,7 +165,6 @@ class AppIndex extends React.Component<AppIndexProps, any> {
167165
if (!this.props.currentUserAnonymous) {
168166
this.props.fetchHomeData(this.props.currentUserAnonymous);
169167
this.props.fetchLowcoderCompVersions();
170-
this.props.fetchBrandingSetting(this.props.currentOrgId);
171168
}
172169
}
173170
}
@@ -521,7 +518,6 @@ const mapDispatchToProps = (dispatch: any) => ({
521518
fetchHomeData: (currentUserAnonymous: boolean | undefined) => {
522519
dispatch(fetchHomeData({}));
523520
},
524-
fetchBrandingSetting: (orgId?: string) => dispatch(fetchBrandingSetting({ orgId, fallbackToGlobal: true })),
525521
fetchLowcoderCompVersions: async () => {
526522
try {
527523
dispatch(setLowcoderCompsLoading(true));

client/packages/lowcoder/src/util/context/EnterpriseContext.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import React, { createContext, useContext, useState, useEffect } from 'react';
2-
import { fetchEnterpriseLicense, fetchEnvironments } from 'redux/reduxActions/enterpriseActions';
2+
import { fetchBrandingSetting, fetchEnterpriseLicense, fetchEnvironments } from 'redux/reduxActions/enterpriseActions';
33
import { selectEnterpriseEditionStatus } from '@lowcoder-ee/redux/selectors/enterpriseSelectors';
44
import { useDispatch, useSelector } from 'react-redux';
55
import { isEEEnvironment } from "util/envUtils";
6+
import { getUser } from '@lowcoder-ee/redux/selectors/usersSelectors';
67

78
interface EnterpriseContextValue {
89
isEnterpriseActive: boolean;
@@ -18,18 +19,20 @@ export const EnterpriseProvider: React.FC<ProviderProps> = ({ children }) => {
1819
const dispatch = useDispatch();
1920
const isEnterpriseActiveRedux = useSelector(selectEnterpriseEditionStatus); // From Redux store
2021
const [isEnterpriseActive, setIsEnterpriseActive] = useState(false);
22+
const user = useSelector(getUser);
2123

2224
useEffect(() => {
2325
if (isEEEnvironment()) {
2426
// Fetch the enterprise license only if we're in an EE environment
2527
dispatch(fetchEnterpriseLicense());
2628
dispatch(fetchEnvironments());
29+
dispatch(fetchBrandingSetting({ orgId: user.currentOrgId, fallbackToGlobal: true }))
2730
} else {
2831
// Set the state to false for non-EE environments
2932
// setEEActiveState(false);
3033
setIsEnterpriseActive(false);
3134
}
32-
}, [dispatch]);
35+
}, [dispatch, user.currentOrgId]);
3336

3437
useEffect(() => {
3538
if (isEEEnvironment()) {

0 commit comments

Comments
 (0)