Skip to content

Commit 9947227

Browse files
author
FalkWolsky
committed
Enterprise Edition API Calls cleanup
1 parent 80f9ff6 commit 9947227

File tree

5 files changed

+30
-25
lines changed

5 files changed

+30
-25
lines changed

client/packages/lowcoder/src/redux/reducers/uiReducers/enterpriseReducer.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { SET_ENTERPRISE_LICENSE } from '../../reduxActions/enterpriseActions';
21
import { ReduxAction, ReduxActionTypes } from "constants/reduxActionConstants";
32

43

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
export const FETCH_ENTERPRISE_LICENSE = 'FETCH_ENTERPRISE_LICENSE';
2-
export const SET_ENTERPRISE_LICENSE = 'SET_ENTERPRISE_LICENSE';
1+
import { ReduxActionTypes } from "constants/reduxActionConstants";
32

4-
export const fetchEnterpriseLicense = () => ({ type: FETCH_ENTERPRISE_LICENSE });
3+
export const fetchEnterpriseLicense = () => ({
4+
type: ReduxActionTypes.FETCH_ENTERPRISE_LICENSE,
5+
});
56

67
export const setEnterpriseLicense = (licenseData: any) => ({
7-
type: SET_ENTERPRISE_LICENSE,
8+
type: ReduxActionTypes.SET_ENTERPRISE_LICENSE,
89
payload: licenseData,
9-
});
10+
});

client/packages/lowcoder/src/redux/sagas/enterpriseSagas.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { call, put, takeLatest } from 'redux-saga/effects';
2-
import { FETCH_ENTERPRISE_LICENSE, setEnterpriseLicense } from 'redux/reduxActions/enterpriseActions';
3-
import { getEnterpriseLicense } from 'api/enterpriseApi';
2+
import { ReduxActionTypes } from "constants/reduxActionConstants";
3+
import { setEnterpriseLicense } from "redux/reduxActions/enterpriseActions";
4+
import { getEnterpriseLicense } from "api/enterpriseApi";
45

56
// Define the type of data returned by the API
67
interface EnterpriseLicenseResponse {
@@ -24,5 +25,5 @@ function* fetchEnterpriseLicenseSaga(): Generator<any, void, EnterpriseLicenseRe
2425
}
2526

2627
export default function* enterpriseSagas() {
27-
yield takeLatest(FETCH_ENTERPRISE_LICENSE, fetchEnterpriseLicenseSaga);
28+
yield takeLatest(ReduxActionTypes.FETCH_ENTERPRISE_LICENSE, fetchEnterpriseLicenseSaga);
2829
}

client/packages/lowcoder/src/redux/sagas/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { pluginSagas } from "redux/sagas/pluginSagas";
33
import { datasourceSagas } from "redux/sagas/datasourceSagas";
44
import userSagas from "redux/sagas/userSagas";
55
import subscriptionSagas from "redux/sagas/subscriptionSagas";
6+
import enterpriseSagas from "redux/sagas/enterpriseSagas";
67
import applicationSagas from "redux/sagas/applicationSagas";
78
import configSagas from "redux/sagas/configSagas";
89
import appSnapshotSagas from "redux/sagas/appSnapshotSagas";
@@ -28,6 +29,7 @@ export const sagas = [
2829
commonSettingsSagas,
2930
jsLibrarySagas,
3031
subscriptionSagas,
32+
enterpriseSagas,
3133
];
3234

3335
export function* rootSaga(sagasToRun = sagas) {

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

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,37 +10,39 @@ interface EnterpriseContextValue {
1010

1111
const EnterpriseContext = createContext<EnterpriseContextValue>({ isEnterpriseActive: false });
1212

13-
type Props = { children?: React.ReactNode };
13+
type ProviderProps = {
14+
children: React.ReactNode;
15+
}
1416

15-
export const EnterpriseProvider: React.FC<Props> = ({ children }) => {
17+
export const EnterpriseProvider: React.FC<ProviderProps> = ({ children }) => {
1618
const dispatch = useDispatch();
1719
const isEnterpriseActiveRedux = useSelector(selectEnterpriseEditionStatus); // From Redux store
1820
const [isEnterpriseActive, setIsEnterpriseActive] = useState(false);
19-
21+
2022
useEffect(() => {
21-
if (isEEEnvironment()) {
23+
if (isEEEnvironment()) {
2224
// Fetch the enterprise license only if we're in an EE environment
2325
dispatch(fetchEnterpriseLicense());
24-
} else {
26+
} else {
2527
// Set the state to false for non-EE environments
2628
setEEActiveState(false);
2729
setIsEnterpriseActive(false);
28-
}
30+
}
2931
}, [dispatch]);
30-
32+
3133
useEffect(() => {
32-
if (isEEEnvironment()) {
34+
if (isEEEnvironment()) {
3335
// Update the global EE state based on Redux
3436
setEEActiveState(isEnterpriseActiveRedux);
3537
setIsEnterpriseActive(isEnterpriseActiveRedux);
36-
}
38+
}
3739
}, [isEnterpriseActiveRedux]);
38-
40+
3941
return (
40-
<EnterpriseContext.Provider value={{ isEnterpriseActive }}>
41-
{children}
42-
</EnterpriseContext.Provider>
42+
<EnterpriseContext.Provider value={{ isEnterpriseActive }}>
43+
{children}
44+
</EnterpriseContext.Provider>
4345
);
44-
};
45-
46-
export const useEnterpriseContext = () => useContext(EnterpriseContext);
46+
};
47+
48+
export const useEnterpriseContext = () => useContext(EnterpriseContext);

0 commit comments

Comments
 (0)