Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1656f73

Browse files
committed
add environments in redux
1 parente21ce96 commit1656f73

File tree

6 files changed

+73
-4
lines changed

6 files changed

+73
-4
lines changed

‎client/packages/lowcoder/src/constants/reduxActionConstants.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ export const ReduxActionTypes = {
172172
/* Enterprise Edition */
173173
FETCH_ENTERPRISE_LICENSE :"FETCH_ENTERPRISE_LICENSE",
174174
SET_ENTERPRISE_LICENSE :"SET_ENTERPRISE_LICENSE",
175+
176+
/* Environments */
177+
FETCH_ENVIRONMENTS :"FETCH_ENVIRONMENTS",
178+
FETCH_ENVIRONMENTS_SUCCESS:"FETCH_ENVIRONMENTS_SUCCESS",
179+
FETCH_ENVIRONMENTS_FAILURE:"FETCH_ENVIRONMENTS_FAILURE",
175180

176181
/* Branding Setting */
177182
FETCH_BRANDING_SETTING :"FETCH_BRANDING_SETTING",

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

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
import{BrandingConfig,BrandingSettingResponse,EnterpriseLicenseResponse}from"@lowcoder-ee/api/enterpriseApi";
22
import{createReducer}from"@lowcoder-ee/util/reducerUtils";
33
import{ReduxAction,ReduxActionTypes}from"constants/reduxActionConstants";
4-
4+
import{Environment}from"pages/setting/environments/types/environment.types";
55
exportinterfaceEnterpriseReduxState{
66
enterprise:EnterpriseLicenseResponse,
77
globalBranding?:BrandingConfig,
88
workspaceBranding?:BrandingConfig,
9+
environments:Environment[],
10+
environmentsLoading:boolean,
11+
environmentsError:string|null,
912
}
1013

1114
constinitialState:EnterpriseReduxState={
1215
enterprise:{
1316
eeActive:false,
1417
remainingAPICalls:0,
1518
eeLicenses:[],
16-
}
19+
},
20+
environments:[],
21+
environmentsLoading:false,
22+
environmentsError:null,
1723
};
1824

1925
constenterpriseReducer=createReducer(initialState,{
@@ -38,6 +44,29 @@ const enterpriseReducer = createReducer(initialState, {
3844
...state,
3945
workspaceBranding:action.payload,
4046
}),
47+
48+
[ReduxActionTypes.FETCH_ENVIRONMENTS]:(
49+
state:EnterpriseReduxState
50+
)=>({
51+
...state,
52+
environmentsLoading:true,
53+
}),
54+
[ReduxActionTypes.FETCH_ENVIRONMENTS_SUCCESS]:(
55+
state:EnterpriseReduxState,
56+
action:ReduxAction<Environment[]>
57+
)=>({
58+
...state,
59+
environments:action.payload,
60+
environmentsLoading:false,
61+
}),
62+
[ReduxActionTypes.FETCH_ENVIRONMENTS_FAILURE]:(
63+
state:EnterpriseReduxState,
64+
action:ReduxAction<string>
65+
)=>({
66+
...state,
67+
environmentsLoading:false,
68+
environmentsError:action.payload,
69+
}),
4170
});
4271

4372
exportdefaultenterpriseReducer;

‎client/packages/lowcoder/src/redux/reduxActions/enterpriseActions.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import{EnterpriseLicenseResponse,FetchBrandingSettingPayload}from"@lowcoder-ee/api/enterpriseApi";
22
import{ReduxActionTypes}from"constants/reduxActionConstants";
3+
import{Environment}from"pages/setting/environments/types/environment.types";
34

45
exportconstfetchEnterpriseLicense=()=>({
56
type:ReduxActionTypes.FETCH_ENTERPRISE_LICENSE,
@@ -16,3 +17,18 @@ export const fetchBrandingSetting = (payload: FetchBrandingSettingPayload) => {
1617
payload,
1718
};
1819
};
20+
21+
exportconstfetchEnvironments=()=>({
22+
type:ReduxActionTypes.FETCH_ENVIRONMENTS,
23+
});
24+
25+
exportconstfetchEnvironmentsSuccess=(environments:Environment[])=>({
26+
type:ReduxActionTypes.FETCH_ENVIRONMENTS_SUCCESS,
27+
payload:environments,
28+
});
29+
30+
exportconstfetchEnvironmentsFailure=(error:string)=>({
31+
type:ReduxActionTypes.FETCH_ENVIRONMENTS_FAILURE,
32+
payload:error,
33+
});
34+

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import{call,put,takeLatest}from'redux-saga/effects';
22
import{ReduxAction,ReduxActionTypes}from"constants/reduxActionConstants";
3-
import{setEnterpriseLicense}from"redux/reduxActions/enterpriseActions";
3+
import{setEnterpriseLicense,fetchEnvironmentsSuccess,fetchEnvironmentsFailure}from"redux/reduxActions/enterpriseActions";
44
import{BrandingSettingResponse,EnterpriseLicenseResponse,FetchBrandingSettingPayload,getBranding,getEnterpriseLicense}from"api/enterpriseApi";
5+
import{getEnvironments}from"pages/setting/environments/services/environments.service";
6+
import{Environment}from"pages/setting/environments/types/environment.types";
7+
58
import{AxiosResponse}from'axios';
69

710
function*fetchEnterpriseLicenseSaga():Generator<any,void,EnterpriseLicenseResponse>{
@@ -14,6 +17,16 @@ function* fetchEnterpriseLicenseSaga(): Generator<any, void, EnterpriseLicenseRe
1417
}
1518
}
1619

20+
function*fetchEnvironmentsSaga():Generator<any,void,Environment[]>{
21+
try{
22+
constenvironments:Environment[]=yieldcall(getEnvironments);
23+
yieldput(fetchEnvironmentsSuccess(environments));
24+
}catch(error){
25+
console.error('Failed to fetch environments:',error);
26+
yieldput(fetchEnvironmentsFailure(errorasstring));
27+
}
28+
}
29+
1730
function*fetchBrandingSettingSaga(action:ReduxAction<FetchBrandingSettingPayload>){
1831
try{
1932
constresponse:BrandingSettingResponse=yieldgetBranding(action.payload.orgId);
@@ -45,4 +58,5 @@ function* fetchBrandingSettingSaga(action: ReduxAction<FetchBrandingSettingPaylo
4558
exportdefaultfunction*enterpriseSagas(){
4659
yieldtakeLatest(ReduxActionTypes.FETCH_ENTERPRISE_LICENSE,fetchEnterpriseLicenseSaga);
4760
yieldtakeLatest(ReduxActionTypes.FETCH_BRANDING_SETTING,fetchBrandingSettingSaga);
61+
yieldtakeLatest(ReduxActionTypes.FETCH_ENVIRONMENTS,fetchEnvironmentsSaga);
4862
}

‎client/packages/lowcoder/src/redux/selectors/enterpriseSelectors.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import{AppState}from"../reducers";
22

3+
34
exportconstselectEnterpriseEditionStatus=(state:AppState)=>
45
state.ui.enterprise?.enterprise?.eeActive??false;
56

@@ -25,3 +26,6 @@ export const getGlobalBrandingSetting = (state: AppState) => {
2526
exportconstgetWorkspaceBrandingSetting=(state:AppState)=>{
2627
returnstate.ui.enterprise?.workspaceBranding;
2728
}
29+
// Environment selectors
30+
exportconstselectEnvironments=(state:AppState)=>
31+
state.ui.enterprise?.environments??[];

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
importReact,{createContext,useContext,useState,useEffect}from'react';
2-
import{fetchEnterpriseLicense}from'redux/reduxActions/enterpriseActions';
2+
import{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";
@@ -23,6 +23,7 @@ export const EnterpriseProvider: React.FC<ProviderProps> = ({ children }) => {
2323
if(isEEEnvironment()){
2424
// Fetch the enterprise license only if we're in an EE environment
2525
dispatch(fetchEnterpriseLicense());
26+
dispatch(fetchEnvironments());
2627
}else{
2728
// Set the state to false for non-EE environments
2829
// setEEActiveState(false);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp