Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EE setup #1358

Open
wants to merge 16 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Enterprise Edition API Calls cleanup
  • Loading branch information
FalkWolsky committed Dec 7, 2024
commit 9947227da335ea328f5c94ac9edf1e1fe90d35ab
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { SET_ENTERPRISE_LICENSE } from '../../reduxActions/enterpriseActions';
import { ReduxAction, ReduxActionTypes } from "constants/reduxActionConstants";


Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
export const FETCH_ENTERPRISE_LICENSE = 'FETCH_ENTERPRISE_LICENSE';
export const SET_ENTERPRISE_LICENSE = 'SET_ENTERPRISE_LICENSE';
import { ReduxActionTypes } from "constants/reduxActionConstants";

export const fetchEnterpriseLicense = () => ({ type: FETCH_ENTERPRISE_LICENSE });
export const fetchEnterpriseLicense = () => ({
type: ReduxActionTypes.FETCH_ENTERPRISE_LICENSE,
});

export const setEnterpriseLicense = (licenseData: any) => ({
type: SET_ENTERPRISE_LICENSE,
type: ReduxActionTypes.SET_ENTERPRISE_LICENSE,
payload: licenseData,
});
});
7 changes: 4 additions & 3 deletions client/packages/lowcoder/src/redux/sagas/enterpriseSagas.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { call, put, takeLatest } from 'redux-saga/effects';
import { FETCH_ENTERPRISE_LICENSE, setEnterpriseLicense } from 'redux/reduxActions/enterpriseActions';
import { getEnterpriseLicense } from 'api/enterpriseApi';
import { ReduxActionTypes } from "constants/reduxActionConstants";
import { setEnterpriseLicense } from "redux/reduxActions/enterpriseActions";
import { getEnterpriseLicense } from "api/enterpriseApi";

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

export default function* enterpriseSagas() {
yield takeLatest(FETCH_ENTERPRISE_LICENSE, fetchEnterpriseLicenseSaga);
yield takeLatest(ReduxActionTypes.FETCH_ENTERPRISE_LICENSE, fetchEnterpriseLicenseSaga);
}
2 changes: 2 additions & 0 deletions client/packages/lowcoder/src/redux/sagas/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { pluginSagas } from "redux/sagas/pluginSagas";
import { datasourceSagas } from "redux/sagas/datasourceSagas";
import userSagas from "redux/sagas/userSagas";
import subscriptionSagas from "redux/sagas/subscriptionSagas";
import enterpriseSagas from "redux/sagas/enterpriseSagas";
import applicationSagas from "redux/sagas/applicationSagas";
import configSagas from "redux/sagas/configSagas";
import appSnapshotSagas from "redux/sagas/appSnapshotSagas";
Expand All @@ -28,6 +29,7 @@ export const sagas = [
commonSettingsSagas,
jsLibrarySagas,
subscriptionSagas,
enterpriseSagas,
];

export function* rootSaga(sagasToRun = sagas) {
Expand Down
34 changes: 18 additions & 16 deletions client/packages/lowcoder/src/util/context/EnterpriseContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,39 @@ interface EnterpriseContextValue {

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

type Props = { children?: React.ReactNode };
type ProviderProps = {
children: React.ReactNode;
}

export const EnterpriseProvider: React.FC<Props> = ({ children }) => {
export const EnterpriseProvider: React.FC<ProviderProps> = ({ children }) => {
const dispatch = useDispatch();
const isEnterpriseActiveRedux = useSelector(selectEnterpriseEditionStatus); // From Redux store
const [isEnterpriseActive, setIsEnterpriseActive] = useState(false);

useEffect(() => {
if (isEEEnvironment()) {
if (isEEEnvironment()) {
// Fetch the enterprise license only if we're in an EE environment
dispatch(fetchEnterpriseLicense());
} else {
} else {
// Set the state to false for non-EE environments
setEEActiveState(false);
setIsEnterpriseActive(false);
}
}
}, [dispatch]);

useEffect(() => {
if (isEEEnvironment()) {
if (isEEEnvironment()) {
// Update the global EE state based on Redux
setEEActiveState(isEnterpriseActiveRedux);
setIsEnterpriseActive(isEnterpriseActiveRedux);
}
}
}, [isEnterpriseActiveRedux]);

return (
<EnterpriseContext.Provider value={{ isEnterpriseActive }}>
{children}
</EnterpriseContext.Provider>
<EnterpriseContext.Provider value={{ isEnterpriseActive }}>
{children}
</EnterpriseContext.Provider>
);
};

export const useEnterpriseContext = () => useContext(EnterpriseContext);
};
export const useEnterpriseContext = () => useContext(EnterpriseContext);
Loading